gTTS: Token: regexp never finds anything
Hello,
I know the code yielding this error is not in this repository but the gtts-token repository seems inactive…
Since a few hours ago it seems that one of the regular expressions when searching “TKK=‘integer.integer’;” in Google Translate HTTP response doesn’t find anything.
Here is my Traceback:
gtts-cli 'hello' --output hello.mp3
Traceback (most recent call last):
File "/usr/local/bin/gtts-cli", line 9, in <module>
load_entry_point('gTTS==2.0.1', 'console_scripts', 'gtts-cli')()
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/gtts/cli.py", line 194, in tts_cli
tts.write_to_fp(output)
File "/usr/local/lib/python2.7/dist-packages/gtts/tts.py", line 187, in write_to_fp
part_tk = self.token.calculate_token(part)
File "/usr/local/lib/python2.7/dist-packages/gtts_token/gtts_token.py", line 28, in calculate_token
seed = self._get_token_key()
File "/usr/local/lib/python2.7/dist-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'
Is it possible this is caused by a modification in Google Translate HTTP response? I tried with other google translate python apps and they also fail to find the token…
Best regards, Thomas
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 2
- Comments: 32 (6 by maintainers)
Commits related to this issue
- This fixes pndurette/gTTS#137 — committed to ilevn/gTTS-token by ilevn 6 years ago
gTTS-token 1.1.2 has just been released. Thanks a lot for the work everyone. It’s good to see something I’ve created years ago still being cared about.
That’s hard to say as this exception is the result of a faulty regex handler in another repo (for which I’ve submitted a pull request for) that is rather inactive as of now.
However, in the meantime you can monkey-patch the affected function like so:
I hope that helps.
I’m not expert in reg expression so i change like this and working now
/usr/local/lib/python2.7/dist-packages/gtts_token/gtts_token.py comment 3 line and add 6 line
etc. I have another Google Text-to-Speech app develop by delphi I this not change anything now my app still work
I just wanted to drop by and say that I’ve provided a regex based solution that is both faster and cleaner compared to regular list indexing.
Cheers
Thank You for the solution Its working now
Try this… It works now.
Worked on code by @ilevn Thanks @ilevn
When will this be fixed in gTTS Eg:- in pip3 install gTTS
Yes It is not working for me too…
Stopped working for me too over night, glad I’m not the only one