import streamlit as st import feedparser from transformers import pipeline st.set_page_config(page_title="🇮🇳 BharatPulse", layout="wide") # Load summarizer @st.cache_resource def load_summarizer(): return pipeline("summarization", model="facebook/bart-large-cnn") summarizer = load_summarizer() # News source NEWS_FEEDS = { "NDTV": "https://feeds.feedburner.com/ndtvnews-top-stories", "India Today": "https://www.indiatoday.in/rss/home", "The Hindu": "https://www.thehindu.com/news/national/feeder/default.rss" } # Title st.title("🇮🇳 BharatPulse") st.subheader("Live News Feeds & Public Sentiment Collector (MVP)") # News source selection source = st.selectbox("📰 Choose News Source", list(NEWS_FEEDS.keys())) feed = feedparser.parse(NEWS_FEEDS[source]) st.markdown("### 🗞️ Latest News Headlines from India") for entry in feed.entries[:5]: st.write(f"**🗞️ {entry.title}**") st.write(entry.published) st.markdown(f"[Read more]({entry.link})", unsafe_allow_html=True) if st.button(f"🔍 Summarize: {entry.title}"): with st.spinner("Summarizing..."): summary = summarizer(entry.summary[:1024], max_length=100, min_length=30, do_sample=False)[0]['summary_text'] st.success(summary) st.markdown("---") # Public Sentiment Collector st.markdown("## 📣 Share Your Voice – Public Sentiment Collector") with st.form("sentiment_form"): name = st.text_input("Your Name (Optional)", "") region = st.text_input("Your Region / State") language = st.text_input("Language") topic = st.text_input("Topic") sentiment = st.radio("Sentiment", ["Positive", "Negative", "Neutral"]) message = st.text_area("Your Message (in your local language or English)") submitted = st.form_submit_button("Submit") if submitted: st.success("✅ Thank you for sharing your opinion!") st.markdown(f"**Name:** {name or 'Anonymous'}") st.markdown(f"**Region:** {region}, **Language:** {language}, **Topic:** {topic}") st.markdown(f"**Sentiment:** {sentiment}") st.markdown(f"**Message:** {message}")