XUnity.AutoTranslator compatible REST Service powered by HuggingFace Transformers
Install poetry: https://python-poetry.org/docs/
- Install required dependencies
poetry install-
Change the model name at
mtlapi/constants/language.pyand add language mapping as required atmtlapi/constants/language.py -
Start the server
poetry run dev- Edit the AutoTranslatorConfig.ini for XUnity.AutoTranslator (usually at
config/AutoTranslatorConfig.ini)
[Service]
Endpoint=CustomTranslate
[Custom]
Url=http://localhost:8000/translate
EnableShortDelay=False
DisableSpamChecks=False
You can configure the language mapping in the mtlapi/constants/language.py file, but only if the model requires it. The dict key comes from the XUnity.AutoTranslator Config, which the service parsed from the request sent by AutoTranslator based on the AutoTranslatorConfig.ini configuration:
[General]
Language=en
FromLanguage=zh
and the value is based on the language mapped into the model. By default the value is mapped to Meta AI's NLLB 200. MarianMT based models do not require this for inference so you can just ignore it completely.