Spaces:
Build error
Build error
File size: 684 Bytes
613e5d1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
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()
|