Views
No views yet

[laughter]) and pronunciation correction via pinyin or phonemes.We recommend using a fresh virtual environment (e.g.,conda,venv, etc.) to avoid conflicts.
1# Install pytorch with your CUDA version, e.g.
2pip install torch==2.8.0+cu128 torchaudio==2.8.0+cu128 --extra-index-url https://download.pytorch.org/whl/cu128See PyTorch official site for other versions installation.
pip install torch==2.8.0 torchaudio==2.8.0pip install torch torchaudio --index-url https://pytorch-extension.intel.com/release-whl/stable/xpu/us/See Intel's PyTorch XPU guide for version-specific instructions.
python -c "import torch; print(torch.xpu.is_available(), torch.xpu.device_count())"flash_attn is not available on XPU; the model automatically falls back to SDPA.flex_attention) has partial XPU support; single-GPU SDPA training should work.1# From PyPI (stable release)
2pip install omnivoice
3
4# From the latest source on GitHub (no need to clone)
5pip install git+https://github.com/k2-fsa/OmniVoice.git
6
7# For development (clone first, editable install)
8git clone https://github.com/k2-fsa/OmniVoice.git
9cd OmniVoice
10pip install -e .1git clone https://github.com/k2-fsa/OmniVoice.git
2cd OmniVoice
3uv syncTip: Can use mirror withuv sync --default-index "https://mirrors.aliyun.com/pypi/simple"
omnivoice-demo --ip 0.0.0.0 --port 8001If you have trouble connecting to HuggingFace when downloading the pre-trained models, setexport HF_ENDPOINT="https://hf-mirror.com"before running.
ref_audio and ref_text:1from omnivoice import OmniVoice
2import soundfile as sf
3import torch
4
5model = OmniVoice.from_pretrained(
6 "k2-fsa/OmniVoice",
7 device_map="cuda:0",
8 dtype=torch.float16
9)
10# Apple Silicon users: use device_map="mps" instead
11# Intel Arc GPU users: use device_map="xpu" instead
12
13audio = model.generate(
14 text="Hello, this is a test of zero-shot voice cloning.",
15 ref_audio="ref.wav",
16 ref_text="Transcription of the reference audio.",
17) # audio is a list of `np.ndarray` with shape (T,) at 24 kHz.
18
19# If you don't want to input `ref_text` manually, you can directly omit the `ref_text`.
20# The model will use Whisper ASR to auto-transcribe it. To use a local copy (or
21# a different Whisper model), pass `asr_model_name="..."` to `from_pretrained`.
22# To control which device Whisper is loaded on (e.g. another GPU in multi-GPU
23# setups, or the CPU), pass `asr_device="cuda:1"` (or `"cpu"`).
24
25sf.write("out.wav", audio[0], 24000)1prompt = model.create_voice_clone_prompt(
2 ref_audio="ref.wav", ref_text="Transcription of the reference audio."
3)
4prompt.save("my_voice.pt")
5
6# Later, in a new session:
7from omnivoice import VoiceClonePrompt
8
9prompt = VoiceClonePrompt.load("my_voice.pt")
10audio = model.generate(text="Hello again!", voice_clone_prompt=prompt)Tips
Use a 3–10 seconds reference audio clip. Longer audio slows down inference and may degrade cloning quality. For standard pronunciation, use a reference audio in the same language as the target speech. In cross-lingual voice cloning (i.e., the reference audio and target speech are in different languages), the generated speech will carry an accent from the reference audio's language. For better results with Arabic numerals, normalize them to words first (e.g., "123" → "one hundred twenty-three"). You can passnormalize_text=Truetogenerate()to do this automatically (opt-in; install the extra withpip install "omnivoice[tn]", which pulls in WeTextProcessing):python1# "I have 2345 apples." is read correctly instead of digit-by-digit. 2audio = model.generate(text="I have 2345 apples.", normalize_text=True)Chinese and English use WeTextProcessing; other languages fall back tonum2wordsfor integers. Inline control syntax ([laughter],[B EY1 S], pinyin tone markers) is preserved. On macOS (Apple Silicon),pyninihas no wheel — install it viaconda install -c conda-forge pyninifirst.For more tips, see docs/tips.md.
1audio = model.generate(
2 text="Hello, this is a test of zero-shot voice design.",
3 instruct="female, low pitch, british accent",
4)Note: The model is primarily trained on the voice cloning task, so voice cloning is the most stable mode. Voice design is trained on Chinese and English data only. It can generalize to other languages, but may produce unstable results for some low-resource languages or edge cases.
audio = model.generate(text="This is a sentence without any voice prompt.")model.generate() API. You can further control the generation behavior via keyword arguments:1audio = model.generate(
2 text="...",
3 num_step=32, # diffusion steps (or 16 for faster inference)
4 speed=1.0, # speed factor (>1.0 faster, <1.0 slower)
5 duration=10.0, # fixed output duration in seconds (overrides speed)
6 # ... more options
7)[laughter] directly in the text to add expressive non-verbal sounds.audio = model.generate(text="[laughter] You really got me. I didn't see that coming at all.")[laughter], [sigh], [confirmation-en], [question-en], [question-ah], [question-oh], [question-ei], [question-yi], [surprise-ah], [surprise-oh], [surprise-wa], [surprise-yo], [dissatisfaction-hnn].audio = model.generate(text="这批货物打ZHE2出售后他严重SHE2本了,再也经不起ZHE1腾了。")audio = model.generate(text="He plays the [B EY1 S] guitar while catching a [B AE1 S] fish.")| Command | Description | Source |
|---|---|---|
omnivoice-demo | Interactive Gradio web demo | omnivoice/cli/demo.py |
omnivoice-infer | Single-item inference | omnivoice/cli/infer.py |
omnivoice-infer-batch | Batch inference across multiple GPUs | omnivoice/cli/infer_batch.py |
omnivoice-demo --ip 0.0.0.0 --port 8001omnivoice-demo --help for all options.1# Voice Cloning
2# ref_text can be omitted (Whisper will auto-transcribe ref_audio to get it).
3omnivoice-infer \
4 --model k2-fsa/OmniVoice \
5 --text "This is a test for text to speech." \
6 --ref_audio ref.wav \
7 --ref_text "Transcription of the reference audio." \
8 --output hello.wav
9
10# Voice Design
11omnivoice-infer --model k2-fsa/OmniVoice \
12 --text "This is a test for text to speech." \
13 --instruct "male, British accent" \
14 --output hello.wav
15
16# Auto Voice
17omnivoice-infer \
18 --model k2-fsa/OmniVoice \
19 --text "This is a test for text to speech."\
20 --output hello.wavomnivoice-infer-batch can distribute batch inference across multiple GPUs, designed for large-scale TTS tasks.1omnivoice-infer-batch \
2 --model k2-fsa/OmniVoice \
3 --test_list test.jsonl \
4 --res_dir results/{"id": "sample_001", "text": "Hello world", "ref_audio": "/path/to/ref.wav", "ref_text": "Reference transcript", "instruct": "female, british accent", "language_id": "en", "duration": 10.0, "speed": 1.0}id and text are mandatory fields. ref_audio and ref_text are used in voice cloning mode. instruct is used in voice design mode. If no reference audio or instruct are provided, the model will generate text in a random voice.language_id, duration, and speed are optional. duration (in seconds) fixes the output length; speed controls the speaking rate. If duration and speed are both provided, speed will be ignored.| Wechat Group | Wechat Official Account |
|---|---|
![]() | ![]() |
1@article{zhu2026omnivoice,
2 title={OmniVoice: Towards Omnilingual Zero-Shot Text-to-Speech with Diffusion Language Models},
3 author={Zhu, Han and Ye, Lingxuan and Kang, Wei and Yao, Zengwei and Guo, Liyong and Kuang, Fangjun and Han, Zhifeng and Zhuang, Weiji and Lin, Long and Povey, Daniel},
4 journal={arXiv preprint arXiv:2604.00688},
5 year={2026}
6}