Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from transformers import pipeline | |
| # Load the sentiment analysis, keyword extraction, and text summarization models from Hugging Face | |
| sentiment_model = pipeline("sentiment-analysis") | |
| summarizer = pipeline("summarization", model="knkarthick/MEETING_SUMMARY") | |
| keyword_extraction_model = pipeline( | |
| "text2text-generation", model="transformer3/keywordextractor" | |
| ) | |
| # Define the function to be called when text input is provided | |
| def analyze_text(text): | |
| # Sentiment analysis | |
| sentiment_result = sentiment_model(text)[0] | |
| sentiment = sentiment_result["label"] | |
| sentiment_score = sentiment_result["score"] | |
| summary = summarizer(text, max_length=130, min_length=30, do_sample=False) | |
| # Keyword extraction | |
| keyword_result = keyword_extraction_model( | |
| f"summarize: {text}", max_length=50, num_return_sequences=1 | |
| ) | |
| keywords = keyword_result[0] | |
| # # Text summarization | |
| summary = summarizer(text, max_length=130, min_length=30, do_sample=False) | |
| return f"Sentiment: {sentiment}, Score: {sentiment_score}\nKeywords: {keywords}\nSummary: {summary}" | |
| # return { | |
| # "sentiment": sentiment, | |
| # "sentiment_score": sentiment_score, | |
| # "keywords": keywords, | |
| # "summary": summary, | |
| # } | |
| # Create the Gradio interface | |
| iface = gr.Interface(fn=analyze_text, inputs="text", outputs="text") | |
| # Launch the interface | |
| iface.launch() | |