Skip to main content

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.5B unless SPARKTTS_MODEL_DIR is set
  • saves outputs in models/bos_model/audio/spark_tts/results/<timestamp>_<profile>/

Main outputs:

  • compile.wav
  • measured.wav
  • inference.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​

OptionDefaultDescription
--textText from the selected profileTarget text to synthesize. It is required when no prompt profile is selected.
--prompt-profiles-pathexample/prompt_profiles.jsonJSON file containing named prompt profiles.
--prompt-profile42dotProfile name to load. Pass an empty string (--prompt-profile "") to use custom prompt inputs.
--prompt-textEmptyTranscript of the reference audio. It should accurately match the spoken audio.
--prompt-speech-pathEmptyPath to the reference audio used for voice conditioning.
--reference-modeautoReference-conditioning strategy: auto, global_only, or transcript_conditioned.

Reference modes:

ModeDescription
autoUses 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_onlyUses 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_conditionedConditions generation on both the reference audio and its transcript. It requires a non-empty --prompt-text.

Controllable TTS​

OptionDefaultDescription
--use-control-ttsfalseUse controllable voice attributes instead of a prompt profile or custom reference voice.
--genderfemaleVoice gender: male or female.
--pitchlowVoice pitch: very_low, low, moderate, high, or very_high.
--speedlowSpeaking speed: very_low, low, moderate, high, or very_high.

Generation​

OptionDefaultDescription
--max-new-tokens1280Maximum number of Qwen tokens to generate. Larger values allow longer output but increase runtime and KV-cache requirements.
--temperature0.8Sampling temperature. Higher values increase randomness; values less than or equal to 0 use greedy decoding.
--top-k50Restrict sampling to the k highest-probability tokens. Use -1 to disable top-k filtering; 0 is invalid.
--top-p0.95Nucleus-sampling probability threshold in the range (0, 1]. Use 1 to disable top-p filtering.
--seed0Random seed reset before each compile, warmup, and measured phase.

Runtime and Output​

OptionDefaultDescription
--tracefalseCapture a TTNN decode trace during warmup and replay it during measured inference.
--iter1Number of measured end-to-end runs used to calculate average metrics. Must be at least 1.
--enable-logfalsePrint the expanded benchmark KPI summary and stage timing breakdown.
--device-id0ID of the TT device used for inference.
--l1-small-size49152TT device L1 small-region size in bytes. This advanced option normally should not be changed.
--model-dirDownloaded model directoryDirectory containing the Spark-TTS weights.
--save-dirresults/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-mode supports auto, global_only, and transcript_conditioned.
  • measured.wav is 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