gradio-space / main.py
broadfield-dev's picture
Initial Space setup of broadfield-dev/gradio-space via Builder
38ea22f verified
raw
history blame contribute delete
549 Bytes
# Import necessary libraries
import gradio as gr
from transformers import pipeline
import json
# Load the French translation pipeline
french_pipeline = pipeline("translation_en_to_fr")
# Define the app
def translate(text):
# Translate the input text using the pipeline
output = french_pipeline(text, max_length=50, truncation=True)
return output[0]['translation_text']
# Create the app interface
app = gr.Interface(fn=translate, inputs="text", outputs="text", title="English to French Text Translator")
# Launch the app
app.launch()