Spark-TTS on TT
TT implementation of Spark-TTS 0.5B.
Setup
From the repository root:
source env_set.sh sparktts
models/bos_model/audio/spark_tts/setup.sh
This uses the repository's existing default python_env; no SparkTTS-specific
environment is required. If the repository has not been set up yet, follow the
top-level build instructions to run ./build_metal.sh and
./create_venv.sh default once. setup.sh then installs only SparkTTS's missing
audio/config dependencies and downloads the pinned reference weights.
If you run Python modules directly, keep the same shell active so the Python path and TT environment stay configured.
For later shells, activate the same default environment and SparkTTS paths from the repository root:
source env_set.sh sparktts
Run Inference
Default prompt-based TTS:
bash $WORKING_DIR/runner/infer.sh
This default run:
- uses prompt profile
42dot - uses the model in
models/bos_model/audio/spark_tts/reference/pretrained_models/Spark-TTS-0.5BunlessSPARKTTS_MODEL_DIRis set - saves outputs in
models/bos_model/audio/spark_tts/results/<timestamp>_<profile>/
Main outputs:
compile.wavmeasured.wavinference.log
Command-Line Options
Options use the form --option-name value. Boolean options can be enabled by passing the flag without a value, for example --trace.
Text and Reference Voice
| Option | Default | Description |
|---|---|---|
--text | Text from the selected profile | Target text to synthesize. It is required when no prompt profile is selected. |
--prompt-profiles-path | example/prompt_profiles.json | JSON file containing named prompt profiles. |
--prompt-profile | 42dot | Profile name to load. Pass an empty string (--prompt-profile "") to use custom prompt inputs. |
--prompt-text | Empty | Transcript of the reference audio. It should accurately match the spoken audio. |
--prompt-speech-path | Empty | Path to the reference audio used for voice conditioning. |
--reference-mode | auto | Reference-conditioning strategy: auto, global_only, or transcript_conditioned. |
Reference modes:
| Mode | Description |
|---|---|
auto | Uses the profile's reference_mode when a profile is selected. Profiles without an explicit mode default to transcript_conditioned. For custom inputs, it selects transcript_conditioned when --prompt-text is provided and global_only otherwise. |
global_only | Uses global information from the reference voice without adding transcript-derived reference semantic tokens to the Qwen prompt. Use this mode when an accurate transcript is unavailable. |
transcript_conditioned | Conditions generation on both the reference audio and its transcript. It requires a non-empty --prompt-text. |
Controllable TTS
| Option | Default | Description |
|---|---|---|
--use-control-tts | false | Use controllable voice attributes instead of a prompt profile or custom reference voice. |
--gender | female | Voice gender: male or female. |
--pitch | low | Voice pitch: very_low, low, moderate, high, or very_high. |
--speed | low | Speaking speed: very_low, low, moderate, high, or very_high. |
Generation
| Option | Default | Description |
|---|---|---|
--max-new-tokens | 1280 | Maximum number of Qwen tokens to generate. Larger values allow longer output but increase runtime and KV-cache requirements. |
--temperature | 0.8 | Sampling temperature. Higher values increase randomness; values less than or equal to 0 use greedy decoding. |
--top-k | 50 | Restrict sampling to the k highest-probability tokens. Use -1 to disable top-k filtering; 0 is invalid. |
--top-p | 0.95 | Nucleus-sampling probability threshold in the range (0, 1]. Use 1 to disable top-p filtering. |
--seed | 0 | Random seed reset before each compile, warmup, and measured phase. |
Runtime and Output
| Option | Default | Description |
|---|---|---|
--trace | false | Capture a TTNN decode trace during warmup and replay it during measured inference. |
--iter | 1 | Number of measured end-to-end runs used to calculate average metrics. Must be at least 1. |
--enable-log | false | Print the expanded benchmark KPI summary and stage timing breakdown. |
--device-id | 0 | ID of the TT device used for inference. |
--l1-small-size | 49152 | TT device L1 small-region size in bytes. This advanced option normally should not be changed. |
--model-dir | Downloaded model directory | Directory containing the Spark-TTS weights. |
--save-dir | results/ | Parent directory for timestamped inference outputs. |
Prompt profile, custom reference, and controllable TTS are separate input modes. A prompt profile cannot be combined with --prompt-text, --prompt-speech-path, or controllable TTS attributes. An explicit --reference-mode cannot be used with controllable TTS.
Notes
- Configure the TT environment and Python path before running
infer.sh. - Direct Python entrypoints should be run after
source env_set.sh sparktts. --reference-modesupportsauto,global_only, andtranscript_conditioned.measured.wavis the main output to check.
Validation
After setup, verify imports and collect the suite without opening a device:
source env_set.sh sparktts
python -c "import bos_metal, einx, omegaconf, soundfile, soxr, torch, torchaudio, transformers, ttnn; from paths import SPARKTTS_ROOT; print(SPARKTTS_ROOT)"
python -m pytest models/bos_model/audio/spark_tts/tests --collect-only -q
Run the full SparkTTS suite on a configured TT system:
python -m pytest models/bos_model/audio/spark_tts/tests -q
Execute Commands (for SQE release)
Change only the target text:
bash models/bos_model/audio/spark_tts/runner/infer.sh \
--text "Hello from Spark-TTS."
Use a different prompt profiles file and profile name:
bash models/bos_model/audio/spark_tts/runner/infer.sh \
--prompt-profiles-path "$TT_METAL_HOME/models/bos_model/audio/spark_tts/example/prompt_profiles.json" \
--prompt-profile woman_en
Use custom prompt audio and transcript:
bash models/bos_model/audio/spark_tts/runner/infer.sh \
--prompt-profile "" \
--text "Hello from Spark-TTS." \
--prompt-text "Welcome to Vietnam. Nice to meet you." \
--prompt-speech-path /path/to/prompt.wav
Enable trace replay flow:
bash models/bos_model/audio/spark_tts/runner/infer.sh --trace
Adjust generation settings:
bash models/bos_model/audio/spark_tts/runner/infer.sh \
--max-new-tokens 1280 \
--temperature 0.8 \
--top-k 50 \
--top-p 0.95 \
--iter 1