← Develop AI Apps and Agents o… Latent Shelf · Ch.19

Module Study Guide · Path 3 · Natural language

Create Speech-Enabled Apps with Azure Speech in Foundry Tools

The dedicated Speech SDK trades the generative model's flexibility for precise control — a config object, a recognizer or synthesizer, and a result you can inspect.

— the module's model

The purpose-built speech service. This module covers Azure Speech and its SpeechConfig, the speech-to-text and text-to-speech APIs and their shared four-step pattern, audio formats and voices, and SSML for fine control over synthesized output.

SpeechConfigSTT & TTSvoices & formats15 quiz questions
01The service

Azure Speech and SpeechConfig

Azure Speech in Foundry Tools is a set of speech capabilities reached through a Foundry resource — speech-to-text (transcribe calls, meetings, audio) and text-to-speech (read messages or emails aloud). You authenticate with the resource endpoint and key, via REST or a language SDK.

Key concept · SpeechConfig is the foundation

Every operation begins with a SpeechConfig object encapsulating the connection details (subscription key + endpoint). Python SDK 1.48.2 and later accept the Foundry resource endpoint directly; earlier versions needed a region instead. SDKs exist for Python, C#, JavaScript, and more (pip install azure-cognitiveservices-speech).

02STT & TTS

One pattern, two directions

Both APIs follow the same four-step shape: build a SpeechConfig, optionally an AudioConfig (input source or output destination), create a proxy client, then call a method and inspect the result.

Speech-to-text vs. text-to-speech.
Speech-to-textText-to-speech
Proxy clientSpeechRecognizerSpeechSynthesizer
AudioConfig defaultSystem microphone (or a file)System speaker (or a file/stream)
Main methodRecognizeOnceAsync()SpeakTextAsync()
Success ReasonRecognizedSpeech (read Text)SynthesizingAudioCompleted (read AudioData)

Key concept · Reading the result's Reason

The recognition result's Reason tells you what happened: RecognizedSpeech (success — use the Text property), NoMatch (audio parsed but no speech detected), or Canceled (an error — check CancellationReason). The synthesis result exposes AudioData, Reason, and ResultId; a Canceled synthesis carries cancellation details.

03Formats, voices, SSML

Shaping the spoken output

Through SpeechConfig you choose the audio format (file type, sample rate, bit depth — e.g. Riff24Khz16BitMonoPcm) and the voice, named by locale + person + detail (e.g. en-US-Brian:DragonHDLatestNeural).

Key concept · SSML for fine control

Speech Synthesis Markup Language is an XML syntax that goes beyond plain text: speaking styles (e.g. cheerful, via mstts:express-as with neural voices), pauses/breaks, phonemes (pronounce "SQL" as "sequel"), prosody (pitch, timbre, rate), say-as rules (dates, times, phone numbers), and inserted audio. Submit it with speak_ssml_async() instead of speak_text_async(). Multiple <voice> elements can hold a dialog between different neural voices.

★Test yourself

Chapter 19 quiz

Fifteen questions on the service, the two APIs, and formats/voices/SSML. Answer first, then expand Show answer.

Part A · Multiple choice

Q1

What object encapsulates the connection details for every Azure Speech operation?

  • A SpeechConfig
  • B AudioConfig
  • C MCPTool
  • D TextAnalyticsClient
Show answer

A — SpeechConfig. Subscription key plus endpoint (or region).

Q2

Which proxy client transcribes speech?

  • A SpeechRecognizer
  • B SpeechSynthesizer
  • C TranslationRecognizer
  • D AIProjectClient
Show answer

A — SpeechRecognizer. SpeechSynthesizer does text-to-speech.

Q3

What Reason value means audio was parsed but no speech was detected?

  • A RecognizedSpeech
  • B NoMatch
  • C Canceled
  • D SynthesizingAudioCompleted
Show answer

B — NoMatch. Canceled means an error occurred.

Q4

What is the default AudioConfig input for speech-to-text?

  • A The system microphone
  • B A blob container
  • C A fixed WAV file
  • D The system speaker
Show answer

A — the system microphone (a file path is the alternative).

Q5

How is a voice named?

  • A Locale + person + detail, e.g. en-US-Brian:DragonHDLatestNeural
  • B A random GUID
  • C Just a number
  • D The endpoint URL
Show answer

A. e.g. locale en-US, person Brian, detail DragonHDLatestNeural.

Q6

Which SSML feature makes "SQL" pronounced as "sequel"?

  • A Phonemes
  • B Prosody
  • C Say-as
  • D Break
Show answer

A — phonemes. They define phonetic pronunciation.

Q7

Which method submits SSML rather than plain text?

  • A speak_ssml_async()
  • B speak_text_async()
  • C recognize_once_async()
  • D transcriptions.create()
Show answer

A — speak_ssml_async().

Part B · True or false

Q8

Both the STT and TTS APIs follow the same core four-step pattern.

Show answer

True. Config → (audio config) → proxy client → method call/result.

Q9

Python SDK 1.48.2+ can use the Foundry resource endpoint directly.

Show answer

True. Earlier versions required a region.

Q10

AudioConfig is always required.

Show answer

False. It's optional; defaults are microphone (in) and speaker (out).

Q11

SSML can put two different neural voices into one dialog.

Show answer

True. Using multiple <voice> elements.

Q12

Audio output format lets you set file type, sample rate, and bit depth.

Show answer

True. e.g. Riff24Khz16BitMonoPcm, set via SpeechConfig.

Part C · Short answer

Q13

Name the two proxy clients for STT and TTS.

Show answer

SpeechRecognizer (STT) and SpeechSynthesizer (TTS).

Q14

Name three things SSML controls.

Show answer

Any three: speaking styles, pauses/breaks, phonemes, prosody (pitch/rate), say-as rules, and inserted audio.

Q15

What Reason value indicates a successful synthesis?

Show answer

SynthesizingAudioCompleted — with AudioData containing the stream.