Spaces:
Sleeping
Sleeping
File size: 541 Bytes
b3d1e71 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
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() |