--- name: text-to-speech description: "Use when creating TTS audio. Prepare, synthesize, verify." metadata: hermes: tags: [tts, speech, pronunciation, audio, text-normalization] related_skills: [test-driven-development] license: MIT author: HamaratLabs version: 1.0.0 --- # Text-to-speech production Use this workflow for spoken narration, voice notes, and generated speech. Keep pronunciation preparation independent from the selected synthesis model so the voice backend can change without losing terminology and tone preferences. ## When to Use Use when creating speech from text, changing a voice/model, correcting pronunciation, or verifying generated audio. ## Procedure 1. **Resolve the brief.** Confirm the final spoken text, language, requested voice/tone, speaking speed, output format and destination. Do not invent pronunciations for ambiguous names or acronyms; ask or mark the uncertainty. Use a per-format speed if the user has one (e.g. 1.2× for a daily news narration); otherwise follow the requested speed or the backend default. 2. **Create a speech-only copy.** Preserve the source script and on-screen captions. Remove only material not meant to be spoken (for example, source URLs or markup), and keep the visual text unchanged when phonetic spelling is needed only for TTS. 3. **Normalize pronunciations before synthesis.** For acronyms, names and abbreviations the voice may misread, use a pronunciation lexicon, backend-supported phoneme/SSML override, or phonetic spelling. Verify that the chosen backend actually supports phoneme/SSML controls; otherwise use explicit spoken-form text. Example for Turkish speech with English letter names: `OCR` → `o si ar` in the speech copy. Use whole-token matching with deliberate case and boundary behavior; never globally replace a letter sequence inside other words. 4. **Test lexicon changes first.** Add a failing regression test for the exact spoken-form transformation, capitalization variants and word boundaries; then implement the smallest change and rerun the tests. Also verify the production entry point applies the normalizer—a correct helper can still be bypassed by its caller. Keep a small pronunciation sample set when changing models. 5. **Choose and run the backend.** Keep the terminology lexicon separate from model-specific voice settings. Use the requested voice/tone and speed explicitly when supported. For a new voice or backend, synthesize a short sample containing the difficult terms before producing the full narration. 6. **Verify the result.** Confirm the expected output path exists, is non-empty, has plausible duration and is not silent/clipped; inspect backend diagnostics. Listen to the sample when playback is available, and say plainly if audio was not auditioned. Never infer correct spoken pronunciation from text preprocessing alone. **For a multi-language claim specifically** ("does this backend actually speak language X", not just "does the UI offer language X as a menu option"), a model card's claimed language list is not verification — generate a short sample in the target language, transcribe it back with an INDEPENDENT ASR model (e.g. local Whisper, language auto-detect, not forced) and confirm both the detected language and the transcript content match the input text. A silently wrong sample rate on write (hardcoding 16000/44100 instead of reading the model's own rate, e.g. `model.tts_model.sample_rate`) produces a sped-up/slowed-down WAV that an ASR model will transcribe as empty or garbage — if a round-trip check comes back empty, suspect the WAV's sample-rate header before suspecting the TTS model's language quality. 7. **Deliver safely.** Return the verified audio file and a concise note about format, duration and any limitation. Do not upload or publish it externally unless the user explicitly requests that action. ## Reusable backend notes For standalone VoxCPM2 Python/Gradio setup and real speech verification, read [`references/voxcpm-standalone.md`](references/voxcpm-standalone.md). A typical setup has TWO separate local backends for different jobs — do not assume either one is "the" local TTS method without checking which capability the task actually needs: - **EMA Lightning** — quick Turkish-only narration, tiny (8.6M params), fast (real-time-or-better even on CPU), no voice cloning (single fixed voice, only a speed knob). Setup, pronunciation helper, and regression test: [`references/local-ema-backend.md`](references/local-ema-backend.md). - **VoxCPM2** — real voice cloning (reference-clip-based), 30 languages, much heavier and slower than real-time. Use it for consented voice clones. Full setup, API, hardware reality, and license-separation notes: [`references/voxcpm2-cloning-backend.md`](references/voxcpm2-cloning-backend.md). When asked "how did we do X locally" and a nearby project folder suggests one tool, verify the tool's actual API/capability (does it expose cloning? what reference-audio parameter does it take?) before building advice or a build brief on top of the assumption — a folder-name or prior-session guess can point at the wrong backend entirely.