> This page is for Platform.

> Fetch clean Markdown by appending `.md` to any page URL under https://signalwire.com/docs or requesting it with the HTTP header `Accept: text/markdown`. The root index at https://signalwire.com/docs/llms.txt lists the available documentation indexes.

# Azure

> Learn how to use Azure TTS voices on the SignalWire platform.

Microsoft's Azure platform offers an impressive array of high-quality, multilingual voices in its Neural model.

## Voices

#### [Voices](https://learn.microsoft.com/en-us/azure/ai-services/speech-service/language-support?tabs=tts)

Browse the complete list of Azure Neural voices in Microsoft's official documentation.

#### [Voice gallery](https://speech.microsoft.com/portal/voicegallery)

Listen to audio samples and preview voices in Azure's interactive voice gallery.

## Usage

Azure voice IDs conform to the following format:

```
azure.<voice>
```

Where `<voice>` is the full Azure voice code (e.g., `en-US-AvaNeural`).

**Examples:**

```
azure.en-US-AvaNeural
azure.en-GB-SoniaNeural
azure.de-DE-KatjaNeural
azure.es-ES-ElviraNeural
```

**Note:** Azure voice IDs already include language information, so no additional language parameter is needed.

## Languages

Azure Neural voices are interchangeably compatible with all supported languages.
Rather than setting language with the language `code`,
simply provide input text in the desired language.

