I have a Python Kivy App where you can use different TTS APIs. I use the basic SSML-Tags but I want to add the Microsoft exclusive styles of the mstts:express-as
attribute. Is there any way to get the available styles for each voice dynamically from the API without having to hardcode it for 50 voices?
I tried the below code to get the available styles for each voice from the Azure Text-to-Speech API.
I modified the line below in the code to retrieve the available styles for 50 voices without any issues.
for voice in voices[:50]:
app.py :
import requests
speech_key = "<SppechKey>"
region = "<SpeechRegion>"
endpoint = f"https://{region}.tts.speech.microsoft.com/cognitiveservices/voices/list"
headers = {
"Ocp-Apim-Subscription-Key": speech_key
}
response = requests.get(endpoint, headers=headers)
voices = response.json()
for voice in voices:
full_name = voice["Name"]
short_name = voice.get("ShortName", "N/A")
styles = voice.get("StyleList", [])
print(f"Full Name: {full_name}, Short Name: {short_name}")
if styles:
print(f"Voice: {short_name}, Styles: {', '.join(styles)}")
else:
print(f"Voice: {short_name}, Styles: None")
Output :
I successfully retrieved the list of styles available for 50 Text-to-Speech voices.