Alyaboelnasr's picture
Create app.py
b3d1e71 verified
raw
history blame contribute delete
541 Bytes
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()