diff --git a/extensions/google-translate/requirements.txt b/extensions/google-translate/requirements.txt new file mode 100644 index 00000000..8b0d4f19 --- /dev/null +++ b/extensions/google-translate/requirements.txt @@ -0,0 +1 @@ +googletrans==3.1.0a0 diff --git a/extensions/google-translate/script.py b/extensions/google-translate/script.py new file mode 100644 index 00000000..aa388110 --- /dev/null +++ b/extensions/google-translate/script.py @@ -0,0 +1,22 @@ +from googletrans import Translator + +translator = Translator() + +params = { + "language string": "ja", +} + +def input_modifier(string): + """ + This function is applied to your text inputs before + they are fed into the model. + """ + + return translator.translate(string, dest='en').text + +def output_modifier(string): + """ + This function is applied to the model outputs. + """ + + return translator.translate(string, dest=params['language string']).text