# Microsoft Azure (/en/ai/platform/models/tts/microsoft)

> For AI agents: see the complete documentation index at [llms.txt](/llms.txt).

> Documentation: Conversational AI.
> Documentation version: Preview.
> This document describes only this version. [Version index](/llms/doc-versions-convoai-guides-v2.txt).


Microsoft Azure offers neural voices in multiple languages with options for different speaking styles and emotions, providing enterprise-grade text-to-speech capabilities with high-quality audio output.

## Sample configuration

The following example shows how to configure Microsoft Azure as the agent's TTS when you create or update an agent. For a complete example, see [Create an agent and start a session](/en/ai/platform/get-started/start-stop-agent#create-an-agent).

Microsoft Azure supports BYOK only. It isn't available in managed mode. Store your Azure Speech key in a secret set, and refer to it from the agent. Your Azure region isn't secret. For details, see [Use your own provider keys](/en/ai/platform/build/use-your-own-keys).

**Python SDK**

```python
from agora_agent import Agent, MicrosoftTTS, secret_ref

# client is your configured Agora client
agent = (
    Agent(client=client)
    .with_stt(...)  # configure your ASR vendor
    .with_llm(...)  # configure your LLM vendor
    .with_tts(
        MicrosoftTTS(
            key=secret_ref("support_prod", "microsoft"),
            region="eastus",
            voice_name="en-US-AndrewMultilingualNeural",
            speed=1.0,
            volume=70,
            sample_rate=24000,
        )
    )
)
```

**TypeScript SDK**

```ts
import { Agent, MicrosoftTTS, secretRef } from 'agora-agents';

// client is your configured Agora client
const agent = new Agent({ client })
  .withStt(/* configure your ASR vendor */)
  .withLlm(/* configure your LLM vendor */)
  .withTts(
    new MicrosoftTTS({
      key: secretRef('support_prod', 'microsoft'),
      region: 'eastus',
      voiceName: 'en-US-AndrewMultilingualNeural',
      speed: 1.0,
      volume: 70,
      sampleRate: 24000,
    }),
  );
```

**Go SDK**

```go
// client is your configured Agora client
speed, volume, sampleRate := 1.0, 70.0, vendors.SampleRate24kHz
agent := agentkit.NewAgent(client).
	WithStt( /* configure your ASR vendor */ ).
	WithLlm( /* configure your LLM vendor */ ).
	WithTts(vendors.NewMicrosoftTTS(vendors.MicrosoftTTSOptions{
		Key:        agentkit.SecretRef("support_prod", "microsoft"),
		Region:     "eastus",
		VoiceName:  "en-US-AndrewMultilingualNeural",
		Speed:      &speed,
		Volume:     &volume,
		SampleRate: &sampleRate,
	}))
```

**REST API**

Set `credential.mode` to `byok` and `credential.fields.key` to a reference to your Azure Speech key. Pass your Azure region in `params`. In the following example, the key is stored as `microsoft` in the `support_prod` set:

```json
"tts": {
  "credential": {
    "mode": "byok",
    "fields": {
      "key": "$secrets.support_prod.microsoft"
    }
  },
  "vendor": "microsoft",
  "params": {
    "region": "eastus",
    "voice_name": "en-US-AndrewMultilingualNeural",
    "speed": 1.0,
    "volume": 70,
    "sample_rate": 24000
  }
}
```

## Key parameters

The `tts` block takes the following fields. In the SDKs, `MicrosoftTTS` sets them from its options.

**tts**

**`vendor` (string) required**

Set to `microsoft`.

**`credential` (object) required**

Set `mode` to `byok` and `fields.key` to a `$secrets.<set>.<key>` reference to your Azure Speech key. Get your key from the [Azure Portal](https://portal.azure.com/).

**`params` (object) required**

**`region` (string) required**

The Azure region where the speech service is hosted, for example `eastus` or `westus2`.

**`voice_name` (string) required**

The identifier for the selected voice for speech synthesis. See [available voices](https://learn.microsoft.com/en-us/azure/ai-services/speech-service/language-support?tabs=tts) for options.

**`speed` (number) optional**

Default value: `1.0`

Speaking rate of the text. Values between `0.5` and `2.0` times the original audio speed.

**`volume` (number) optional**

Default value: `100`

Audio volume as a number between `0.0` and `100.0`, where `0.0` is quietest and `100.0` is loudest.

**`sample_rate` (integer) optional**

Default value: `24000`

Audio sampling rate in Hz. Common values: `16000`, `24000`, `48000`.

> **Caution**
>
> The parameters listed on this page are validated for use with the Conversational AI Platform. Required parameters must be provided as documented. Any additional parameters in `params` are passed through directly to Microsoft Azure without validation. For a full list of supported options, refer to the [Microsoft Azure TTS documentation](https://learn.microsoft.com/en-us/azure/ai-services/speech-service/text-to-speech).
