translator / app.py
shaaravpawar's picture
Update app.py
dcc5243 verified
raw
history blame contribute delete
488 Bytes
import gradio as gr
from transformers import pipeline
# Create a translation pipeline
translator = pipeline('translation', model='google/t5-small')
def translate_text(text):
# Use the pipeline to translate text
translation = translator(text, max_length=512)
return translation[0]['translation_text']
# Create the Gradio interface
iface = gr.Interface(fn=translate_text, inputs='text', outputs='text', title='Text Translator')
if __name__ == "__main__":
iface.launch()