TenshiTranslator.Translator.OfflineTranslator module¶
- class TenshiTranslator.Translator.OfflineTranslator.OfflineTranslator(outputOption: OutputFormat, preprocessGlossary: Glossary, postProcessGlossary: Glossary, sugoiDirectory: str)¶
Bases:
Translator
Translator that uses sugoi toolkit’s offline translation server.
Files are translated line by line through http requests. This translator requires sugoi toolkit but is faster than the online translator. It is also more accurate as it uses a newer model and has no character limits. The speed of this translator is dependent on your computer’s hardware, and is generally recommended if you don’t have an Nvidia GPU. The object takes around 12 seconds to initialize, as it starts the sugoi offline translator server.
- Parameters:
outputOption – the output format to use
preprocessGlossary – the glossary to use for preprocessing
postProcessGlossary – the glossary to use for postprocessing
sugoiDirectory – the path to the sugoi toolkit
- sendTranslationRequest(japanese: str) str ¶
Translates a string from japanese to english using the sugoi offline translator server
- Parameters:
japanese – the string to be translated
- Returns:
the translated string
- translate(inputFilePath: str)¶
Translates a file and writes to inputFilePath-Translated.txt
- Parameters:
inputFilePath – path to the file to be translated
- Raises:
FileNotFoundError if the file is not found
- Raises:
Exception if any other error occurs