When using the Microsoft TTS engine with another configuration than the default, Home Assistant returns an error when trying to synthesize:
[pycsspeechtts.pycsspeechtts] Text synthesis failed, statuscode 400, reason:
[homeassistant.components.tts] Error on init TTS: No TTS from microsoft for 'test'
configuration.yamltts:
- platform: microsoft
api_key: <HIDDEN>
region: westeurope
language: nl-nl
gender: Female
type: ColetteNeural
pitch: "default"
rate: "0"
volume: "0"
contour: "(0%,+0%) (100%,+0%)"
After debugging /usr/local/lib/python3.8/site-packages/pycsspeechtts/pyspeechtts.py I noticed the issue is caused by this line of code:
voice.set(
'name', 'Microsoft Server Speech Text to Speech Voice ('+language+', '+voiceType+')')
In the latest version of pyspeechtts.py at https://github.com/jeroenterheerdt/pycsspeechtts, a new function was added and used:
Function to uppercase the country code in the language:
def name_lang(language):
lang1,lang2 = language.split("-")
return "{}-{}".format(lang1,lang2.upper())
Function used:
voice.set(
'name', 'Microsoft Server Speech Text to Speech Voice ('+name_lang(language)+', '+voiceType+')')
Applying this to pyspeechtts.py resolves the problem I encountered. TTS is now correctly synthesizing Dutch text using Microsoft Azure TTS.
Is it possible to bring the latest version of pycsspeechtts to Home Assistant?
microsoft documentation
microsoft source
(message by IssueLinks)
Verified this to be a problem in the dependency, requested new package ^ with @jeroenterheerdt as the issue has already been fixed in the code. Changes as mentioned in the start of this issue do solve the problem.
Just pushed a new package to pypi: https://pypi.org/project/pycsspeechtts/.
Most helpful comment
Just pushed a new package to pypi: https://pypi.org/project/pycsspeechtts/.