用途
OmniVoice 是一个支持 600 多种语言的大规模多语言零样本 TTS 模型,采用扩散语言模型风格架构。它可用于多语言文本转语音、从短音频片段克隆说话人音色、通过文本属性设计说话人声音,以及无需任何提示的自动语音生成。
主要能力
OmniVoice 提供三种核心模式:
- 语音克隆:提供参考音频(ref_audio)与参考文本(ref_text),从短音频片段克隆说话人。ref_text 可省略,此时由 Whisper 自动转写参考音频。
- 语音设计:通过 instruct 字符串描述说话人属性,无需音频。支持的属性包括性别(male、female)、年龄(child、young、middle-aged、elderly)、音高(very low pitch、low pitch、high pitch、very high pitch)、风格(whisper)、英语口音(american accent、british accent、australian accent 等)以及中文方言(如四川话、陕西话等)。
- 自动语音:不提供额外信息,模型随机选择音色。
其他能力包括:
- 生成参数控制:num_step(扩散步数,默认 32,可用 16 加速)、speed(语速倍率)、duration(固定输出时长,覆盖 speed)。
- 非语言符号:可在文本中内联插入 [laughter]、[sigh]、[confirmation-en]、[question-en]、[question-ah]、[question-oh]、[question-ei]、[question-yi]、[surprise-ah]、[surprise-oh]、[surprise-wa]、[surprise-yo]、[dissatisfaction-hnn] 等表达性声音标签。
- 发音控制:中文可用带声调数字的内联拼音(大写,如 ZHE2);英文可用方括号内的 CMU 词典发音(大写,如 [IH1 T])。
- 输出格式:采样率 24,000 Hz,类型为 list[torch.Tensor],每个张量形状 (1, T),可用 torchaudio.save(path, audio[0], 24000) 保存。
使用方式
安装
环境要求:Python 3.9+、PyTorch 2.8+、CUDA(推荐)或 Apple Silicon(MPS)或 CPU、pip(推荐)。
第一步,按平台安装 PyTorch:
NVIDIA GPU(CUDA 12.8):
pip install torch==2.8.0+cu128 torchaudio==2.8.0+cu128 --extra-index-url https://download.pytorch.org/whl/cu128
Apple Silicon:
pip install torch==2.8.0 torchaudio==2.8.0
第二步,安装 OmniVoice:
pip install omnivoice
或从源码安装最新版:
pip install git+https://github.com/k2-fsa/OmniVoice.git
或可编辑开发安装:
git clone https://github.com/k2-fsa/OmniVoice.git cd OmniVoice pip install -e .
使用 uv:
git clone https://github.com/k2-fsa/OmniVoice.git cd OmniVoice uv sync
使用镜像:uv sync --default-index "https://mirrors.aliyun.com/pypi/simple"
若 HuggingFace 被屏蔽,可设置镜像:
export HF_ENDPOINT="https://hf-mirror.com"
Python API
加载模型(NVIDIA GPU):
from omnivoice import OmniVoice import torch import torchaudio
model = OmniVoice.from_pretrained( "k2-fsa/OmniVoice", device_map="cuda:0", dtype=torch.float16 )
Apple Silicon 使用 device_map="mps",CPU 使用 device_map="cpu" 与 dtype=torch.float32(较慢)。
语音克隆(带手动参考转写,更快更准确):
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.", )
省略 ref_text 时由 Whisper 自动转写 ref_audio。
语音设计:
audio = model.generate( text="Hello, this is a test of zero-shot voice design.", instruct="female, low pitch, british accent", )
自动语音:
audio = model.generate(text="This is a sentence without any voice prompt.")
生成参数示例:
audio = model.generate( text="Hello world.", ref_audio="ref.wav", ref_text="Reference text.", num_step=32, speed=1.2, duration=8.0, )
命令行工具
Web 演示:
omnivoice-demo --ip 0.0.0.0 --port 8001 omnivoice-demo --help
单条推理(语音克隆):
omnivoice-infer
--model k2-fsa/OmniVoice
--text "This is a test for text to speech."
--ref_audio ref.wav
--ref_text "Transcription of the reference audio."
--output hello.wav
单条推理(语音设计):
omnivoice-infer
--model k2-fsa/OmniVoice
--text "This is a test for text to speech."
--instruct "male, British accent"
--output hello.wav
单条推理(自动语音):
omnivoice-infer
--model k2-fsa/OmniVoice
--text "This is a test for text to speech."
--output hello.wav
批量推理(多 GPU):
omnivoice-infer-batch
--model k2-fsa/OmniVoice
--test_list test.jsonl
--res_dir results/
JSONL 字段:id(必填,唯一标识)、text(必填,待合成文本)、ref_audio(可选,参考音频路径)、ref_text(可选,参考音频转写)、instruct(可选,说话人属性)、language_id(可选,语言代码如 "en")、language_name(可选,语言名称如 "English")、duration(可选,固定输出时长秒数)、speed(可选,语速倍率,设置 duration 时忽略)。
适用场景
- 多语言语音合成与配音。
- 基于短参考音频的个性化音色克隆。
- 通过文本属性快速设计不同性别、年龄、音高、口音或方言的说话人声音。
- 批量生成语音数据集(支持多 GPU 批量推理)。
- 需要表达性非语言声音(笑声、叹气、疑问语气等)的语音内容。
限制与注意事项
- 环境要求 Python 3.9+、PyTorch 2.8+,推荐 CUDA 或 Apple Silicon,CPU 推理较慢。
- 输出采样率固定为 24,000 Hz。
- 音质问题可通过提高 num_step 至 32 或 64、手动提供 ref_text、使用干净无噪的参考音频(建议 3–15 秒)改善。
- CUDA 显存不足时使用 float16 而非 float32,或减小批量大小与文本长度。
- Whisper 自动转写需安装 openai-whisper。
- 中文发音错误可使用内联带声调数字的拼音(如 ZHE2)纠正。
- Apple Silicon(MPS)需显式使用 device_map="mps"。
- 模型与资源:HuggingFace 模型 k2-fsa/OmniVoice,HuggingFace Space https://huggingface.co/spaces/k2-fsa/OmniVoice,论文 https://arxiv.org/abs/2604.00688,演示页 https://zhu-han.github.io/omnivoice,支持语言见仓库 docs/languages.md,语音设计属性见 docs/voice-design.md,生成参数见 docs/generation-parameters.md,训练/评估示例见仓库 examples/。
- 关于收费、价格、平台等具体信息,资料中暂未提供。