Azure TTS
Navel’s Python SDK can use Microsoft Azure as a text-to-speech backend for scripts that need cloud-generated voices. This gives researchers access to a large Azure voice catalog with support for more than 70 languages, including multilingual voices and optional speaking styles.
Azure TTS requires an Azure Speech resource, a matching resource key and region, and an internet connection from the robot. The SDK sends the text to Azure, receives synthesized audio, and plays it through Navel’s normal TTS audio device.
Warning
Azure Speech is a billed cloud service. Do not put account keys into source control or share them in notebooks, papers, screenshots, or issue reports.
Create the Azure resource
You need an Azure account with an active subscription and an Azure AI Speech
resource. After the resource has been deployed, open the resource’s Keys and
Endpoint page and copy one of the keys. Also note the resource’s region
identifier, for example germanywestcentral. These are the values passed as
speech_key and speech_region when calling
set_speech_backend("azure", ...).
More info: https://learn.microsoft.com/en-us/azure/ai-services/Speech-Service/language-support?tabs=tts
If you prefer the Azure CLI, the equivalent minimal setup is:
az login
az account set --subscription "<SUBSCRIPTION_ID>"
az group create \
--name "<RESOURCE_GROUP>" \
--location "germanywestcentral"
az cognitiveservices account create \
--name "<RESOURCE_NAME>" \
--resource-group "<RESOURCE_GROUP>" \
--kind "SpeechServices" \
--sku "S0" \
--location "germanywestcentral" \
--yes
az cognitiveservices account keys list \
--name "<RESOURCE_NAME>" \
--resource-group "<RESOURCE_GROUP>" \
--query "key1" \
-o tsv
Use Azure TTS
The Azure backend is selected from Python with
navel.Robot.set_speech_backend(). The SDK package already depends on
the Azure Speech SDK.
Create a script such as azure_speak.py:
1#!/usr/bin/env python3
2
3import asyncio
4
5import navel
6
7
8async def main():
9 async with navel.Robot() as robot:
10 robot.set_speech_backend(
11 "azure",
12 speech_key="<your Azure Speech key>",
13 speech_region="germanywestcentral",
14 locale="de-DE",
15 voice_name="zh-CN-XiaoyouMultilingualNeural",
16 )
17 await robot.say("Hallo, ich spreche mit Azure Text-to-Speech.")
18
19
20if __name__ == "__main__":
21 asyncio.run(main())
Run it on the robot:
python3 azure_speak.py
To use a different voice, change both locale and voice_name to a
supported Azure Speech voice. Azure text-to-speech supports more than 70
languages, and the voice list changes over time, so use Microsoft’s language
and voice support page when choosing a voice for a study.
The Azure backend also accepts optional style and pitch arguments:
robot.set_speech_backend(
"azure",
speech_key="<your Azure Speech key>",
speech_region="germanywestcentral",
locale="de-DE",
voice_name="zh-CN-XiaoyouMultilingualNeural",
style="chat",
pitch="+14%",
)
These are the relevant parameters for Azure TTS:
Parameter |
Value |
|---|---|
|
|
|
One key from the Azure Speech resource’s Keys and Endpoint page |
|
The Azure region identifier for the Speech resource, for example
|
|
The BCP-47 locale for the selected voice, for example |
|
The Azure voice name, for example |
|
Optional Azure speaking style supported by the selected voice |
|
Optional pitch adjustment, for example |