Views
No views yet
owensong/Inflect-Nano-v1 — a 4.63M-parameter
feed-forward English TTS (FastSpeech-style acoustic + Snake-activation HiFi-GAN vocoder, 24 kHz).
This repo packages the model as ONNX graphs for torch-free, real-time CPU inference on edge devices
(verified on a Jetson Nano gen1)..pt. A single-graph trace is blocked by the acoustic model's dynamic
length-regulator (Python .tolist() loops). This export uses the standard FastSpeech split — the
neural parts are ONNX, the length regulator is a small vectorized NumPy step on the host:phone/tone/lang/speaker ids
│
▼ acoustic_encoder.onnx (embeddings + Conv-FFN encoder + duration/pitch/energy heads)
conditioned[1,T,H], durations[1,T], pitch[1,T,2]
│
▼ host length-regulator (NumPy, ~free) — repeat-by-duration + frame meta + local context + abs-frame pos
frames / frame_meta / local_ctx_raw / abs_pos / pitch_frame / frame_mask
│
▼ acoustic_decoder.onnx (learned projections + Conv-FFN decoder + BiGRU + mel head + postnet)
mel[1,80,F]
│
▼ vocoder.onnx (Snake HiFi-GAN)
wav[1,1,F*256] @ 24 kHz| file | size | what |
|---|---|---|
acoustic_encoder.onnx | 5.6 MB | text ids → conditioned features + durations + pitch |
acoustic_decoder.onnx | 8.0 MB | regulated frames → mel |
vocoder.onnx | 4.7 MB | mel → 24 kHz waveform |
inflect_onnx_infer.py | — | reference onnxruntime runner incl. the NumPy host_regulate |
owensong/Inflect-Nano-v1's text_to_tokens, then feed the
ids here).| threads | RTF | peak RSS |
|---|---|---|
| 4 | 0.51 | 142 MB |
| 2 | 0.68 | 136 MB |
| 1 | 1.11 | 139 MB |
output.wav you can play)1pip install onnxruntime soundfile numpy g2p_en transformers numba
2# the base model provides the text frontend (text -> phoneme ids):
3git clone https://huggingface.co/owensong/Inflect-Nano-v1
4# run this script from the folder containing the .onnx files + inflect_onnx_infer.py1import sys, numpy as np, onnxruntime as ort, soundfile as sf
2sys.path.insert(0, "Inflect-Nano-v1") # base model frontend
3sys.path.insert(0, "Inflect-Nano-v1/third_party/tiny_tts_frontend")
4from inference import text_to_tokens # owensong/Inflect-Nano-v1: text -> ids
5from inflect_onnx_infer import host_regulate # this repo: NumPy length-regulator
6
7# 1) text -> phoneme / tone / language ids
8phone, tone, lang = text_to_tokens("Hello, this is a tiny on-device text to speech model.")
9phone, tone, lang = phone.numpy()[None], tone.numpy()[None], lang.numpy()[None] # [1, T] int64
10speaker = np.array([0], dtype=np.int64)
11
12# 2) ONNX pipeline: encoder -> NumPy regulator -> decoder -> vocoder
13sA = ort.InferenceSession("acoustic_encoder.onnx", providers=["CPUExecutionProvider"])
14sB = ort.InferenceSession("acoustic_decoder.onnx", providers=["CPUExecutionProvider"])
15sV = ort.InferenceSession("vocoder.onnx", providers=["CPUExecutionProvider"])
16cond, dur, pitch = sA.run(None, {"phone": phone, "tone": tone, "lang": lang, "speaker": speaker})
17mel = sB.run(None, host_regulate(cond, dur, pitch))[0]
18wav = sV.run(None, {"mel": mel.astype(np.float32)})[0].reshape(-1) # 24 kHz mono float32
19
20# 3) save to disk for inspection / playback
21sf.write("output.wav", wav, 24000)
22print(f"wrote output.wav (24 kHz, {len(wav)/24000:.1f}s)")1aplay output.wav # Linux
2afplay output.wav # macOS
3# or open output.wav in any audio editor, or in a notebook:
4# from IPython.display import Audio; Audio("output.wav")owensong/Inflect-Nano-v1. ONNX export contributed by
the jetson-tts edge-TTS project.