Exams / AI-901 / D2 Implement AI solutions by using Microsoft Foundry
Implement AI solutions for text and speech by using Foundry
- Build a lightweight application that includes text analysis
- Respond to spoken prompts by using a deployed multimodal model
- Build a lightweight application by using Azure Speech in Foundry Tools
This module is about the SDK/class/package mechanics behind text analysis and speech, not just "which workload is this" (that's D1.3). Expect: which Python class/method/package to call, and which object configures what.
Azure Language: text analysis in Python
Azure Language's text-analysis features (key phrase extraction, NER, sentiment, summarization, PII detection, language detection) are all reached from one client library:
| What you need | How |
|---|---|
| Install the SDK | pip install azure-ai-textanalytics — "Use this quickstart to create a Named Entity Recognition (NER) application with the client library for Python.", installed with "After installing Python, you can install the client library with:" the azure-ai-textanalytics package |
| Build the client | TextAnalyticsClient(endpoint, AzureKeyCredential(key)) |
| Key topics of a text | client.extract_key_phrases() — "Use key phrase extraction to quickly identify the main concepts in text." |
| Typed entities (people, places, dates…) | client.recognize_entities() |
| Entities linked to a knowledge base | client.recognize_linked_entities() |
| Condensed summary | client.begin_extract_summary() (long-running operation, hence begin_) |
The package name is the trap: azure-ai-textanalytics is the Language SDK. azure-ai-translation-text is Translator, azure-search-documents is Azure AI Search, and langchain is a generic orchestration framework — none of those are the Azure Language client library.
Azure Speech in Foundry Tools: the four core SDK classes
| Class | Role |
|---|---|
SpeechConfig |
Connection/auth to the Speech resource — "Class that defines configurations for speech recognition and speech synthesis." Built from the resource's key plus region or endpoint: "Get the Speech resource key and region." / "The service endpoint to connect to." |
AudioConfig |
Audio input source for recognition — microphone (use_default_microphone=True) or a file |
SpeechRecognizer |
Speech-to-text. Needs a SpeechConfig (and optionally an AudioConfig) |
SpeechSynthesizer + AudioOutputConfig |
Text-to-speech. AudioOutputConfig is the audio output destination (speaker, file, or stream) |
Storage keys, model-deployment names, and Foundry project endpoints are all distractors here — none of them initialize a SpeechConfig.
Recognition: single-shot vs. continuous
| Method | Use case |
|---|---|
recognizer.recognize_once() |
"The previous examples use single-shot recognition, which recognizes a single utterance." — one spoken command, synchronous |
recognizer.start_continuous_recognition() / stop_continuous_recognition() |
"In contrast, you use continuous recognition when you want to control when to stop recognizing." — ongoing microphone/file transcription, started and stopped explicitly |
recognizer.start_keyword_recognition() |
Listens for a specific keyword/wake word, not generic commands |
A default-microphone AudioConfig for continuous transcription: audio_config = speechsdk.audio.AudioConfig(use_default_microphone=True).
Synthesis output destination
AudioOutputConfig decides where synthesized audio goes:
AudioOutputConfig(filename="output.wav")— "To save synthesized speech to a file instead of playing it to the speaker, specify a filename in the AudioOutputConfig."AudioOutputConfig(stream)— writes to a stream object (needs an actual stream, not just the class name).AudioOutputConfig(use_default_speaker=True)— plays through the speaker (the default if no file/stream is given).AudioStreamFormatonly describes a stream's audio format; it is not itself an output destination.
Batch vs. real-time speech-to-text
| Capability | When |
|---|---|
Real-time recognition (SpeechRecognizer) |
Live microphone or a single file, one call at a time |
| Batch transcription | "Use batch transcription to transcribe a large amount of audio data in storage." Point it at multiple files or "an Azure Blob Storage container with the audio files to transcribe" — the right fit for thousands of already-recorded calls |
Speech recognition vs. synthesis (the matching trap)
- Speech recognition = "Use speech to text to convert audio into text." → it transcribes spoken input.
- Speech synthesis = "With text to speech, you can convert input text into humanlike synthesized speech." → it generates spoken output.
- Entity extraction is a separate NLP capability (Azure Language), not something either speech tool performs — in a matching exercise it should be left unmatched.
Sending audio to a deployed multimodal model
A multimodal model deployment in Microsoft Foundry that supports audio accepts the recorded audio directly, no separate speech-to-text step: "Models that support audio inputs and outputs allow you to generate spoken audio responses to prompts and use audio inputs to prompt the model." A text transcript is only needed when the target model does not accept audio input and speech-to-text runs first as a preprocessing step. Sending an image of the waveform or a text embedding vector are not how audio-capable models consume voice input.
Exam traps
SpeechConfig= connection/auth (key + region/endpoint).AudioConfig= input source.AudioOutputConfig= output destination. Don't swap them.recognize_once()= one utterance, synchronous.start_continuous_recognition()/stop_continuous_recognition()= ongoing, explicitly stopped.start_keyword_recognition()= wake-word listening, not general commands.- Batch transcription works on audio already in storage (multiple files or a Blob container); it is not for a live microphone feed.
AudioOutputConfig(filename=...)writes to a file;AudioOutputConfig(stream)needs a real stream object;AudioStreamFormatonly sets a stream's format, it is not an output destination.- Azure Language's Python package is
azure-ai-textanalytics— notazure-ai-translation-text(Translator),azure-search-documents(Azure AI Search), orlangchain. extract_key_phrases()= main topics/concepts.recognize_entities()= typed entities.recognize_linked_entities()= entities + knowledge-base links.begin_extract_summary()= condensed summary (long-running).- An audio-capable multimodal model takes audio directly as an input prompt — a text transcript is only needed when the model itself doesn't accept audio.
Docs
- Text to speech overview - Speech service - Foundry Tools
- How to recognize speech - Speech service
- Speech-to-text quickstart — Foundry Tools
- SpeechRecognizer class — Azure SDK for Python
- SpeechConfig class — Azure SDK for Python
- Text to speech quickstart - Speech service - Foundry Tools
- AudioOutputConfig class — Azure SDK for Python
- Batch transcription overview - Speech service - Foundry Tools
- Locate audio files for batch transcription - Speech service - Foundry Tools
- What is Azure Speech?
- Quickstart: Get started with Azure OpenAI audio generation
- What is key phrase extraction in Azure Language in Foundry Tools?
- Quickstart: Use the NER client library — Foundry Tools
- Use Azure Language SDK and REST API — Foundry Tools