Spaces:
Sleeping
Sleeping
import subprocess | |
import gradio as gr | |
from translate import Translator | |
def generate_text(): | |
cmd = ['./run', 'model.bin'] | |
result = subprocess.run(cmd, stdout=subprocess.PIPE, text=True) | |
translator= Translator(from_lang='en', to_lang='zh-cn') | |
# Split the output into sentences | |
sentences = result.stdout.split('. ') | |
# Translate each sentence and join them back together | |
translation = '. '.join(translator.translate(sentence) for sentence in sentences) | |
return translation | |
iface = gr.Interface( | |
fn=generate_text, | |
inputs=[], | |
outputs="text", | |
submit_label="开始生成", | |
title="和小羊驼一起玩" | |
) | |
iface.launch() | |