Your profile

One profile for every MSDEVBUILD site. Only you can see it, and the site owner if you write in.

Lesson 33 of 39
❮Prev Next❯

Speech to Text and Text to Speech for Agents

Module 4: Text & Speech ⏱ 10 min read Updated

Your note

My notes for this lesson

Select any text in the lesson to highlight it or add a note. Saved in this browser.

    No highlights yet. Select a sentence in the lesson, then pick a colour or add a note.

    All my bookmarks and notes

    Reading settings

    For every lesson, saved in this browser.

    Text size
    Line spacing
    Font

    With IaaS you rent the virtual machine. Microsoft looks after the building, power and hardware; you patch the operating system.

    30-second answer

    A voice agent is a loop you can swap piece by piece: speech to text turns the caller into words, the model or agent answers, and text to speech with a neural voice speaks the reply. SSML controls pauses, rate and pitch. When domain words come out wrong, try a phrase list first (no training). For many terms, accents or noisy lines, train a custom speech model and use its endpoint ID. For a live phone agent, Voice Live runs speech in, the model or agent, and speech out over one low-latency connection with noise suppression and turn detection built in.

    Simulate it » No Azure account needed

    Exam objective: 4.2.1 Implement workflows to convert speech to text and text to speech for agentic interactions. 4.2.2 Integrate speech as an agent modality, including custom speech models. (Skills measured as of April 16, 2026)

    Simulations

    Feel it before you read it. No account needed, nothing leaves this page.

    Azure portal: Speech in and out for an agent: transcribe, customise, speak, Voice Live Transcribe, customise speech, speak with SSML and start Voice Live.
    </> Embed

    Embed this simulation

    Free for trainers, teachers and bloggers. Paste this into your page:

    Loading the portal…

    Open <strong>Foundry Tools → Azure Speech</strong>. Speech is how an agent hears and talks.

    👆 Click the glowing item in the portal to continue

    Read the steps as text
    1. Open Foundry Tools → Azure Speech. Speech is how an agent hears and talks.
    2. Transcribe a pharmacy call. The base model trips on Metformin and Atorvastatin, and the agent would act on the wrong words.
    3. In Custom speech, upload related text or labelled audio, train, test, then deploy an endpoint.
    4. In code, set endpoint_id to use the custom model, or add a PhraseListGrammar to boost a handful of words.
    5. The reply goes out through text to speech. SSML adds a pause and slows the time so callers catch it.
    6. For a live phone agent, Voice Live runs speech in, the model or agent, and speech out over one low-latency connection, with noise suppression and turn detection built in.

    🧪 Simulation for learning. Screens are simplified versions of the Azure portal; names, prices and IDs are examples. Nothing here touches real Azure.

    😟 THE PROBLEM

    The phone agent mishears drug names and sounds like a robot reading numbers.

    😊 THE SOLUTION

    Use a phrase list or custom speech for the vocabulary and SSML for the delivery.

    • A few words misheard✓ A phrase list
    • Many terms, accents or noisy lines✓ A custom speech model and endpoint ID
    • Flat, rushed replies✓ SSML with breaks and prosody
    • Slow, stitched-together voice loop✓ Voice Live
    🛠️ Solved with: Azure Speech

    Start with a question

    What happens if the pharmacy agent hears 'met for men' instead of Metformin?

    Contoso Pharmacy wants a phone agent. A caller says, “I need a refill of Metformin 500.” The speech model hears “met for men 500”. The agent looks for a drug that doesn’t exist, apologises, and the caller hangs up.

    Nothing is wrong with the agent’s brain. The mistake happened one step earlier, at the ears, and every later step inherited it. A voice agent is only as good as its speech in and speech out.

    Explain it like I’m 10

    The technical explanation

    The voice loop

    1. Speech to text (Azure Speech): real-time recognition of the caller’s audio.
    2. Model or agent: reads the text and answers.
    3. Text to speech: a neural voice such as en-IN-NeerjaNeural speaks the answer.
    import azure.cognitiveservices.speech as speechsdk
    
    cfg = speechsdk.SpeechConfig(subscription=KEY, endpoint=ENDPOINT)
    cfg.speech_synthesis_voice_name = "en-IN-NeerjaNeural"
    recognizer = speechsdk.SpeechRecognizer(cfg, speechsdk.audio.AudioConfig(filename="question.wav"))
    heard = recognizer.recognize_once().text
    reply = ask_agent(heard)
    speechsdk.SpeechSynthesizer(cfg).speak_text_async(reply).get()

    Domain words: phrase list or custom speech

    Phrase listCustom speech
    Best forA handful of names and termsMany terms, accents, noisy lines, industry vocabulary
    Data neededNoneRelated text and/or audio with human-labelled transcripts
    TrainingNoneTrain, test, deploy an endpoint
    In codePhraseListGrammar.addPhrase("Metformin")cfg.endpoint_id = "<custom endpoint ID>"

    Start with the phrase list. Move to custom speech when the list stops helping.

    Shape the voice with SSML

    Plain text uses the voice’s defaults. SSML is XML that controls the delivery:

    <speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xml:lang="en-IN">
      <voice name="en-IN-NeerjaNeural">
        Your Metformin is ready <break time="300ms"/>
        <prosody rate="-10%">after 5 PM.</prosody>
      </voice>
    </speak>

    Use <break> for pauses, <prosody> for rate and pitch, and the voice’s style options where supported. SSML changes how the answer sounds. It never fixes what was heard.

    Voice Live for live agents

    Stitching three calls together adds delay and makes interruptions awkward. Voice Live exposes a single real-time connection: audio goes in, a model (such as gpt-4.1-mini) or a Foundry agent answers, and audio comes back out. It includes noise suppression, echo cancellation and end-of-utterance (turn) detection. Choose it for phone agents, kiosks and anywhere a pause of a second feels wrong.

    Architect level Why recognition errors travel so far

    An agent has no ears of its own. It only sees the transcript. If the transcript is wrong, the agent can be completely confident and completely wrong. That’s why teams measure word error rate on their own recordings, test the hard vocabulary first, and keep a confirmation step (“Did you say Metformin 500?”) for actions that matter, like refills or payments.

    Real-world business scenario

    Healthcare retail

    Contoso Pharmacy (fictional)

    The problem
    Refill calls overloaded the counter after 5 PM, and a trial voice bot misheard drug names and sounded rushed when it read pickup times.
    What they used
    Azure Speech with a phrase list for the 40 most common drug names, a custom speech model trained on labelled call audio for the full catalogue, SSML replies with a pause before the time, and Voice Live in front of a Foundry agent.
    Why that choice
    The phrase list was the quick fix during the pilot. Custom speech handled the long tail and local accents. SSML made times easy to catch, and Voice Live cut the lag between turns.
    The result
    Most refill calls were completed without staff, and the team added a spoken confirmation for the drug and strength.

    When to use it and when not to

    ✓ Use it when…

    • An agent must talk to people on a phone, kiosk or smart speaker.
    • Domain names are misrecognised (phrase list first, then custom speech).
    • Replies include times, numbers or codes that need careful delivery (SSML).

    ✕ Think twice when…

    • You train custom speech to fix two words.
    • You expect SSML to correct what the recogniser heard.
    • You act on a spoken request that costs money or health without a confirmation.

    ↔ Alternatives to consider

    • Voice Live for natural, low-latency live conversations.
    • Batch transcription for recorded calls you process later.
    • A text chat agent when speech adds nothing for the user.
    Ready for more?The full lesson adds the technical explanation, when to use it, interview questions and revision notes.

    Test yourself with exercises

    5 original practice questions in the AI-103 style. Pick your answers, then check them. You will see why each option is right or wrong. Score 75% or more and this topic is marked complete.

    Question 1

    Question 1 of 5

    A pharmacy phone agent mishears two drug names, but only these two words fail. You need the fastest fix with no data collection or training. What should you do?

    Question 2

    Question 2 of 5

    A call center has 3,000 product terms, regional accents and noisy lines. A phrase list does not improve recognition enough. What should you do?

    Question 3

    Question 3 of 5

    Spoken replies from an agent read a time too fast: "your order is ready at five" is spoken in one breath. You must add a short pause and slow only the time. Which technique should you use?

    Question 4

    Question 4 of 5

    You build a voice agent. The caller speaks, the agent answers and the reply is spoken. Which sequence describes one turn?

    Question 5

    Question 5 of 5

    A phone agent needs low-latency speech in and speech out, noise suppression and turn detection, over a single connection with a model or an agent. Which feature should you use?

    Interview preparation

    Say your answer out loud first, then open the model answer. Interviewers care more about your reasoning than the exact words.

    Beginner How does a voice agent work?

    Model answer

    Speech to text turns what the caller says into text. The model or agent reads it and writes an answer. Text to speech turns the answer into audio and plays it back. Each of the three pieces can be swapped on its own.

    Intermediate Speech recognition keeps mishearing two drug names. What do you try?

    Model answer

    A phrase list with those two names. It needs no data and no training, and it boosts those words. If it's hundreds of terms or the audio is noisy, I'd train custom speech on related text or labelled audio.

    Experienced developer When do you move from the Speech SDK loop to Voice Live?

    Model answer

    When latency and natural turn-taking matter, like a phone line. Voice Live handles speech in, the model or agent and speech out over one connection, with noise suppression, echo cancellation and end-of-turn detection, so I'm not stitching three calls together and handling interruptions myself.

    Scenario Callers say the agent sounds rushed when it reads times and codes. What do you change?

    Model answer

    I'd send the reply as SSML instead of plain text: a break before the time, a slightly slower prosody rate for it, and say-as for codes. The words don't change, only the delivery.

    Quick revision

    Key points

    • One voice turn is speech to text, model or agent, text to speech.
    • Phrase list is the quick, no-training fix. Custom speech is for many terms, accents or noise.
    • A custom speech model is used by setting its endpoint ID in the SpeechConfig.
    • SSML controls pauses, rate, pitch and style of the spoken reply.
    • Voice Live is the low-latency speech to speech option for live agents.

    Important terminology

    Speech to text
    Azure Speech converting spoken audio into text, in real time or in batch.
    Text to speech
    Azure Speech turning text into spoken audio with a neural voice.
    SSML
    Speech Synthesis Markup Language. XML that sets the voice, pauses, rate, pitch and style of synthesized speech.
    Phrase list
    A short list of words and phrases that biases recognition toward them. No training required.
    Custom speech
    A speech recognition model trained on your text or labelled audio and called through a custom endpoint ID.
    Voice Live
    A real-time speech to speech interface for models and agents, with noise suppression, echo cancellation and end-of-turn detection.

    Common mistakes

    • Training custom speech for two misheard words.
    • Using SSML and expecting it to fix recognition errors. It only shapes output.
    • Stitching three slow calls together for a live phone line.

    Exam tips

    • "A few words misheard, no training" = phrase list.
    • "Industry vocabulary, accents, noise" = custom speech.
    • "Add a pause and slow the rate" = SSML.

    Five quick revision questions

    1. 1.What does SSML change?Show

      How synthesized speech is delivered (pauses, rate, pitch, style).

    2. 2.What do you set to use a custom speech model?Show

      Its endpoint ID.

    3. 3.What does Voice Live combine?Show

      Speech in, the model or agent, and speech out on one connection.

    4. 4.Which fix needs no training for a few words?Show

      A phrase list.

    5. 5.What turns the agent reply into spoken audio?Show

      Text to speech with a neural voice.

    Official references

    Finished this lesson? Tick it off. Your progress is saved in this browser.

    Next up: Speech Translation and Reasoning over Audio

    Studying with a friend? Send them this lesson

    It's free and needs no sign-up. Their progress saves in their own browser.

    Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges. Play ❯

    Install MSDEVBUILD Azure

    Free · no account · works offline

    Save the whole course for offline ›

    Hi, I’m your Nimbus

    Your study buddy. Pick what we do next.

    MSDEVBUILD · Multi-Stack Dev Build

    Sign in to MSDEVBUILD

    One account for Azure certifications and the blog: sign in here and you are signed in on both. Your XP, streak, practice deck and certificate stay in sync on every device. Optional: everything works without an account.