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

Module Study Guide · Path 3 · Natural language

Develop a Speech-Capable Generative AI Application

A generative model that hears and speaks — the same gpt-4o family that reasons over text now transcribes audio and returns a voice.

— the module's idea

Speech through generative models. This module covers choosing a speech-capable model from the Foundry catalog, transcribing audio to text, and synthesizing text into a voice — all through the AzureOpenAI client.

gpt-4o speech modelstranscribesynthesize14 quiz questions
01Choosing a model

Transcription vs. synthesis

The Microsoft Foundry model catalog holds generative models from many providers, each optimized for different tasks. For audio there are two use cases — speech-to-text (transcription) and text-to-speech (synthesis) — and the gpt-4o family of OpenAI models offers specialized speech-capable variants for both. Use the portal's filters and search to match a model to your app.

Key concept · The speech-capable model line-up

Transcription: gpt-4o-transcribe (standard), gpt-4o-mini-transcribe (lightweight), and gpt-4o-transcribe-diarize (adds speaker diarization — who said what). Synthesis: gpt-4o-tts and gpt-4o-mini-tts. Availability varies by region, so check the model regional-availability table before you deploy.

02Transcribe

Audio in, text out

Speech-to-text submits audio to the model and returns a text transcript. You use the AzureOpenAI client from the OpenAI SDK, pointed at your Foundry endpoint.

Key concept · The transcription call

Open the audio file in binary mode and call client.audio.transcriptions.create(model=…, file=audio_file, response_format="text"). The key parameters are the model deployment, the binary file, and the response_format (e.g. "text"), against an api_version such as 2025-03-01-preview. The return is the transcript.

03Synthesize

Text in, voice out

Text-to-speech is the reverse: submitted text becomes an audio stream of vocalized speech, again through the AzureOpenAI client.

Key concept · The synthesis call

Call client.audio.speech.with_streaming_response.create(model=…, voice="alloy", input="…", instructions="Speak in an upbeat tone") and stream the result to a file. The distinctive parameters are voice (e.g. "alloy"), input (the text), and an optional instructions string that steers the delivery style or tone — a generative twist the classic Speech SDK doesn't have. The output is an audio file you write to disk.

★Test yourself

Chapter 18 quiz

Fourteen questions on model choice, transcription, and synthesis. Answer first, then expand Show answer.

Part A · Multiple choice

Q1

Which model family provides the speech-capable variants in this module?

  • A Phi-4
  • B The gpt-4o family
  • C FLUX
  • D Sora
Show answer

B — gpt-4o. Specialized transcribe and tts variants.

Q2

Which model adds speaker diarization?

  • A gpt-4o-transcribe-diarize
  • B gpt-4o-mini-tts
  • C gpt-4o-tts
  • D gpt-4o-mini-transcribe
Show answer

A. Diarization identifies who said what.

Q3

Which client is used for both transcription and synthesis here?

  • A The AzureOpenAI client from the OpenAI SDK
  • B TextAnalyticsClient
  • C SpeechRecognizer
  • D AIProjectClient
Show answer

A. Pointed at the Foundry endpoint.

Q4

Which method transcribes audio?

  • A client.audio.transcriptions.create
  • B client.images.generate
  • C client.responses.create
  • D recognize_entities
Show answer

A. With model, binary file, and response_format.

Q5

Which synthesis parameter steers the delivery style or tone?

  • A instructions
  • B response_format
  • C seconds
  • D size
Show answer

A — instructions, e.g. "Speak in an upbeat, excited tone."

Q6

What are the two audio use cases the module covers?

  • A Transcription and synthesis
  • B Translation and summarization
  • C Detection and redaction
  • D Vision and video
Show answer

A. Speech-to-text and text-to-speech.

Part B · True or false

Q7

Model availability for these speech models varies by region.

Show answer

True. Check the regional-availability table before deploying.

Q8

The audio file must be opened in binary mode for transcription.

Show answer

True. e.g. open(path, "rb").

Q9

The "voice" parameter belongs to the transcription call.

Show answer

False. voice is a synthesis (text-to-speech) parameter.

Q10

Synthesis returns an audio stream that you can write to a file.

Show answer

True. Using the streaming response to save the file.

Q11

gpt-4o-mini-transcribe is a lightweight transcription model.

Show answer

True. A smaller variant of gpt-4o-transcribe.

Part C · Short answer

Q12

Name the three transcription models.

Show answer

gpt-4o-transcribe, gpt-4o-mini-transcribe, and gpt-4o-transcribe-diarize.

Q13

Name the two text-to-speech models.

Show answer

gpt-4o-tts and gpt-4o-mini-tts.

Q14

Name the three main parameters of the synthesis call.

Show answer

voice, input (the text), and instructions (plus the model deployment).