Proba_Nos / app.py
JJFrancisco's picture
Update app.py
20d2de6 verified
raw
history blame
597 Bytes
import gradio as gr
import subprocess
def translate(input_text):
command = f"onmt_translate -src {input_text} -model NOS-MT-OpenNMT-en-gl --output ./output_file.txt --replace_unk -gpu 0"
process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = process.communicate()
if process.returncode != 0:
raise Exception(f"Error occurred: {stderr.decode().strip()}")
return stdout.decode().strip()
demo = gr.Interface(fn=translate, inputs="textbox", outputs="textbox")
if __name__ == "__main__":
demo.launch()