sinedie/SRTranslator

No service has returned a valid result

Closed this issue · 3 comments

It doesn't work for me

script

import os
from srtranslator import SrtFile
#from srtranslator.translators.deepl_api import DeeplApi
#from srtranslator.translators.deepl_scrap import DeeplTranslator
from srtranslator.translators.translatepy import TranslatePy
translator = TranslatePy()
filepath = "/home/alucard/Downloads/film.srt"
srt = SrtFile(filepath)
srt.translate(translator, "nl", "hu")
# Making the result subtitles prettier
srt.wrap_lines()
srt.save(f"{os.path.splitext(filepath)[0]}_translated.srt")

result

[alucard@arch ~/Downloads]$ python translate.py
Loading /home/alucard/Downloads/film.srt
... Translating chunk. 0 %
Traceback (most recent call last):
File "/home/alucard/Downloads/translate.py", line 9, in <module>
srt.translate(translator, "nl", "hu")
File "/home/alucard/.local/lib/python3.11/site-packages/srtranslator/srt_file.py", line 154, in translate
translation = translator.translate(
^^^^^^^^^^^^^^^^^^^^^
File "/home/alucard/.local/lib/python3.11/site-packages/srtranslator/translators/translatepy.py", line 14, in translate
result = self.translator.translate(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/alucard/.local/lib/python3.11/site-packages/translatepy/translate.py", line 135, in translate
raise NoResult("No service has returned a valid result")
translatepy.exceptions.NoResult: No service has returned a valid result

Does not work with other translators...

Arch Linux

Hey!

This is an issue with TranslatePy, it wasn't able to fullfill the translation request. I can't really do much to help. This is a helper to translate .srt files, not really to actually translate it, tho has multiple built-in providers, try another one, probably the most used is DeeplTranslator (not the api, the selinum based).

Hope it works

WORKING!!!!!!!!!!!!

[alucard@arch ~/Downloads]$ python -m srtranslator --translator translatepy film.srt -i en -o hu
Loading film.srt
... Translating chunk. 0 %
... Translation done
Saving film_hu.srt

yeahhh!

deepl api also works. :)