Lesson 1 of 3 Speech Solutions for Agents

Adding Speech to Text and Text to Speech to Agents

This lesson explains the Azure Speech recognition modes and neural voices, the LLM-based transcription of audio models, and how they fit agentic interactions such as voice assistants.

Learning outcomes

After completing this lesson, you will be able to:

  • Choose a speech to text option from input and latency requirements.
  • Control text to speech with neural voices and SSML.
  • Keep a chained voice agent responsive.

Recognition modes

Azure Speech is the Foundry Tool for spoken language. It provides speech to text (recognition), text to speech (synthesis) and speech translation, and it is reached through the Foundry resource with Microsoft Entra ID authentication, like the other Foundry Tools. Audio models deployed from Foundry Models add a second route to transcription, in which a generative model converts audio to text.

Speech recognition, also called speech to text or transcription, converts spoken audio into written text. A recognition mode is the way the audio is submitted and the results are returned. The right mode depends on where the audio comes from and how soon the text is needed, and Azure Speech offers three.

Real-time recognition with the Speech SDK processes a live stream from a microphone or a call and returns interim results as the person speaks, which a voice assistant or live captioning needs.

The fast transcription API takes a recorded file and returns the complete transcript synchronously, faster than the recording's duration, which suits a voice note or a call that has just ended.

Batch transcription processes many files from storage asynchronously and returns results later, which suits archives and overnight processing where cost and throughput matter more than speed.

Transcription models such as gpt-4o-mini-transcribe are called through the audio API on the v1 endpoint. They are accurate on difficult audio and can follow a prompt that lists expected terms, but they do not offer every feature of Azure Speech, so the requirements for diarization, timestamps or custom models decide between them. The following table compares the speech to text options.

OptionInputLatencyTypical use
Real-time recognition (Speech SDK)Microphone or audio streamImmediate, with interim resultsVoice assistants, live captions
Fast transcription APIAudio fileFaster than real time, synchronousRecorded calls or voice notes needing quick results
Batch transcriptionMany files in storageAsynchronousLarge archives, overnight processing
Transcription models (for example gpt-4o-mini-transcribe)Audio file or streamFastLLM-based accuracy through the audio API

Features include automatic punctuation, diarization (which speaker said what), word-level timestamps, profanity filtering, language identification and phrase lists that boost recognition of specific words at runtime.

The Speech to Text playground lists the recognition modes, as the following screenshot shows: real-time transcription for streaming microphone input, fast transcription for a single file, LLM speech for audio enhanced with an LLM, and batch transcription for many files, with options such as language identification, speaker diarization and a phrase list.

Speech to Text playground with the modes Real-time, Fast, LLM Speech and Batch transcription
Batch transcription suits large volumes; fast transcription returns one file's transcript quickly.
Sort into groups

Real-time or batch?

Exam skills 4.2.1

Choose the speech-to-text option for live audio and for large archives.

Log in to try this activity Interactive activities are free with an account.

Text to speech

Text to speech uses neural voices, including high-definition voices with more natural prosody, in many languages. Speech Synthesis Markup Language (SSML) controls voice selection, pronunciation (phonemes and custom lexicons), pauses, rate, pitch, emphasis and speaking styles. Output formats range from compressed streams for telephony to high-quality audio files.

import azure.cognitiveservices.speech as speechsdk
# Entra ID: authorization token "aad#<resource ID>#<access token>" with a custom-subdomain Foundry resource
token = f"aad#{resource_id}#{cred.get_token('https://cognitiveservices.azure.com/.default').token}"
config = speechsdk.SpeechConfig(auth_token=token, region=region)
config.speech_synthesis_voice_name = "en-US-AvaMultilingualNeural"
synth = speechsdk.SpeechSynthesizer(speech_config=config,
                                    audio_config=speechsdk.audio.AudioOutputConfig(filename="reply.wav"))
synth.speak_ssml_async('''<speak version="1.0" xml:lang="en-US"><voice name="en-US-AvaMultilingualNeural">
  Your order <say-as interpret-as="characters">ORD</say-as> 104233 has shipped.<break time="300ms"/>
  It will arrive on Friday.</voice></speak>''').get()
True or false

Speak clearly

Exam skills 4.2.1

Check four facts about text to speech and voice replies.

Log in to try this activity Interactive activities are free with an account.

Speech in agentic interactions

A simple voice agent chains recognition, the agent call and synthesis. To keep it responsive, the recognizer streams interim results, the agent's response is streamed and synthesized sentence by sentence, and replies are kept short because listeners cannot skim. The agent's instructions are adjusted for voice: no tables or links, numbers spoken clearly, and confirmation of critical details such as amounts and dates. For low-latency, interruptible conversations, the Voice Live API replaces the chain.

Worked example

Choosing a recognition mode

A clinic records 2,000 patient phone calls a day. Each call must be transcribed with speaker labels within a few minutes of ending so that a summary is ready for the nurse's follow-up.

The calls are recorded files that need quick results with diarization, so the fast transcription API fits. Real-time recognition is for live streams, and batch transcription is asynchronous and suited to processing that can wait.

Check yourself

Which recognition mode suits recorded files that need results quickly?

Show answer

Fast transcription. Live audio uses real-time recognition, and large archives use batch transcription.

Exam Tips

Remember for the exam

  • Live audio: real-time recognition. Recorded files needing quick results: fast transcription. Archives: batch.
  • SSML controls pronunciation, pauses, rate and style.
  • Adapt agent replies for voice: short, no tables, confirm critical details.