Skip to main content

BOS Omnivoice on N1A0

Overview​

OmniVoice is an omnilingual zero-shot text-to-speech (TTS) model built on a diffusion language model (masked / non-autoregressive iterative decoding) instead of the usual autoregressive token-by-token decoder.

Pipeline:

ComponentDetail
BackboneQwen3, 28 decoder layers, hidden 1024, 16 heads / 8 KV heads (GQA), head_dim 128, FFN 3072, RoPE theta 1e6, RMSNorm eps 1e-6
Audio codecHiggs-Audio-V2 tokenizer — HuBERT semantic encoder + DAC acoustic encoder + residual vector quantizer
Codebooks8 x 1025 tokens (1024 = mask id), codebook weights [8, 8, 6, 6, 4, 4, 2, 2]
DecodingIterative masked (diffusion-style) decoding with classifier-free guidance
Output24 kHz mono waveform

Scope​

  • Checkpoint: k2-fsa/OmniVoice (HuggingFace Hub, default for every runner).
  • Auxiliary models: eustlb/higgs-audio-v2-tokenizer (codec), openai/whisper-large-v3-turbo (optional reference-text ASR).
  • Platform: BOS N1A0 / Blackhole, single device (device_id=0), 4 x 5 compute-core grid (compute_with_storage_grid_size=(5, 4) = 20 cores) for the LLM decoder; the audio-tokenizer modules auto-size their grid from device.compute_with_storage_grid_size().
  • Backends: pytorch (reference, CPU/CUDA/XPU/MPS) and ttnn (hybrid TT-Metal + PyTorch host glue).
  • Supported modes:
    • Voice clone — --ref-audio (+ optional --ref-text, auto-transcribed when omitted)
    • Voice design — --instruct comma-separated attributes from the supported vocabulary, no reference audio
    • Auto — neither reference nor instruction; the model picks a voice
  • Batch size: 1 request at a time (the guided forward internally runs a conditional + unconditional pair).

Repository layout​

PathPurpose
assets/Reference audio: demo/ (short samples) and beckmark/ (LibriSpeech clips)
evaluation/LibriSpeech subset builder and batch generation driver
reference/Pure PyTorch reference implementation (omnivoice.py, modules/, cli/)
tests/Unit, smoke, real-device and Tracy PCC tests
tt/TTNN implementation: omnivoice.py, modules/llm, modules/audio_tokenizer, static_embedding_cache.py, target_audio_head.py
utils/Shared audio I/O, text normalization, duration estimation, metric logging
backends.pyBackend enum + load_model() dispatcher
run_model.pySingle-request inference runner (the only entry point)
pyproject.tomlDependencies, extras (tn, eval), ruff config

Every caller goes through backends.py, which dispatches to either the PyTorch or TTNN backend implementation. Switching backend is a single CLI flag.


Setup environment​

From the repository root:

cd $TT_METAL_HOME
./create_venv.sh omnivoice
source env_set.sh omnivoice

Supported CLI Arguments​

Shared by run_model.py and evaluation/generate_audio.py.

FlagTypeDefaultDescription
--backendpytorch | ttnnpytorch
(ttnn in generate_audio.py)
Inference backend
--modelstrk2-fsa/OmniVoiceCheckpoint dir or HF repo
--devicestrautoTorch device (cuda > xpu > mps > cpu)
--textstrrequiredText to synthesize
--outputpathoutput.wavOutput WAV path
--languagestrNoneLanguage hint
--ref-audio / --ref_audiopathNoneReference audio for voice cloning
--ref-text / --ref_textstrNoneReference transcript (ASR-filled when omitted)
--instructstrNoneComma-separated attributes from the supported vocabulary (voice design mode; not free text)
--durationfloatNoneForce output duration (sec)
--speedfloat1.0Speaking-rate multiplier
--num-step / --num_stepint16Iterative unmasking steps
--guidance-scalefloat1Classifier-free guidance scale
--t-shiftfloat0.1Masking-schedule time shift
--denoiseboolTrueDenoise the reference audio
--preprocess-promptboolTrue (generate_audio.py only)Normalize/prepare the reference prompt
--postprocess-outputboolTruePost-process the generated waveform
--layer-penalty-factorfloat5.0Per-codebook layer penalty during unmasking
--position-temperaturefloat5.0Position sampling temperature
--class-temperaturefloat0.0Token (class) sampling temperature
--cacheflagoffReuse the reference audio-tokenizer output from TT DRAM. Requires --backend ttnn and --ref-audio. run_model.py only.
--benchmarkflagoffBenchmark timing and metric logging

run_model.py​

Single request, end to end. It opens the TTNN device, enables the program cache, loads the model, runs 3 warm-up generations, then one synchronized timed generation, and saves the generated WAV file. If --benchmark is provided, the script additionally logs the complete benchmark metrics.

