OneRingTranslator icon indicating copy to clipboard operation
OneRingTranslator copied to clipboard

[Feature Request] pip package

Open Cohee1207 opened this issue 1 year ago • 1 comments

Hi there,

Following up on the pull request for SillyTavern, I really liked your project and wondering if you could wrap it into a pip package so the translation service could be installed to any Python project. I would like including it into my ST-Extras project (https://github.com/SillyTavern/SillyTavern-extras) as an optional module to make a one-click install for users of ST and colabs.

If you need examples, here's Silero TTS server that was possible to be integrated thanks to that: https://github.com/ouoertheo/silero-api-server

Best wishes.

Cohee1207 avatar Jun 19 '23 12:06 Cohee1207

Hi! Thanks for request, and for SillyTavern stuff! :)

About pip package - I'm not really sure about it. One of core functions as I feel it's to add your own plugins and edit their options - and in this case you must have access to folder structure. And I just no good at pip packages making...

On other hand, there is two ways:

  • There are already cool pip package if you wanna have access to different online translators almost at no cost: https://pypi.org/project/deep-translator/ Somewhere I just use it's functions.

  • You can just integrate OneRingTranslator in SillyTaverns-extras, if you want. It's as easy as:

    • Copy jaa.py and oneringcore.py to your root project folder
    • Copy plugins folder (with translation plugins you feel you need)

just somewhere run (I've just copied relevant fragments from run_webapi.py file):

core = OneRingCore()
core.init_with_plugins()

def translate(text:str, from_lang:str = "", to_lang:str = "", translator_plugin:str = "", add_params:str = ""):
    if translator_plugin == "":
        translator_plugin = core.default_translator
    res = core.translators[translator_plugin][1](core,text,from_lang,to_lang,add_params)

That's all!

I will think about pip package later, but not sure I'll make it good...

janvarev avatar Jun 19 '23 12:06 janvarev