Tuesday, July 19, 2022

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

  • รัน python3 แล้ว exception ประมาณนี้ ซึ่งก่อนหน้านี้ โค้ดนี้ใช้ได้อยู่นะ
  • แต่ทำไมวันนี้มัน exception หว่า   

$ python3 text_file_to_speech.py 

Traceback (most recent call last):

  File "text_file_to_speech.py", line 18, in <module>

  myobj.save("./audios/output.mp3") 

  File "/usr/lib/python3/dist-packages/gtts/tts.py", line 295, in save

    self.write_to_fp(f)

  File "/usr/lib/python3/dist-packages/gtts/tts.py", line 251, in write_to_fp

    prepared_requests = self._prepare_requests()

  File "/usr/lib/python3/dist-packages/gtts/tts.py", line 194, in _prepare_requests

    part_tk = self.token.calculate_token(part)

  File "/usr/lib/python3/dist-packages/gtts_token/gtts_token.py", line 28, in calculate_token

    seed = self._get_token_key()

  File "/usr/lib/python3/dist-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?

Solved
pip3 install gTTS-token --upgrade
pip3 install gTTS --upgrade
Add
  • ติดตั้ง pip ถ้าไม่มี
  • สำหรับ python2
sudo apt install python-pip
  • สำหรับ python3
sudo apt install python3-pip
Ref
  • https://stackoverflow.com/questions/64699071/valueerror-unable-to-find-token-seed-did-https-translate-google-com-change

No comments:

Post a Comment

Popular Posts