import gradio as gr from textblob import TextBlob def analyze_sentiment(text: str): blob = TextBlob(text) sentiment = blob.sentiment.polarity if sentiment > 0: sentiment_label = 'positive' elif sentiment < 0: sentiment_label = 'negative' else: sentiment_label = 'neutral' return sentiment_label, sentiment iface = gr.Interface(fn=analyze_sentiment, inputs="text", outputs=["text", "number"], title="Sentiment Analysis", description="Enter text to analyze its sentiment. Returns the sentiment label and polarity.") iface.launch(server_name="0.0.0.0", server_port=7860)