OmniVoice fp4-4bit-bnb

This repository contains the fp4-4bit-bnb converted OmniVoice model for PyTorch inference.

Converter / inference repository:
https://github.com/kawshikbuet17/OmniVoice-Model-Converter

Requirements

Install these packages in your Python environment:

omnivoice
torch
soundfile
numpy

Basic Python Inference

Prepare two local files before running:

ref_audio.wav
ref_text.txt
from pathlib import Path

import numpy as np
import soundfile as sf
import torch
from omnivoice import OmniVoice

repo_id = "kawshikbuet17/OmniVoice-fp4-4bit-bnb"

text = "আমি কৌশিকের কনভার্ট করা মডেল ব্যবহার করে এই অডিওটি তৈরি করছি।"
ref_audio = "./ref_audio.wav"
ref_text = Path("./ref_text.txt").read_text(encoding="utf-8").strip()
out_wav = "./omnivoice_fp4-4bit-bnb_output.wav"

model = OmniVoice.from_pretrained(
    repo_id,
    device_map="cuda:0",
    dtype=torch.float16,
)

model.eval() if hasattr(model, "eval") else None

with torch.inference_mode():
    output = model.generate(
        text=text,
        language="Bengali",
        ref_audio=ref_audio,
        ref_text=ref_text,
        num_step=32,
        guidance_scale=2.0,
        speed=1.0,
        t_shift=0.1,
        denoise=True,
        postprocess_output=True,
        layer_penalty_factor=5.0,
        position_temperature=5.0,
        class_temperature=0.0,
        audio_chunk_duration=15.0,
        audio_chunk_threshold=30.0,
    )

if isinstance(output, dict):
    for key in ["audio", "audios", "wav", "wavs", "waveform", "samples"]:
        if key in output:
            output = output[key]
            break

if isinstance(output, (tuple, list)):
    output = output[0]

if isinstance(output, torch.Tensor):
    audio = output.detach().float().cpu().numpy()
else:
    audio = np.asarray(output, dtype=np.float32)

while audio.ndim > 1 and audio.shape[0] == 1:
    audio = audio[0]

if audio.ndim == 2 and audio.shape[0] <= 8 and audio.shape[1] > audio.shape[0]:
    audio = audio.T

audio = np.clip(audio, -1.0, 1.0)
sample_rate = getattr(model, "sampling_rate", None) or getattr(model, "sample_rate", None) or 24000

sf.write(out_wav, audio, sample_rate)
print(f"Saved: {out_wav}")

Notes

  • Use device_map="cuda:0" or device_map="cuda:1" based on your GPU.
  • Use device_map="cpu" only if GPU is not available. CPU inference can be slow.

Prepared By

Kawshik Kumar Paul
Software Engineer | Researcher
Department of Computer Science and Engineering (CSE)
Bangladesh University of Engineering and Technology (BUET)
Email: kawshikbuet17@gmail.com

Downloads last month
23
Safetensors
Model size
0.8B params
Tensor type
I64
·
F32
·
F16
·
U8
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for kawshikbuet17/OmniVoice-fp4-4bit-bnb

Finetuned
Qwen/Qwen3-0.6B
Finetuned
k2-fsa/OmniVoice
Quantized
(18)
this model