Build an App with Azure Speech in Foundry Tools
30-second answer
A lightweight speech app uses Azure Speech in Foundry Tools through the Speech SDK (pip package azure-cognitiveservices-speech). You create a SpeechConfig with your key and endpoint, then use a SpeechRecognizer to turn a WAV file or the microphone into text (speech to text), and a SpeechSynthesizer with a neural voice to turn text into audio (text to speech). SSML lets you control rate, pitch, pauses and speaking style.
Simulate it » No Azure account neededExam objective: 2.2.3 Build a lightweight application by using Azure Speech in Foundry Tools. (Skills measured as of April 15, 2026)
Simulations
Feel it before you read it. No account needed, nothing leaves this page.
Open <strong>Azure Speech</strong>, upload audio and <strong>transcribe</strong>. Diarization labels who spoke when.
👆 Click the glowing item in the portal to continue
Read the steps as text
- Open Azure Speech, upload audio and transcribe. Diarization labels who spoke when.
- Speech to text returns the words with timestamps (and translation if you ask for it).
- Now the other way: type text, pick a neural voice (Indian English here) and play it.
- SSML controls emphasis, pauses and speed. View code shows the Speech SDK calls.
🧪 Simulation for learning. Screens are simplified versions of the Azure portal; names, prices and IDs are examples. Nothing here touches real Azure.
🖱️ Drag to rotate · scroll or pinch to zoom
Text to speech
Speech synthesis turns text into natural speech with a neural voice. SSML lets you control speed, pitch and pauses. Think audiobooks, voice assistants and accessibility readers.
🤔 What happens if…
Read this tour as text
- Five workload lanes. Most AI apps fall into a few workloads: generative and agentic AI, text analysis, speech, computer vision and information extraction. Each lane here takes a different kind of input and turns it into something useful.
- Text analysis. A hotel review goes in. Azure Language returns the sentiment (positive, neutral, negative), key phrases, named entities (people, places, dates), PII and a short summary.
- Speech to text. Speech recognition turns spoken audio into text: live captions, call transcripts, voice commands. It can also translate speech into another language as you talk.
- Text to speech. Speech synthesis turns text into natural speech with a neural voice. SSML lets you control speed, pitch and pauses. Think audiobooks, voice assistants and accessibility readers.
- Computer vision. A photo goes in. Vision models return a caption, tags, objects with boxes, and any printed or handwritten text (OCR). A multimodal chat model can also answer questions about the picture.
- Image generation. Image-generation models work the other way round: a text prompt goes in and a brand-new image comes out. Guardrails block harmful requests, and generated images are marked with content credentials.
- Extract from documents. Azure Content Understanding reads an invoice and returns fields you defined (vendor, date, total) with a confidence score for each, so low-confidence values can go to a person.
- Extract from audio and video. The same service handles media: an audio call becomes a transcript with speakers and a summary; a video is split into segments with key frames, descriptions and chapters.
Transcribe a spoken question, answer it with a neural voice, then send the same audio straight to an audio-capable model.
🎓 Education-only simulation. Your lab is saved in this browser, so you can leave and continue later.
😟 THE PROBLEM
Your kiosk app needs to listen and talk back.
😊 THE SOLUTION
The Speech SDK for recognition and neural voices.
- Can’t hear users✓ SpeechRecognizer
- Can’t speak✓ SpeechSynthesizer
- Voice sounds rushed✓ SSML prosody
Start with a question
How does a railway announcement app know how to say 'platform 4' in a calm, clear voice?
Station announcements used to be recorded by a person, one clip per train. Change the platform and someone had to record it again.
Today an app can take the text “The 6:40 Chennai Express will arrive on platform 4” and speak it in a natural voice, in English or Hindi, slower for the platform number. And it can do the reverse too, turning a passenger’s spoken question into text. That’s Azure Speech.
Explain it like I’m 10
The technical explanation
Azure Speech in Foundry Tools is available on your Foundry resource (or a standalone Speech resource). Your app needs the key and endpoint, which you’ll find on the resource in the Azure portal or Foundry portal.
| Feature | What it does | SDK piece |
|---|---|---|
| Speech to text (real time) | Transcribes a file or live microphone | SpeechRecognizer |
| Fast and batch transcription | Transcribes long or many recordings | REST APIs |
| Text to speech | Speaks text with a neural voice | SpeechSynthesizer |
| SSML | Controls voice, rate, pitch, pauses, style | speak_ssml_async |
| Speech translation | Spoken input to translated text or speech | TranslationRecognizer |
| Speaker diarization | Labels who spoke when | Transcription options |
pip install azure-cognitiveservices-speech
export SPEECH_KEY="<key>"
export ENDPOINT="https://<resource-name>.cognitiveservices.azure.com/"
speech_app.py: speech to text
import os
import azure.cognitiveservices.speech as speechsdk
speech_config = speechsdk.SpeechConfig(subscription=os.environ["SPEECH_KEY"], endpoint=os.environ["ENDPOINT"])
speech_config.speech_recognition_language = "en-IN"
# From a file. Use AudioConfig(use_default_microphone=True) for the mic.
audio_config = speechsdk.audio.AudioConfig(filename="question.wav")
recognizer = speechsdk.SpeechRecognizer(speech_config=speech_config, audio_config=audio_config)
result = recognizer.recognize_once_async().get() # one utterance, up to about 30 seconds
if result.reason == speechsdk.ResultReason.RecognizedSpeech:
print("You said:", result.text)
elif result.reason == speechsdk.ResultReason.NoMatch:
print("No speech could be recognised.")
recognize_once stops at the first pause. For a long meeting recording, use continuous recognition (start_continuous_recognition with a recognized event handler) or batch transcription.
Text to speech with a neural voice
speech_config.speech_synthesis_voice_name = "en-IN-NeerjaNeural"
# Save to a file. Leave audio_config out to play on the default speaker.
file_out = speechsdk.audio.AudioOutputConfig(filename="answer.wav")
synthesizer = speechsdk.SpeechSynthesizer(speech_config=speech_config, audio_config=file_out)
result = synthesizer.speak_text_async("Your train will arrive on platform 4.").get()
if result.reason == speechsdk.ResultReason.SynthesizingAudioCompleted:
print("Saved answer.wav")
SSML for control
Plain text uses the voice’s defaults. SSML lets you slow a number down, add a pause, or pick a style that the voice supports.
ssml = """
<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis"
xmlns:mstts="https://www.w3.org/2001/mstts" xml:lang="en-US">
<voice name="en-US-AriaNeural">
<mstts:express-as style="customerservice">
Your booking is confirmed.<break time="500ms"/>
Your PNR is <prosody rate="-30%">4 5 2 1 9 8 7 6 3 0</prosody>.
</mstts:express-as>
</voice>
</speak>"""
synthesizer.speak_ssml_async(ssml).get()
Not every voice supports every style, so check the voice list in the Speech playground before you rely on one.
Architect level Custom speech and custom voice
Custom speech trains recognition on your own audio and text so it gets domain words right, like drug names or station names. Custom neural voice and personal voice create a voice that sounds like a specific person; those are limited access features with an application and consent requirements, because a cloned voice can be misused. That’s responsible AI showing up as product policy.
Real-world business scenario
Contoso Rail Services
- The problem
- Platform changes meant re-recording announcements by hand, and the help kiosk couldn't understand spoken questions from travellers.
- What they used
- A Python service with the Speech SDK: SpeechSynthesizer with en-IN and hi-IN neural voices and SSML to slow down train numbers, plus SpeechRecognizer on the kiosk microphone.
- Why that choice
- Neural voices sound natural in both languages, SSML makes numbers clear on noisy platforms, and the same SDK handles listening and speaking.
- The result
- Announcements update the moment the timetable changes, and kiosk users can simply ask 'Which platform for Madurai?'.
When to use it and when not to
✓ Use it when…
- You need transcripts of calls, meetings or voice notes.
- Your app must speak with a natural voice, in a chosen language and style.
- You need fine control of pronunciation, pauses and speed through SSML.
✕ Think twice when…
- You only want a model to answer a spoken question. An audio-capable multimodal model may be one step simpler.
- Cloning a real person's voice without the limited-access approval and their consent.
↔ Alternatives to consider
- An audio-capable multimodal model that takes input_audio directly.
- Content Understanding for transcripts plus summaries of recorded calls.
- Voice Live API for live voice agents.
Test yourself with exercises
5 original practice questions in the AI-901 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.
Interview preparation
Say your answer out loud first, then open the model answer. Interviewers care more about your reasoning than the exact words.
Beginner What are the two main things Azure Speech does?
Model answer
Speech to text, which turns spoken audio into a transcript, and text to speech, which reads text aloud in a natural neural voice. It also does speech translation and a few more advanced features.
Interviewer follows up
Which Python package do you install?
You
azure-cognitiveservices-speech, imported as azure.cognitiveservices.speech, usually aliased to speechsdk.
Intermediate Your recognize_once call only captures the first sentence of a five-minute recording. Why?
Model answer
recognize_once stops at the first pause and handles about 30 seconds at most. For longer audio I'd use continuous recognition with start_continuous_recognition and handle the recognized events, or batch transcription for big files.
Experienced developer When do you use SSML instead of plain text for synthesis?
Model answer
When the defaults don't sound right: slowing down a long account number, adding a pause before a key instruction, changing pitch, using a speaking style like cheerful or customer service, or switching voices mid-paragraph. Plain text is fine for short, simple replies.
Scenario A hospital kiosk must read discharge instructions in English and Hindi. How would you build it?
Model answer
Use the Speech SDK's SpeechSynthesizer with a neural voice for each language, for example an en-IN voice and hi-IN-SwaraNeural, with SSML to slow the rate for medication names. I'd keep the text reviewed by staff, since the voice reads exactly what it's given.
Quick revision
Key points
- pip install azure-cognitiveservices-speech; import azure.cognitiveservices.speech as speechsdk.
- SpeechConfig holds the key and endpoint, plus speech_recognition_language and speech_synthesis_voice_name.
- SpeechRecognizer + AudioConfig(filename=...) or use_default_microphone=True gives speech to text.
- SpeechSynthesizer.speak_text_async(text).get() reads text in the chosen neural voice.
- speak_ssml_async takes SSML to control rate, pitch, pauses and style.
Important terminology
- Azure Speech in Foundry Tools
- The Foundry Tools service (formerly Azure AI Speech) for speech to text, text to speech, translation and voice features.
- SpeechConfig
- The Speech SDK object that holds your key, endpoint, recognition language and synthesis voice.
- SpeechRecognizer
- The Speech SDK class that converts audio from a file or microphone into text.
- SpeechSynthesizer
- The Speech SDK class that converts text or SSML into spoken audio.
- Neural voice
- A natural-sounding prebuilt voice such as en-US-AvaMultilingualNeural or en-IN-NeerjaNeural.
- SSML
- Speech Synthesis Markup Language, an XML format for controlling voice, rate, pitch, pauses and style.
Common mistakes
- Using recognize_once for long recordings. It stops after one utterance (about 30 seconds max).
- Forgetting to check result.reason, so silent failures look like empty text.
Exam tips
- "Read text aloud in a natural voice" = text to speech with a neural voice.
- "Make the voice pause or slow down" = SSML.
- "Transcribe a recording" = speech to text with SpeechRecognizer.
Five quick revision questions
-
1.Which class turns audio into text?Show
SpeechRecognizer
-
2.Which class turns text into audio?Show
SpeechSynthesizer
-
3.Which property chooses the voice?Show
speech_config.speech_synthesis_voice_name
-
4.What markup controls pauses and speaking rate?Show
SSML (Speech Synthesis Markup Language).
-
5.What should you use instead of recognize_once for long audio?Show
Continuous recognition (or batch transcription).
Official references
Finished this lesson? Tick it off. Your progress is saved in this browser.
Next up: Use Images in Prompts with a Multimodal Model
Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges.