import gradio as gr from transformers import pipeline sentiment_analyzer = pipeline("sentiment-analysis") def analyze_sentiment(text): result = sentiment_analyzer(text)[0] return f"感情: {result['label']}, 確信度: {result['score']:.2f}" iface = gr.Interface( fn=analyze_sentiment, inputs="text", outputs="text", title="簡単な感情分析", description="テキストを入力して、その感情を分析します。" ) iface.launch()