Reference and cloned-output wav files are small (~2MB each) and are the actual evidence of the voice-clone+translate demo working, so track them despite the general *.wav exclusion. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Y1oQ4h4WE4R9KRvMQLr5Ey
tts
Text-to-speech service demos and proofs-of-concept.
Voice-clone + translate demo (MOSS-TTS)
clone_and_translate_demo.py translates a short English sentence spoken by the narrator in
our sample clip to Spanish (via Helsinki-NLP/opus-mt-en-es), then uses
MOSS-TTS to synthesize the Spanish text in the
narrator's cloned voice. The reference audio (reference/narrator_ref_en.wav) is trimmed
from demucs's isolated vocals stem for the exact same sentence, so the English original and
the Spanish clone can be compared directly — this is the first working slice of the full
audio-translation pipeline sketched in the top-level README.
Setup
MOSS-TTS ships as a full repo you install editable (not a plain pip install), and it isn't
part of this git repo — it's vendored outside it since it's a large third-party project:
git clone --depth 1 https://github.com/OpenMOSS/MOSS-TTS.git /path/to/vendor/MOSS-TTS
python3 -m venv .venv && . .venv/bin/activate
pip install --extra-index-url https://download.pytorch.org/whl/cu128 \
-e "/path/to/vendor/MOSS-TTS[torch-runtime]"
pip install sentencepiece # for the MarianMT translation step
Running
SITE=$(python3 -c "import site; print(site.getsitepackages()[0])")
export LD_LIBRARY_PATH=$(find "$SITE/nvidia" -maxdepth 2 -type d -name lib | paste -sd: -)
python3 clone_and_translate_demo.py
Output goes to output/narrator_cloned_es.wav (48kHz stereo, ~11s).
Gotchas found running this on an RTX 3090
- The flagship 8B
MOSS-TTS-v1.5checkpoint OOMs on a 24GB 3090 — loading the model plus its audio tokenizer already uses ~22.5GB, leaving no room for generation. Use the 4BMOSS-TTS-Local-Transformer-v1.5checkpoint instead (also natively 48kHz stereo); it's the option the project itself recommends for smaller GPUs. torchaudio.load()/.save()fail withCould not load libtorchcodecon this setup. The real cause (visible viactypes.CDLLdirectly, not the wrapped exception) is a missinglibnppicc.so.12— torchcodec links against NVIDIA's NPP library for its video-decode path, butmoss-tts's dependencies don't pull it in since MOSS-TTS only needs audio. Fix:pip install nvidia-npp-cu12, then add allnvidia/*/libwheel directories toLD_LIBRARY_PATHbefore running (see theSITE=...line above) — the pip-installed CUDA libraries aren't on the default linker search path. This also affects code paths inside MOSS-TTS's own processor (it usestorchaudio.load()to read reference audio), so the fix has to be in place before the script imports it, not just around your own save calls.- Saving the generated audio with plain
soundfile.write()instead oftorchaudio.save()avoids depending on torchcodec at all for the output side, but doesn't help with the reference-audio loading path above.