Consult the Azure
[supported languages resource](https://learn.microsoft.com/en-us/azure/ai-services/speech-service/language-support?tabs=tts)
for an up-to-date list of supported languages.

## SSML support

Azure voices support [Speech Synthesis Markup Language (SSML)](https://learn.microsoft.com/en-us/azure/ai-services/speech-service/speech-synthesis-markup) for advanced control over:

* Prosody (pitch, rate, volume)
* Emphasis and breaks
* Phonetic pronunciation
* Multi-language content

Consult Azure's [SSML documentation](https://learn.microsoft.com/en-us/azure/ai-services/speech-service/speech-synthesis-markup) for detailed usage instructions.

---

## Examples

Learn how to use Azure voices on the SignalWire platform.

#### SWML

Use the
[**`languages`**](/docs/swml/reference/calling/ai/languages#use-voice-strings)
SWML method to set one or more voices for an [AI agent](/docs/swml/reference/calling/ai).

#### Python — SWML builder

```python
# Install: python -m pip install signalwire-sdk
# Save as azure_ai_agent.py and run: python azure_ai_agent.py
from signalwire import SWMLBuilder, SWMLService

service = SWMLService(
    name="azure-ai-agent",
    route="/swml",
    port=3000,
    basic_auth=("signalwire", "<YOUR_BASIC_AUTH_PASSWORD>"),
)
SWMLBuilder(service).ai(
    prompt_text="Have an open-ended conversation about flowers.",
    languages=[{
        "name": "English",
        "code": "en-US",
        "voice": "azure.en-US-AvaNeural",
    }],
)

service.serve()
```

#### TypeScript — SWML builder

```typescript
// Install: npm install @signalwire/sdk
// This sample also runs as JavaScript: save as azure-ai-agent.mjs,
// then run: node azure-ai-agent.mjs
import { SWMLService } from "@signalwire/sdk";

const service = new SWMLService({
  name: "azure-ai-agent",
  route: "/swml",
  port: 3000,
  basicAuth: ["signalwire", "<YOUR_BASIC_AUTH_PASSWORD>"],
});
service.getBuilder().ai({
  // @ts-expect-error The ai verb takes a { text } prompt; the SDK types it as a string.
  prompt: { text: "Have an open-ended conversation about flowers." },
  languages: [
    { name: "English", code: "en-US", voice: "azure.en-US-AvaNeural" },
  ],
});

await service.serve();
```

#### YAML

```yaml
version: 1.0.0
sections:
  main:
  - ai:
      prompt:
        text: Have an open-ended conversation about flowers.
      languages:
        - name: English
          code: en-US
          voice: azure.en-US-AvaNeural
```

Alternatively, use the [**`say_voice`** parameter](/docs/swml/reference/play#variables)
of the [**`play`**](/docs/swml/reference/play)
SWML method to select a voice for basic TTS.

#### Python — SWML builder

```python
# Install: python -m pip install signalwire-sdk
# Save as azure_tts.py and run: python azure_tts.py
from signalwire import SWMLBuilder, SWMLService

service = SWMLService(
    name="azure-tts",
    route="/swml",
    port=3000,
    basic_auth=("signalwire", "<YOUR_BASIC_AUTH_PASSWORD>"),
)
builder = SWMLBuilder(service)
builder.set(say_voice="azure.en-US-AvaNeural")
builder.play(url="say:Greetings. This is the Ava voice from Microsoft Azure's Neural text-to-speech model.")

service.serve()
```

#### TypeScript — SWML builder

```typescript
// Install: npm install @signalwire/sdk
// This sample also runs as JavaScript: save as azure-tts.mjs,
// then run: node azure-tts.mjs
import { SWMLService } from "@signalwire/sdk";

const service = new SWMLService({
  name: "azure-tts",
  route: "/swml",
  port: 3000,
  basicAuth: ["signalwire", "<YOUR_BASIC_AUTH_PASSWORD>"],
});
const builder = service.getBuilder();
builder.set({ say_voice: "azure.en-US-AvaNeural" });
builder.play({ url: "say:Greetings. This is the Ava voice from Microsoft Azure's Neural text-to-speech model." });

await service.serve();
```

#### YAML

```yaml
version: 1.0.0
sections:
  main:
  - set:
      say_voice: "azure.en-US-AvaNeural"
  - play: "say:Greetings. This is the Ava voice from Microsoft Azure's Neural text-to-speech model."
```

The [Server SDKs](/docs/server-sdks) build each document and serve it at `/swml` on port 3000.
The server answers only requests that carry the username `signalwire` and the password you set
in place of `<YOUR_BASIC_AUTH_PASSWORD>`. To send calls from your phone number to the server,
follow [Answer a call via SWML](/docs/platform/voice/make-and-receive-calls#answer-a-call-via-swml).

#### WebSocket (Relay)

A Relay client in the [Server SDKs](/docs/server-sdks) passes the voice string with the text it
plays. This handler answers calls on the `default` topic, plays the greeting in that voice, and
hangs up. Replace `<YOUR_PROJECT_ID>` and `<YOUR_API_TOKEN>` with your Project ID and an API
token that has the **Voice** permission.

#### Python — Relay client

```python
# Install: python -m pip install signalwire-sdk
# Save as azure_relay.py and run: python azure_relay.py
from signalwire.relay import RelayClient

client = RelayClient(
    project="<YOUR_PROJECT_ID>",
    token="<YOUR_API_TOKEN>",
    contexts=["default"],
)

@client.on_call
async def handle_call(call):
    await call.answer()

    async def hang_up_after_playback(_event):
        if call.state != "ended":
            await call.hangup()

    await call.play([{
        "type": "tts",
        "params": {
            "text": "Greetings. This is the Ava voice from Microsoft Azure's Neural text-to-speech model.",
            "voice": "azure.en-US-AvaNeural",
        },
    }], on_completed=hang_up_after_playback)
    await call.wait_for_ended()

client.run()
```

#### TypeScript — Relay client

```typescript
// Install: npm install @signalwire/sdk
// This sample also runs as JavaScript: save as azure-relay.mjs,
// then run: node azure-relay.mjs
import { RelayClient } from "@signalwire/sdk";

const client = new RelayClient({
  project: "<YOUR_PROJECT_ID>",
  token: "<YOUR_API_TOKEN>",
  contexts: ["default"],
});

client.onCall(async (call) => {
  await call.answer();
  await call.play([{
    type: "tts",
    params: {
      text: "Greetings. This is the Ava voice from Microsoft Azure's Neural text-to-speech model.",
      voice: "azure.en-US-AvaNeural",
    },
  }], {
    onCompleted: async () => {
      if (call.state !== "ended") await call.hangup();
    },
  });
  await call.waitForEnded();
});

await client.run();
```

To route calls from your phone number to the handler, assign the number to a Relay Application
on the `default` topic, as described in
[Answer a call via WebSocket (Relay)](/docs/platform/voice/make-and-receive-calls#answer-a-call-via-websocket-relay).

#### Call Flow Builder

Azure voices are not yet supported in Call Flow Builder.