Microsoft Azure

Updated

Use Microsoft Azure for text-to-speech (TTS) in a Conversational AI Platform agent.

Preview documentation

You're reading the Conversational AI Platform (Preview) docs. Switch to Main.

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.

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.

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,
        )
    )
)
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,
    }),
  );
// 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,
	}))

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:

"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
vendorstring
required

Set to microsoft.

credentialobject
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.

paramsobject
required
regionstring
required

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

voice_namestring
required

The identifier for the selected voice for speech synthesis. See available voices for options.

speednumber
optional
Default value
1.0

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

volumenumber
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_rateinteger
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.