Shiny.Maui.Shell v6 support for AI routing tools Learn More
Azure AI Speech
| Downloads |
Frameworks
.NET
.NET MAUI
Operating Systems
Android
iOS
Windows
Overview
Section titled “Overview”Azure AI Speech provides enterprise-grade cloud speech-to-text and text-to-speech powered by Azure Cognitive Services. It replaces the platform-native ISpeechToTextService and ITextToSpeechService registrations with cloud-backed implementations while still using platform-native audio capture and playback.
// In MauiProgram.csbuilder.Services.AddAudioSource(); // Platform-native microphone capture (required for STT)builder.Services.AddAudioPlayer(); // Platform-native audio playback (required for TTS)builder.Services.AddAzureSpeech("your-subscription-key", "eastus");Or with a config object and selective services:
builder.Services.AddAudioSource();builder.Services.AddAudioPlayer();builder.Services.AddAzureSpeech( new AzureSpeechConfig { SubscriptionKey = "your-subscription-key", Region = "eastus" }, speechToText: true, textToSpeech: true);Configuration
Section titled “Configuration”public record AzureSpeechConfig{ public required string SubscriptionKey { get; init; } public required string Region { get; init; }}| Property | Description |
|---|---|
SubscriptionKey | Your Azure Speech Services subscription key |
Region | Azure region (e.g., eastus, westus2, westeurope) |
Once registered, inject and use ISpeechToTextService and ITextToSpeechService exactly as you would with platform-native speech — the API is identical:
public class MyViewModel(ISpeechToTextService stt, ITextToSpeechService tts){ async Task ListenAndRespond(CancellationToken ct) { var access = await stt.RequestAccess(); if (access != AccessState.Available) return;
var text = await stt.ListenUntilSilence(cancellationToken: ct);
if (text != null) await tts.SpeakAsync($"You said: {text}"); }}STT-Only or TTS-Only
Section titled “STT-Only or TTS-Only”You can register Azure for just one service:
// Azure STT only (use platform-native TTS)builder.Services.AddAudioSource();builder.Services.AddTextToSpeech(); // Platform-native TTSbuilder.Services.AddAzureSpeech("key", "region", speechToText: true, textToSpeech: false);
// Azure TTS only (use platform-native STT)builder.Services.AddAudioPlayer();builder.Services.AddSpeechToText(); // Platform-native STTbuilder.Services.AddAzureSpeech("key", "region", speechToText: false, textToSpeech: true);