Core: pycsspeechtts: incorrect language formatting

Created on 4 Nov 2020  路  3Comments  路  Source: home-assistant/core

The problem

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'

Environment

  • Home Assistant Core release with the issue: confirmed on 1.116 and 1.117 (up to 1.117.2)
  • Last working Home Assistant Core release (if known): unknown
  • Operating environment (OS/Container/Supervised/Core): OS
  • Integration causing this issue: TTS / Microsoft / pycsspeechtts
  • Link to integration documentation on our website: https://www.home-assistant.io/integrations/microsoft/

Problem-relevant configuration.yaml

tts:
  - 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%)"

Traceback/Error logs

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.

Additional information

Is it possible to bring the latest version of pycsspeechtts to Home Assistant?

microsoft

Most helpful comment

Just pushed a new package to pypi: https://pypi.org/project/pycsspeechtts/.

All 3 comments

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/.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Bergasha picture Bergasha  路  176Comments

balloob picture balloob  路  371Comments

rschaeuble picture rschaeuble  路  230Comments

McGiverGim picture McGiverGim  路  124Comments

gieljnssns picture gieljnssns  路  277Comments