k2-fsa/OmniVoice

High-Quality Voice Cloning TTS for 600+ Languages

OmniVoice – 大規模、零樣本文字轉語音

是什麼 – OmniVoice 是一個可合成 600 多種語言 的多語言文字轉語音(TTS)系統,無需任何語言特定的微調。它採用擴散式語言模型架構,以極低的即時因子(RTF ≈ 0.025,即快 40 倍於即時)生成高品質音訊。該模型支援三種主要用途:

  1. 語音克隆 – 生成與短參考錄音相似的語音。
  2. 語音設計 – 不提供參考音訊,而是指定說話人屬性(性別、年齡、音高、口音、方言、輕聲等)。
  3. 自動語音 – 讓模型自動選擇語音。

它還支援細粒度控制,例如非語言符號([laughter])和顯式發音提示(中文拼音、英文 CMU 音素)。


快速開始

  • Web UI – 執行 omnivoice-demo --ip 0.0.0.0 --port 8001 啟動 Gradio 示範。
  • Hugging Face Space – 在 https://huggingface.co/spaces/k2-fsa/OmniVoice 在線試用模型。
  • Colab 筆記本 – README 中連結了可直接執行的筆記本。

安裝(pip)

# 安裝與硬體匹配的 PyTorch(CUDA、Apple Silicon、Intel XPU)
# 例如,適用於最新 NVIDIA GPU:
pip install torch==2.8.0+cu128 torchaudio==2.8.0+cu128 \
    --extra-index-url https://download.pytorch.org/whl/cu128

# 安裝套件(PyPI 上的穩定版)
pip install omnivoice

從倉儲直接安裝(pip install git+https://github.com/k2-fsa/OmniVoice.git)或使用 uv 工具同步相依性。


Python API(核心模式)

from omnivoice import OmniVoice
import soundfile as sf, torch

model = OmniVoice.from_pretrained(
    "k2-fsa/OmniVoice",
    device_map="cuda:0",   # Apple Silicon 用 "mps",Intel Arc 用 "xpu"
    dtype=torch.float16)

# 1️⃣ 語音克隆
audio = model.generate(
    text="Hello, this is a test of zero-shot voice cloning.",
    ref_audio="ref.wav",
    ref_text="Transcription of the reference audio.")
sf.write("out.wav", audio[0], 24000)

# 2️⃣ 語音設計
audio = model.generate(
    text="Hello, this is a test of voice design.",
    instruct="female, low pitch, british accent")

# 3️⃣ 自動語音
audio = model.generate(text="Just speak in a random voice.")

相同的 model.generate 呼叫也支援擴散步數(num_step)、速度因子、固定時長等眾多參數,詳見 docs/generation-parameters.md


命令列工具

命令 典型用途
omnivoice-demo 啟動互動式 Gradio 示範
omnivoice-infer 單句推論(語音克隆、設計或自動)
omnivoice-infer-batch 高吞吐批量推論,可跨 GPU 分散

所有 CLI 選項均與 Python API 參數一致(如 --ref_audio--instruct--num_step)。


速度優化技巧

  • FlashInfer 內核可在不損失品質的情況下實現 2–2.9 倍加速。安裝對應 CUDA 版本的預編譯 wheel,並透過 --enable_flashinfer true(CLI)或 apply_flashinfer(model)(Python)啟用。CUDA 圖進一步提升單批次(batch-size 1)的延遲效能。

訓練與評估

倉儲包含 examples/ 資料夾,逐步介紹資料準備、模型訓練、評估和微調流程。使用者可將此流程適配至自有資料。


社群與支援

  • 問題在 GitHub 上處理。
  • 提供微信群組和官方帳號,用於中文社群討論。
  • 社群專案列表維護在 docs/community-projects.md 中。

引用

若在研究中使用 OmniVoice,請引用 arXiv 論文:

@article{zhu2026omnivoice,
  title={OmniVoice: Towards Omnilingual Zero‑Shot Text‑to‑Speech with Diffusion Language Models},
  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},
  journal={arXiv preprint arXiv:2604.00688},
  year={2026}
}

伦理說明

作者明確禁止非法語音克隆、冒充、詐欺或其他任何非法/不道德用途。使用者須遵守當地法規和負責任 AI 指南。

相關

  • 專案
  • 專案
  • 專案
  • 專案
  • 專案