import gradio as gr from transformers import pipeline import torch # Load sentiment analysis models english_sentiment_model = pipeline("sentiment-analysis", model="nlptown/bert-base-multilingual-uncased-sentiment") arabic_sentiment_model = pipeline("sentiment-analysis", model="akhooli/arabic-sentiment") def analyze_sentiment(text, language): if language == "English": result = english_sentiment_model(text) else: result = arabic_sentiment_model(text) return result[0]['label'], result[0]['score'] # Create Gradio interface iface = gr.Interface( fn=analyze_sentiment, inputs=[ gr.inputs.Textbox(label="Enter text"), gr.inputs.Radio(choices=["English", "Arabic"], label="Select Language") ], outputs=[ gr.outputs.Label(label="Sentiment"), gr.outputs.Number(label="Confidence Score") ], title="Sentiment Analysis", description="Analyze the sentiment of text in English and Arabic." ) iface.launch()