Azure-Samples / Cognitive-Speech-TTS

Microsoft Text-to-Speech API sample code in several languages, part of Cognitive Services.
https://azure.microsoft.com/en-us/services/cognitive-services/text-to-speech/
Other
892 stars 510 forks source link

How to make it read accented characters in Spanish? #225

Closed Jun711 closed 1 year ago

Jun711 commented 2 years ago

It doesn't seem to be able to read words with accented characters when I send the request using the API endpoint.

However, it works when I use the sdk which uses wss but I don't plan to switch to that at the moment as it requires me to re-configure my server using docker.

I have checked the document on Azure website but there is no example for that.

This is what I used to send the TTS request.

test = "<speak version='1.0' xml:lang='en-us'><voice xml:lang='es-US' xml:gender='Male' name='es-US-AlonsoNeural'><prosody rate="0%">típico de los años</prosody></voice></speak>"
headers = {"Content-type" : "application/ssml+xml",
      "X-Microsoft-OutputFormat" : "riff-24khz-16bit-mono-pcm",
      "Authorization" : "Bearer " + auth_token,
      "Content-length":str(len(text))
  }
res = requests.post("https://westus2.tts.speech.microsoft.com/cognitiveservices/v1", data=text , headers=headers, timeout=29)

Thank you

szhaomsft commented 2 years ago

is it encoding issue? https://stackoverflow.com/questions/708915/detecting-the-character-encoding-of-an-http-post-request

Jun711 commented 2 years ago

@szhaomsft I tried adding charset=UTF-8 but it still doesn't work. These are the headers that I used

headers = {"Content-type" : "application/ssml+xml; charset=UTF-8",
            "X-Microsoft-OutputFormat" : "riff-24khz-16bit-mono-pcm", 
            "Authorization" : "Bearer " + auth_token,
            "Content-length" : str(len(text))
        }