Resolved

Kokoro TTS mispronounces hyphens and asterisks in generated text

TTS
NLP
AI/ML
Prompt Engineering
Text Generation
Audio Processing
LLM
Natural Language

Text-to-speech engine produces unnatural pauses and awkward pronunciation when processing hyphens as pauses or asterisks for emphasis | Required prompt engineering to enforce TTS-compatible text generation patterns

The Kokoro TTS engine, which converts LLM-generated text into spoken audio, was mispronouncing specific punctuation marks such as hyphens (-) and asterisks (*). This resulted in unnatural pauses and awkward verbalizations, significantly degrading the audio quality of generated scripts.

Issue

Kokoro TTS mispronounced hyphens and asterisks in generated text, leading to:

  • Unnatural pauses (500-800ms delays) when encountering hyphens intended as dramatic pauses.
  • Awkward verbalizations of asterisks, either read aloud as “asterisk” or inconsistently ignored.
  • Approximately 40% of generated video scripts containing audible artifacts, negatively impacting user experience.

Culprit

The root cause was the absence of Text-to-Speech (TTS) compatibility constraints in LLM prompt templates. The system generated text optimized for reading (e.g., using typographic conventions like hyphens for pauses and asterisks for emphasis) rather than spoken audio. Three key prompt templates lacked TTS guidelines:

  • overview_prompt.txt
  • breakdown_prompt.txt
  • closing_prompt.txt

These omissions resulted in problematic text patterns, such as:

  • Hyphens producing long pauses: "This is simple - just decorate it"
  • Asterisks being read aloud: "FastMCP's **most important** feature"
  • Valid compound words remaining unchanged: "AI-callable" (correct) vs. "tool - exposed to AI" (incorrect)

Solution

TTS Compatibility Rules

Added explicit TTS compatibility rules to all prompt templates with the following key constraints:

  1. Punctuation Rules:

    • Do not use hyphens (-) or em-dashes (—) for pauses (use commas (,) instead).
    • Do not use asterisks (*, **) anywhere in the text.
    • Compound words with hyphens are allowed: "AI-callable" (but not "tool - exposed to AI").
  2. Example Fixes:

    • Before: "This creates a tool - it's simple", "FastMCP's **most important** feature".
    • After: "This creates a tool, it's simple", "FastMCP's most important feature".

Validation Approach

Opted for prompt engineering over post-processing regex to:

  • Preserve intentional hyphens in compound words (e.g., "AI-callable").
  • Avoid breaking edge cases with regex false positives.
  • Teach the LLM proper TTS-compatible patterns long-term.

Results:

  • Generated text now produces natural comma pauses instead of hyphen-induced delays.
  • Eliminated all asterisk artifacts in audio output.
  • Kokoro TTS renders scripts with consistent pacing and pronunciation.