import gradio as gr from textblob import TextBlob def analyze_sentiment(text): blob = TextBlob(text) sentiment = blob.sentiment.polarity if sentiment > 0: color = "green" label = "Positive" elif sentiment < 0: color = "red" label = "Negative" else: color = "yellow" label = "Neutral" return color, label def sentiment_analysis(text): color, label = analyze_sentiment(text) return "

{} Sentiment

".format(color, label) iface = gr.Interface( fn=sentiment_analysis, inputs=gr.inputs.Textbox(lines=5, label="Enter Text"), outputs="html" ) iface.launch()