MossTTSEngine wraps MOSS-TTS-Nano ONNX and torch runtimes. The source keeps
the Realtime variant behind a clear error until a bounded local smoke exists.
Install RealtimeTTS with the MOSS extra. The extra includes the shared PyPI-resolvable runtime dependencies RealtimeTTS can declare, but MOSS-TTS-Nano itself, local model/runtime assets, and CUDA choices still need deliberate setup.
pip install "realtimetts[moss]"If you keep a local MOSS-TTS-Nano checkout, installing it editable remains a good development workflow:
pip install -e third_party/MOSS-TTS-NanoChoose one runtime path:
- ONNX: install the MOSS ONNX runtime dependencies and
onnxruntimeoronnxruntime-gpu. - Torch: install the MOSS torch runtime dependencies and a compatible PyTorch and torchaudio build.
from RealtimeTTS import TextToAudioStream, MossTTSEngine, MossTTSVoice
if __name__ == "__main__":
voice = MossTTSVoice(
name="demo",
prompt_audio_path="reference.wav",
prompt_text="Exact transcript of the reference audio.",
)
engine = MossTTSEngine(voice=voice, backend="onnx", execution_provider="cpu")
stream = TextToAudioStream(engine)
stream.feed("Hello from MOSS TTS.")
stream.play()
engine.shutdown()- Supported source variant is
variant="nano"withbackend="onnx"orbackend="torch". variant="realtime"orbackend="realtime"currently raises an import error.- Defaults target
OpenMOSS-Team/MOSS-TTS-NanoandOpenMOSS-Team/MOSS-Audio-Tokenizer-Nano. - Default audio is 48000 Hz stereo;
get_stream_info()returns channel count from the loaded runtime metadata. - ONNX CUDA on Windows checks
MOSS_CUDA_DLL_DIRS,ORT_CUDA_DLL_DIRS,CUDA_PATH,CUDA_HOME, andCUDNN_PATH, then tries common NVIDIA install directories andonnxruntime.preload_dlls. - The wrapper writes temporary runtime output under
test_outputs/moss_tts_internalby default.
- MOSS-TTS-Nano package metadata observed Python
>=3.10,torch==2.7.0,torchaudio==2.7.0,transformers==4.57.1, andonnxruntime>=1.20.0. - Working Nano venv used
torch==2.7.0+cu128,torchaudio==2.7.0+cu128, andonnxruntime-gpu. soundfilewas needed because the first Nano smoke had no workingtorchaudio.load()backend for the reference WAV.- NLTK
punktandpunkt_tabwere installed locally for sentence splitting. - Torch Nano rejects
prompt_textinvoice_clone; the wrapper records transcript data for reproducibility but does not pass it to that torch path. - ONNX CPU, ONNX CUDA, and Torch CUDA smokes all produced valid files in the dev-log, but ONNX CUDA had instability and Torch CUDA had slower-than-realtime RTF despite good TTFA.
- The MOSS-TTS-Realtime probe used
torch==2.9.1+cu128,torchaudio==2.9.1+cu128, andtorchcodec==0.8.1, but full smoke attempts timed out or hit torchcodec/FFmpeg DLL issues.
- For ONNX CUDA on Windows, set
CUDNN_PATHor the explicit DLL directory env vars if CUDA/cuDNN DLLs are not found. - If Realtime variant is requested, switch back to
variant="nano"until the Realtime path is implemented and locally validated.