pndurette / gTTS

Python library and CLI tool to interface with Google Translate's text-to-speech API
http://gtts.readthedocs.org/
MIT License
2.32k stars 361 forks source link

ValueError: Unable to find token seed! Did https://translate.google.com change? #232

Closed Mohammed-Shoaib closed 3 years ago

Mohammed-Shoaib commented 4 years ago

After I send 10-15 requests, I get the following error:

Traceback (most recent call last):
  File "text_to_speech.py", line 25, in <module>
    text_to_speech(data)
  File "text_to_speech.py", line 17, in text_to_speech
    tts.save(f'audio/{key}/def-{i + 1}.mp3')
  File "/home/shoaib/anaconda3/lib/python3.7/site-packages/gtts/tts.py", line 111, in save
    self.write_to_fp(f)
  File "/home/shoaib/anaconda3/lib/python3.7/site-packages/gtts/tts.py", line 124, in write_to_fp
    'tk' : self.token.calculate_token(part)}
  File "/home/shoaib/anaconda3/lib/python3.7/site-packages/gtts_token/gtts_token.py", line 28, in calculate_token
    seed = self._get_token_key()
  File "/home/shoaib/anaconda3/lib/python3.7/site-packages/gtts_token/gtts_token.py", line 59, in _get_token_key
    "Unable to find token seed! Did https://translate.google.com change?"
ValueError: Unable to find token seed! Did https://translate.google.com change?

I thought this might be a bug in the latest release, i.e., 2.1.1 so I tried 1.2.0 and I still get the same error.

I also thought it could be that my IP address is being blocked. I read up on the Quotas & limits and I don't think that should be an issue as well.

System information:

Thank you for your timely help. :relaxed: :sparkles:

mkanet commented 3 years ago

Please forgive my ignorance. I am getting this error when using the below card:

entity: media_player.living_room_speaker
hold_action:
action: none
show_icon: true
show_name: true
tap_action:
action: call-service
service: tts.google_translate_say
service_data:
    entity_id: media_player.living_room_speaker
    message: Please remember to close the back door!
type: entity-button

However, I am still able to make the same device talk successfully by using below:

Call Service:  tts.google_translate_say
entity_id: media_player.living_room_speaker
message: Please remember to close the back door!

I'm curious why does one work, but not the other? They are both making my Google Nest speak. Will I be able to use the card that's failing now in an upcoming Home Assistant version without changing anything in my configuration?

pndurette commented 3 years ago

Just closing this, as it was kept for discussion after the issue was fixed and then bit of an HA direction talk but it's starting to derail a bit.

So cool to see this go to HA, thanks for your work all. I'll sure try to contribute when I can!

Hasibulkarimratul commented 3 years ago

Has the Error been fixed? Should I just upgrade gTTS ans gTTS-token?

MandarJKulkarni commented 3 years ago

Has the Error been fixed? Should I just upgrade gTTS ans gTTS-token?

Upgrading the versions worked for me.

rajveer01 commented 3 years ago

Uninstall and Reinstall of gTTS worked For me.

ak-115 commented 3 years ago

Happening with me also, using Python 3.9 on Windows 10. Used this library before and not issues, check the code here: https://github.com/afonsosantos/alexis/blob/master/main.py

The error:

Traceback (most recent call last):
  File "C:\Users\afons\Desktop\pyvoice\pyVoice\main.py", line 25, in <module>
    respond(voice_data)
  File "C:\Users\afons\Desktop\pyvoice\pyVoice\main.py", line 9, in respond
    date()
  File "C:\Users\afons\Desktop\pyvoice\pyVoice\commands\date_time.py", line 9, in date
    speak('A data de hoje é ' + str(today_date))
  File "C:\Users\afons\Desktop\pyvoice\pyVoice\utils\audio.py", line 51, in speak
    tts.save(audio_file)
  File "C:\Users\afons\Desktop\pyvoice\pyVoice\venv\lib\site-packages\gtts\tts.py", line 295, in save
    self.write_to_fp(f)
  File "C:\Users\afons\Desktop\pyvoice\pyVoice\venv\lib\site-packages\gtts\tts.py", line 251, in write_to_fp
    prepared_requests = self._prepare_requests()
  File "C:\Users\afons\Desktop\pyvoice\pyVoice\venv\lib\site-packages\gtts\tts.py", line 194, in _prepare_requests
    part_tk = self.token.calculate_token(part)
  File "C:\Users\afons\Desktop\pyvoice\pyVoice\venv\lib\site-packages\gtts_token\gtts_token.py", line 28, in calculate_token
    seed = self._get_token_key()
  File "C:\Users\afons\Desktop\pyvoice\pyVoice\venv\lib\site-packages\gtts_token\gtts_token.py", line 58, in _get_token_key
    raise ValueError(
ValueError: Unable to find token seed! Did https://translate.google.com change?

EDIT: after some analysis, seems to be crashing on the tts.save line as below:

image

bro the same is happening with me tooo I guess there is a server problem from gtts site

Shivampurbia commented 3 years ago

tried uninstalling and installing but still the same error.

ibelgin commented 3 years ago

Uninstall and Reinstalling it Helped Me