Azure-Samples / cognitive-services-speech-sdk

Sample code for the Microsoft Cognitive Services Speech SDK
MIT License
2.85k stars 1.84k forks source link

Ssml should only contain one language. #1659

Closed marosoaie closed 2 years ago

marosoaie commented 2 years ago

I'm trying to use the text to speech API in iOS and I'm getting the following error: Connection was closed by the remote host. Error code: 1007. Error details: Ssml should only contain one language. USP state: 3. Received audio size: 0 bytes.

I used the helloworld sample project in this repo to try the api: (cognitive-services-speech-sdk-master/quickstart/swift/ios/text-to-speech/helloworld). I call the api like this: synthesizer.speakSsml("<speak>Hello world</speak>").

Am I doing something wrong?

I also tried configuring the language and voice explicitly, but I keep getting the same error.

      try speechConfig = SPXSpeechConfiguration(subscription: sub, region: region)
      speechConfig?.speechSynthesisLanguage = "en-US"
      speechConfig?.speechSynthesisVoiceName = "en-US-JennyNeural"
dargilco commented 2 years ago

@marosoaie Per our documentation, you are missing mandatory elements in the SSML string. This is an example of a valid SSML string:

"<speak version='1.0' xml:lang='en-US' xmlns='http://www.w3.org/2001/10/synthesis'><voice name='Microsoft Server Speech Text to Speech Voice (en-US, AriaNeural)'>Hellow World</voice></speak>"
marosoaie commented 2 years ago

@dargilco I’m using the native iOS SDK. It exposes properties like speechSynthesisLanguage and speechSynthesisVoiceName. What is the point of these properties if I need to set the lang and voice name manually in the xml?

yulin-li commented 2 years ago

The speechSynthesisLanguage and speechSynthesisVoiceName only take effect for plain text.