Views
No views yet
Important — Russian stress is automatic. Text inside<ru>…</ru>receives stress markers automatically by default. Explicit+markers always win.Important — cross-language prompts. When an English reference voice is speaking Russian, experiment withduration_scalebelow1(for example0.8). It is usually a better starting point than the default1.Recommended voices:ru_f1andru_m5are the preferred Russian voice prompts.
pip install -r requirements.txtsounddevice is only required for direct speaker playback. On Linux, install
the system PortAudio library if it is not already present.1from transformers import AutoModel
2
3tts = AutoModel.from_pretrained(
4 "TeraSpace/TeraTTSv2",
5 trust_remote_code=True,
6 provider="CPUExecutionProvider",
7 threads=6
8)
9
10waveform = tts.generate_speech(
11 "<ru>Привет от TeraTTS.</ru>",
12 voice="ru_f1",
13 duration_scale=1,
14)
15tts.save_wav("teratts.wav", waveform)waveform is a mono float32 NumPy array at 44,100 Hz. save_wav writes
standard signed-16-bit PCM WAV without an extra audio package.tts.normalize_text(text).| Control | Values | Effect |
|---|---|---|
voice | ru_f1 ★, ru_m5 ★, ru_f2, ru_m1, eng_f3, eng_f4_whisper, eng_f5, eng_m2_whisper, eng_m3, eng_m4 | Selects a bundled precomputed voice style named after its reference audio. ★ marks the recommended Russian prompts. |
duration_scale | Positive float, default 1 | Higher values produce slower, longer speech. |
diffusion_model | distilled (default), teacher | Distilled is faster; teacher supports adjustable CFG. |
ruaccent_mode | full (default), dictionary | Full uses RUAccent neural ONNX graphs plus dictionaries; dictionary mode loads dictionaries only. |
diffusion_model="distilled" is the fast eight-step sampler. To
use the teacher sampler, choose it while loading:1teacher_tts = AutoModel.from_pretrained(
2 "TeraSpace/TeraTTSv2",
3 trust_remote_code=True,
4 provider="CPUExecutionProvider",
5 threads=6,
6 diffusion_model="teacher",
7)guidance can be adjusted when generating with the teacher sampler. The
distilled sampler has CFG 3 baked into its graph.<en>…</en> or <ru>…</ru>. The
runtime rejects untagged or unbalanced input with a tag-specific error. Before
number expansion and stress marking, it inserts spaces after punctuation and
between a number and a following word. Characters outside the model vocabulary
are skipped with a runtime warning. Numbers inside language tags are expanded to
words in the matching language before synthesis:1waveform = tts.generate_speech(
2 "<ru>У меня 21 яблоко.</ru> <en>I have 42 apples.</en>",
3 voice="ru_f1",
4 duration_scale=1,
5)+ markers remain authoritative. For a lower-memory,
deterministic dictionary-only path, choose the mode while loading:1dictionary_tts = AutoModel.from_pretrained(
2 "TeraSpace/TeraTTSv2",
3 trust_remote_code=True,
4 provider="CPUExecutionProvider",
5 threads=6,
6 ruaccent_mode="dictionary",
7)ё replacements, while unknown words and
ambiguous homographs are left unchanged. Set russian_stress=False to disable
automatic Russian stress processing entirely.eng_f3 for Russian text, start by trying
duration_scale=0.8 and adjust by ear:1waveform = tts.generate_speech(
2 "<ru>Это русский текст английским голосом.</ru>",
3 voice="eng_f3",
4 duration_scale=0.8,
5)1for chunk in tts.generate_speech_stream(
2 "<en>Streaming speech is ready.</en>",
3 voice="eng_f3",
4 duration_scale=1,
5):
6 # Send float32 mono chunks (44,100 Hz) to a player or network client.
7 consume(chunk)trust_remote_code=True.RUACCENT_NOTICE.txt.