import gradio as gr from transformers import pipeline # Function for detecting language def detect_language(text): result = language_detector(text) return result[0]['label'] # Define example inputs in multiple languages examples = [ ["Hello, how are you?"], # English ["Bonjour, comment ça va?"], # French ["Hola, ¿cómo estás?"], # Spanish ["مرحبًا كيف حالك؟"], # Arabic ] # Gradio Interface iface = gr.Interface( fn=detect_language, inputs=gr.Textbox(label="Enter Text"), outputs=gr.Textbox(label="Detected Language"), title="Language Detection", description="Enter text in any language, and the model will identify the language.", examples=examples ) # Launch the Gradio app if __name__ == "__main__": iface.launch()