g.schindler17
g.schindler17

Reputation: 62

Using SSML and Python with Azure Voice

I'm creating a project that uses Azure's voice to text to speak a string back to the user. I want to change the voice gender and style with SSML, but Python does not seem to really support all the symbols needed in the string. I can't find any documentation on it, but is there a way?

My code:

import azure.cognitiveservices.speech as speechsdk


what_needs_to_be_spoken = "Sample text to be spoken"

# Creates an instance of a speech config with specified subscription key and service region.
# Replace with your own subscription key and service region (e.g., "westus").
speech_key, service_region = "insert_azure_speech_key_here", "eastus"
speech_config = speechsdk.SpeechConfig(subscription=speech_key, region=service_region)


# Creates a speech synthesizer using the default speaker as audio output.
speech_synthesizer = speechsdk.SpeechSynthesizer(speech_config=speech_config)

# Synthesizes the received text to speech.
# The synthesized speech is expected to be heard on the speaker with this line executed.
result = speech_synthesizer.speak_text_async(what_needs_to_be_spoken).get()

Upvotes: 1

Views: 1309

Answers (1)

chschrae
chschrae

Reputation: 36

SSML is fully supported in the SDK for the SpeechSynthesizer

Python should support all the symbols needed inside the string.

Here is a general overview of Strings in python.

https://realpython.com/python-strings/#string-manipulation

Please let us know if there is more you need.

Upvotes: 0

Related Questions