cd $TT_METAL_HOME
python models/bos_model/audio/omnivoice/run_model.py \
--backend ttnn \
--text "Excuse me, could you tell me how to get to the nearest post office? Sure! Go straight for two blocks, then turn left at the traffic light. It's on your right. Thank you so much!" \
--ref-audio models/bos_model/audio/omnivoice/assets/demo/ref_audio2.wav \
--ref-text "Hello, how are you? I'm fine, thankyou, and you?" \
--guidance-scale 1 \
--output output.wav

With --cache, the reference audio is tokenized once into TT DRAM before the timed run; the runner then asserts tokenizer_encode_count did not increase, so a silent cache miss fails loudly instead of quietly costing latency.

Voice design instructions​

--instruct accepts a closed vocabulary of voice attributes, not a free-text style prompt. Combine attributes with a comma and a space for English, or a full-width comma (,) for Chinese. Choose no more than one value from each mutually exclusive category.

CategoryValid English valuesValid Chinese values
Gendermale, female男, 女
Agechild, teenager, young adult, middle-aged, elderly儿童, 少年, 青年, 中年, 老年
Pitchvery low pitch, low pitch, moderate pitch, high pitch, very high pitch极低音调, 低音调, 中音调, 高音调, 极高音调
Voice qualitywhisper耳语
Accent (English only)american accent, british accent, australian accent, chinese accent, canadian accent, indian accent, korean accent, portuguese accent, russian accent, japanese accent—
Dialect (Chinese only)—河南话, 陕西话, 四川话, 贵州话, 云南话, 桂林话, 济南话, 石家庄话, 甘肃话, 宁夏话, 青岛话, 东北话

Do not mix English and Chinese attributes, or an English accent with a Chinese dialect. Values must match the vocabulary: for example, use low pitch, not low-pitched.

English voice-design example:

python models/bos_model/audio/omnivoice/run_model.py \
--backend ttnn \
--text "Welcome to today's program." \
--instruct "female, young adult, low pitch, american accent" \
--output output.wav

Chinese voice-design example:

python models/bos_model/audio/omnivoice/run_model.py \
--backend ttnn \
--text "欢迎收听今天的节目。" \
--instruct "女,青年,低音调,河南话" \
--output output.wav

Librispeech Evaluation​

Batch generation over a LibriSpeech-style dataset. Full details in the evaluation README.

cd $TT_METAL_HOME

# 1. build a packaged LibriSpeech subset (audio/ + metadata.parquet)
python models/bos_model/audio/omnivoice/evaluation/downloader.py \
--num-rows 10 --seed 42 \
--output-dir models/bos_model/audio/omnivoice/evaluation/librispeech_subset

# 2. generate audio on device
python models/bos_model/audio/omnivoice/evaluation/generate_audio.py \
--backend ttnn \
--dataset-root models/bos_model/audio/omnivoice/evaluation/librispeech_subset \
--num-samples 10 --selection-seed 42 --generation-seed 42 \
--output-dir models/bos_model/audio/omnivoice/evaluation/results

# 3. WER evaluation (optional)
python models/bos_model/audio/omnivoice/evaluation/eval_wer.py


Tests​

Tests are located in the tests directory and use pytest with real device artifacts. All integration tests require:

  • TT hardware (N1A0 device)
  • Captured real-module artifacts in tests/artifacts/real_major_modules.pt

Test matrix​

TestModuleTypeCommand
test_llm_real_pccQwen3 LLMIntegrationpytest tests/test_llm_pcc.py::test_llm_real_pcc -v
test_semantic_encoder_real_pccHuBERT semantic encoderIntegrationpytest tests/test_semantic_encoder_pcc.py::test_semantic_encoder_real_pcc -v
test_acoustic_pccDAC acoustic encoderIntegrationpytest tests/test_acoustic_pcc.py -v
test_hubert_pccHuBERT full stackIntegrationpytest tests/test_hubert_pcc.py -v
test_quantizer_pccRVQ quantizerIntegrationpytest tests/test_quantizer_pcc.py -v
test_audio_token_update_opsAudio token masking opsIntegrationpytest tests/test_audio_token_update_ops.py -v

Running tests​

Before running tests, capture real-module artifacts:

cd $TT_METAL_HOME
python models/bos_model/audio/omnivoice/tests/capture_all_real_artifacts.py

Run individual tests:

cd $TT_METAL_HOME

# LLM (Qwen3 decoder) PCC test
pytest models/bos_model/audio/omnivoice/tests/test_llm_pcc.py::test_llm_real_pcc -v

# Semantic encoder (HuBERT) PCC test
pytest models/bos_model/audio/omnivoice/tests/test_semantic_encoder_pcc.py::test_semantic_encoder_real_pcc -v

# Acoustic encoder (DAC) PCC test
pytest models/bos_model/audio/omnivoice/tests/test_acoustic_pcc.py -v

# HuBERT full stack PCC test
pytest models/bos_model/audio/omnivoice/tests/test_hubert_pcc.py -v

# RVQ quantizer PCC test
pytest models/bos_model/audio/omnivoice/tests/test_quantizer_pcc.py -v

# Audio token masking operations test
pytest models/bos_model/audio/omnivoice/tests/test_audio_token_update_ops.py -v