Tts.google_say errors 'NoneType' object has no attribute 'group'

Hi guys, I recently started working with HA (running on RPi 3B+ with raspbian stretch in docker). All worked fine but google tts seems to be broken now.

The error that I get:

Log Details (ERROR)
Fri Sep 21 2018 11:09:16 GMT+0200 (Central European Summer Time)

Error executing service <ServiceCall tts.google_say (c:71c8aa7cb1f24ca5a685bf932de0fe81): entity_id=['media_player.living'], message=test>
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/core.py", line 1127, 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 62, in _get_token_key
    a = re.search("a\\\\x3d(-?\d+);", tkk_expr).group(1)
AttributeError: 'NoneType' object has no attribute 'group'

After searching the web I found a possible solution:
https://github.com/instabot-py/instabot.py/issues/1529
which pointed to this:
https://github.com/instabot-py/instabot.py/commit/806e09414f73a461bdb81fd6d4fc2e1e34a54ef8

Any thoughts on how to do this when using HA in a docker container?

Known issue, possible solution gTTS-token update.

thanks! didn’t find it somehow.

For people who find this topic first. This worked for me:
I went into the console of my HA docker container (I use portainer) and executed:

pip uninstall gTTS-token
pip install gTTS-token

Then restarted HA and tss is working again

This is broken again now, but I have a fix in pull request. A working version of the gtts_token can be found here:

cheers,

Dora

2 Likes

I have been in the process of moving my setup from a Pi at 0.75.1 to a Docker setup on 0.82.1, and I thought I had something messed up in the config for the last hour. Should have searched here first.

Thank you for the update, just used the old custom_component from here, Google TTS Problems and updated the gtts_token.py with your new code for now, and all back working again.