Overview
This plugin allows you to use MAI voices from Microsoft AI as a TTS provider for your voice agents. The plugin synthesizes speech with the Azure Speech REST API.
Installation
Install the plugin from PyPI:
uv add "livekit-agents[microsoft-ai]~=1.8"
Authentication
The plugin requires an Azure Speech resource key and region. Set the following environment variables in your .env file:
MICROSOFT_AI_TTS_API_KEY=<your-speech-resource-key>MICROSOFT_AI_TTS_REGION=<your-speech-region>
Usage
Use Microsoft AI TTS in an AgentSession or as a standalone speech generator. For example, you can use this TTS in the Voice AI quickstart.
from livekit.agents import AgentSessionfrom livekit.plugins import microsoft_aisession = AgentSession(tts=microsoft_ai.TTS(voice="en-US-Harper",model="MAI-Voice-2-Flash",sample_rate=24000,),# ... llm, stt, etc.)
The plugin has no default model, voice, or sample rate. Set each one in the constructor or with its environment variable.
Parameters
This section describes some of the available parameters. See the plugin reference for a complete list of all available parameters.
voicestringEnv: MICROSOFT_AI_TTS_VOICEVoice name, for example en-US-Harper. The plugin appends model to form the voice ID. You can also pass a full voice ID such as en-US-Harper:MAI-Voice-2-Flash.
modelstringEnv: MICROSOFT_AI_TTS_MODELMAI voice model, for example MAI-Voice-2-Flash. Optional when voice is a full voice ID. If you set both, the model must match the suffix of voice (case-insensitive).
sample_rateintegerEnv: MICROSOFT_AI_TTS_SAMPLE_RATEOutput sample rate in Hz. Valid values are 8000, 22050, 24000, 44100, and 48000.
languagestringDefault: en-USLanguage tag for the SSML request.
regionstringEnv: MICROSOFT_AI_TTS_REGIONAzure Speech region, for example eastus. Required unless you set url.
urlstringEnv: MICROSOFT_AI_TTS_URLFull synthesis endpoint URL. Use this parameter for sovereign clouds or custom endpoints. This value overrides region.
Additional resources
The following resources provide more information about using Microsoft AI with LiveKit Agents.