File size: 1,435 Bytes
9994aaf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# PrimeTTS v2-Stream-Clean — token-level streaming, v2-clean audio

The definitive streaming variant: **token-level band-attention encoder** (input
streams incrementally) **+ v2's non-causal clean vocoder** (no parasite noise).
Reconciles token-level input streaming with clean audio — the causal v2-Stream
sacrificed quality unnecessarily; this doesn't.

- `v2streamclean_enc.onnx` — text (x,tone,lang,x_lengths,noise_scale,length_scale) → z[1,192,T]. Band encoder, token-level. Run **once** per phrase.
- `v2streamclean_dec.onnx` — z[1,192,Tc] → wav[1,1,Tc·256]. Clean non-causal vocoder. Run **per chunk**, overlap-save.
- `onnx_stream.py` — reference runner (uses the right params).

**Streaming params: chunk = 24, left = 64, RIGHT = 16** (the clean non-causal
vocoder needs 16 future frames for bit-exact chunking; the causal one used 4).
16 kHz, zh-TW + English.

```python
from onnx_stream import StreamingTTS   # RIGHT=16 baked in
tts = StreamingTTS("v2streamclean_enc.onnx", "v2streamclean_dec.onnx")
z = tts.encode(phone_ids, tone_ids, lang_ids)      # once
for pcm in tts.stream(z): play(pcm)                # per 24-frame chunk, clean audio
```
Frontend (text→ids): g2pw bopomofo + g2p_en, 88 syms/6 tones/2 langs, add_blank.
sherpa-onnx: `OfflineTtsMbistftStreamModel(enc, dec, num_threads=2, right_lookahead=16)`.

License: Apache-2.0 · part of [Luigi/PrimeTTS](https://huggingface.co/Luigi/PrimeTTS).