Spaces:
Runtime error
Runtime error
File size: 601 Bytes
11934c6 02b79f6 11934c6 |
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 27 |
import gradio as gr
import sentencepiece as spm
import ctranslate2
description = "Translator"
title = "Translate!"
translator = ctranslate2.Translator("./", device="cpu")
spm_encoder = spm.SentencePieceProcessor("./en.spm.model")
spm_decoder = spm.SentencePieceProcessor("./ku.spm.model")
def translate(text):
tokens = spm_encoder.encode(text, out_type=str)
result = translator.translate_batch([tokens])
output = spm_decoder.decode(result[0].hypotheses[0], out_type=str)
return output
iface = gr.Interface(
translate,
inputs="text",
outputs="text"
)
iface.launch() |