translate-subtitles
translate-subtitles copied to clipboard
ValueError: No JSON object could be decoded
At some point I get this error using google translate option:
Traceback (most recent call last):
File "run.py", line 71, in <module>
translater(sys.argv[1:])
File "run.py", line 67, in translater
s.translate_substitle(subFile, source_language, target_language, translator, max_length)
File "src/subTranslater.py", line 220, in translate_substitle
File "src/subTranslater.py", line 93, in send_google_translator
File "src/goslate.py", line 336, in translate
File "src/goslate.py", line 281, in _translate_single_text
File "src/goslate.py", line 167, in _execute
File "src/goslate.py", line 279, in <lambda>
File "src/goslate.py", line 206, in _basic_translate
File "/usr/lib/python2.7/dist-packages/requests/models.py", line 897, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/lib/python2.7/json/__init__.py", line 339, in loads
return _default_decoder.decode(s)
File "/usr/lib/python2.7/json/decoder.py", line 364, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python2.7/json/decoder.py", line 382, in raw_decode
raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
Is it because of google "banning" too much requests?
I understand you get banned by google because of the amount of requests made? is it possible to send the whole text in the srt and get it translated in one request?
Google translate allows 5000 characters at a time so we can translate regarding this limit. It would be a good feature but need to test this before implementation. Will you volunteer for this?
hey @yeahman45, I released v2 by implementing raw translation via googletranslatepy. If you have time, please check it and feel free to contribute.
The new version translated a long subtitle successfully.
1420
01:38:46,208 --> 01:38:51,583
<i>Devam et, biz ışık
Atış, kalp devam ediyor</i>
1421
01:38:55,208 --> 01:39:00,541
<i>Devam et, biz ışık</i>
<i>Atım, kalp devam ediyor</i>
Translated by subtitle_translator via google translator
written by Mesut Gunes: https://github.com/gunesmes/subtitle_translator
New file name: /Users/mesutgunes/Projects/personal/subtitle_translator/An.Unforgettable.Year.Autumn.2023_en_to_tr.srt
Duration: 0:12:46.338071