# 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()