File size: 802 Bytes
ace915b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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()