import gradio as gr from transformers import pipeline # Initialize the language detection pipeline language_detector = pipeline("text-classification", model="papluca/xlm-roberta-base-language-detection") # Function to detect language def detect_language(sentence): result = language_detector(sentence) return result[0]['label'] # Gradio interface iface = gr.Interface( fn=detect_language, inputs=gr.Textbox(label="Input Sentence"), outputs=gr.Textbox(label="Detected Language") ) # Launch the interface iface.launch()