0
Phase 15

TTS

~2 min read

Concept & How It Works

    Why Does It Exist?

    Reading agent responses on screen isn't always possible or desirable. TTS enables phone agents, accessibility features, and conversational experiences that feel human.

    Real-World Analogy

    TTS is an audiobook narrator — it reads written text aloud with appropriate pacing, emphasis, and tone.
    Loading diagram...

    Visual Workflows

    What is TTS?

    Loading diagram...

    Example

    Scenario

    Agent generates answer text → TTS converts to audio stream → played through phone system IVR. Voice: 'professional female, en-US'.

    Solution

    In Voice & Multimodal Agents, apply TTS to this scenario: Agent generates answer text → TTS converts to audio stream → played through phone system IVR. Identify the inputs, run the technique, validate the output, and note one thing you would monitor in production.

    Practice Task

    Do this before moving to the next module — reading alone is not enough.

    Open the Code Walkthrough below and run it locally. Change one parameter related to TTS (e.g. model, temperature, top_k, or tool name), observe the difference in output, and write 2–3 sentences explaining what changed.

    Code Walkthrough

    Highlighted lines show where TTS happens in the code.

    TTS
    1from openai import OpenAI  # import dependencies2
    3client = OpenAI()  # create API client4
    5def speak(text: str, output_path: str = "response.mp3") -> str:  # define a reusable function6    response = client.audio.speech.create(  # call the API7        model="tts-1",8        voice="nova",9        input=text,10    )11    response.stream_to_file(output_path)12    return output_path  # return the result

    Commands to Remember

    Commands to Remember

    • pip install openai # vision, audio, and TTS APIs
    • pip install pypdf # PDF ingestion for document agents

    Common Mistakes

    • Treating TTS as a black box without evaluation
    • Ignoring cost and latency in production
    • Skipping error handling for tts

    Cheat Sheet

    Quick recap — the most important points from this module.

    Cheat Sheet

    quick ref
    • TTS
    • Neural TTS
    • SSML
    • Voice ID