Hi,
I am trying the service with python and have changed the language with the following settings based on the sample code:
lang = "de-DE-Stefan-Apollo"
speech_config = speechsdk.SpeechConfig(subscription=speech_key, region=service_region, speech_recognition_language=lang)
However, the speech-language is still the default one (English).
Could you please let me know how to change the language correctly? Thanks!
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
@irishun The speech_recognition_language should be in the recognized BCP-47 format which is essentially in this case de-DE. de-DE-Stefan-Apollo is the voice that would be used later to convert your text to synthesized speech.
Hi Rohit, thank you very much for the reply. I have changed to:
speech_recognition_language = "de-DE"
However, I could not find how to change the "speech_synthesis_language" parameter, which I found in the python documentation to "get" the synthesis language.
This parameter cannot be passed into speechsdk.SpeechConfig().
As a result, the text to speech service still uses English to speak out the German text.
The code I am using is from quickstart: https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/quickstarts/text-to-speech?tabs=dotnet%2Clinux%2Cjre&pivots=programming-language-python
Hi @irishun,
One way to change the synthesis language it is to set the property value on the speech_config instance:
synthesis_lang_prop_id = SpeechServiceConnection_SynthLanguage
speech_config.set_property(synthesis_lang_prop_id , "de-DE")
This is the API that I'm referring to that will set the property and here is the property ids. Please let me know if this works that so I can close this issue. Thank you
Hi @IEvangelist ,
thank you for the reply.
I saw that SpeechServiceConnection_SynthLanguage is in azure.cognitiveservices.speech.PropertyId.
But I am not sure how to use it correctly.
Here is what I tried:
from azure.cognitiveservices.speech import Propertyid
synthesis_lang_prop_id = Propertyid.SpeechServiceConnection_SynthLanguage
And I got an error of:
ImportError: cannot import name 'Propertyid' from 'azure.cognitiveservices.speech'
If I just add
synthesis_lang_prop_id = SpeechServiceConnection_SynthLanguage
speech_config.set_property(synthesis_lang_prop_id , "de-DE")
I got an error of:
NameError: name 'SpeechServiceConnection_SynthLanguage' is not defined
In all honesty, I'm not a Python expert. Could you try this, and in the meantime I'll connect with someone who is more advanced? Notice that there is an overload for the setProperty function that takes a string.
speech_config.set_property("SpeechServiceConnection_SynthLanguage", "de-DE")
Please let me know if this works so that I can close this issue. Thank you
Hi David, thank you for your reply.
Unfortunately, after changing the code I still got an error:
TypeError: property_id value must be PropertyId instance
Ah, I just realized that the method name is different. Try this:
speech_config.set_property_by_name("SpeechServiceConnection_SynthLanguage", "de-DE")
Please let me know if this works so that I can close this issue. Thank you
Thanks David,
speech_config.set_property_by_name("SpeechServiceConnection_SynthLanguage", "de-DE")
does not through an error!
But the speech_synthesizer still pronounces in the default language (English).
@irishun Could you please set the voice name using set_voice_name()
I have tried the same using the rest API sample which generated a file with german voice de-DE-Stefan-Apollo
sample-20200305-1044.zip
Hi Rohit,
Thank you for your reply.
I cannot use set_voice_name() to set the voice to German,
But if I don't use Quick Start code and take the code from the sample you provided, I can get the speech of other languages
You might need to have the de-DE language package installed on your machine. For example, after setting the voice and setting the language property... it should work. Also, have you verified that you're using a valid region?
@irishun We hope the above steps helped you use the required voice for speech synthesis.
We will now proceed to close this thread. If there are further questions regarding this matter, please tag @RohitMungi-MSFT in your reply.