Google TTS Problems

Has Google just change something in there Google Home/Mini as my TTS has stopped working.
I am on 0.76.2

2018-09-21 22:04:06 ERROR (MainThread) [homeassistant.core] Error executing service <ServiceCall tts.google_say (c:d167fde88c8f40838831a3957cbbb8cd): message=Its 10:04., entity_id=['media_player.google_home', 'media_player.google_kitchen']>
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/core.py", line 1117, in _event_to_service_call
    await service_handler.func(service_call)
  File "/usr/src/app/homeassistant/components/tts/__init__.py", line 134, in async_say_handle
    options=options
  File "/usr/src/app/homeassistant/components/tts/__init__.py", line 300, in async_get_url
    engine, key, message, use_cache, language, options)
  File "/usr/src/app/homeassistant/components/tts/__init__.py", line 313, in async_get_tts_audio
    message, language, options)
  File "/usr/src/app/homeassistant/components/tts/google.py", line 83, in async_get_tts_audio
    token.calculate_token, part)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/gtts_token/gtts_token.py", line 28, in calculate_token
    seed = self._get_token_key()
  File "/usr/local/lib/python3.6/site-packages/gtts_token/gtts_token.py", line 62, in _get_token_key
    a = re.search("a\\\\x3d(-?\d+);", tkk_expr).group(1)
AttributeError: 'NoneType' object has no attribute 'group'

I see there is a fix coming in 0.78.2 or 0.79 but i dont want to upgrade to them as i use Node Red and the api_password wont work with the new Auth.

Also i see that there is problems with Deconz and Google cast on the latest versions.

Any Help Thanks.

1 Like

Please search/browse forum/github/discord before you ask.

Don’t you think I have done that.

I have looked here.

Here

Here

1 Like

@cameron if you search on Discord you will get all teh answers you want about the TTS issue. Also don’t be afraid to upgrade the api password and auth are non breaking changes, they even mentioned that in the release notes.

Thanks @dshokouhi
I found this on Discord and it took me to this

I’ll have to wait and updated to 0.78.3 to get Google TTS fix.

So I’ve read through Discord and GitHub all morning on this issue but am as confused as I was at the start. I see the GTTS token has to be bumped top 1.1.2 in the google_token.py file but I am unsure how one actually gets to that file or am I wasting my time and I just need to wait til the next update comes out??

Use wget or whatever d/l tool you need and grab this https://github.com/home-assistant/home-assistant/files/2406996/gtts_token.zip and put it in your custom_components folder. Unzip it and it will pull out 2 folders. Restart HA and you’re off to the races with working TTS until 78.3 comes out and fixes this. Enjoy!

2 Likes

I can confirm that the fix from here works. The process I followed on Hassbian to fix this was;

cd /srv/homeassistant
sudo python3 -m venv .
source bin/activate
sudo nano /srv/homeassistant/lib/python3.5/site-packages/gtts_token/gtts_token.py

Delete and add in the new text as shown in the link provided, reboot you Pi, fixed.

Awesome, thanks so much for that info. TTS back up and working like a gem!!

Time for a beer I think!

1 Like

Thanks Guys
That works great :+1::beer::beer:

I used the add to custom_components way. @TheFuzz4.:grin:

What issues are you seeing with deconz?

I’ve verified that with 78.3 that my TTS is back to working as it should. Don’t forget that once you upgrade to remove those tts folders that were unpacked from that zip if you used that method.

1 Like

I cant get it to work?..
Have replace the lines…
And I also see that it creates a new mp3 file in tts folder, but it wont play it on the speakers

Starting today Nov 29:th I get the exact same problem as OP. I’m using latest Hass.io v140 with HASS 0.82.1 and this has been working flawlessly for weeks until today. Has token expired again? Is anyone else experiencing this?

got the same today as well…ugh!!
I’m on Hassbian though

Here’s the traceback:

    2018-11-29 17:00:11 ERROR (MainThread) [homeassistant.core] Error executing service <ServiceCall tts.google_say (c:6ec27b9f9a3448e38d4e355e5c25ddf6): entity_id=['media_player.srsx77_mist_2'], message=Klockan är 17:00 och det är 1 grader ute., cache=False>
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/core.py", line 1177, in _event_to_service_call
    await service_handler.func(service_call)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/tts/__init__.py", line 137, in async_say_handle
    options=options
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/tts/__init__.py", line 306, in async_get_url
    engine, key, message, use_cache, language, options)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/tts/__init__.py", line 318, in async_get_tts_audio
    message, language, options)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/tts/google.py", line 83, in async_get_tts_audio
    token.calculate_token, part)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/gtts_token/gtts_token.py", line 28, in calculate_token
    seed = self._get_token_key()
  File "/usr/local/lib/python3.6/site-packages/gtts_token/gtts_token.py", line 57, in _get_token_key
    tkk_expr = re.search(".*?(TKK=.*?;)W.*?", line).group(1)
AttributeError: 'NoneType' object has no attribute 'group'

Looks like Google Translate changed some stuff. Fix of gtts-token seems to be worked on: https://github.com/Boudewijn26/gTTS-token/pulls

1 Like

Thanx bro… it now works… applied th changes as per your link

This error seems to affect quite a lot of people, looking forward to early patches, thanks to the programmer