news-summarize / app.py
Manishkumaryadav's picture
Upload 8 files
706ec74 verified
raw
history blame
2.03 kB
import streamlit as st
import requests
import os
import pandas as pd
BACKEND_URL = "http://127.0.0.1:5000/analyze"
st.title("πŸ“Š News Sentiment Analysis & TTS in Hindi")
# Input field for company name
company_name = st.text_input("Enter Company Name", "")
if st.button("Analyze"):
if not company_name:
st.warning("⚠️ Please enter a company name.")
else:
st.info(f"Analyzing news for {company_name}...")
response = requests.post(
BACKEND_URL,
json={"company_name": company_name}
)
if response.status_code == 200:
data = response.json()
st.success("βœ… Analysis Complete!")
# βœ… Display Sentiment Summary
st.subheader("πŸ“Š Sentiment Summary")
st.json(data["sentiment_summary"])
# βœ… Display Articles
st.subheader("πŸ“° Extracted Articles")
df = pd.DataFrame(data["articles"])
for _, article in df.iterrows():
st.markdown(f"### [{article['title']}]({article['url']})")
st.write(f"**Summary:** {article['summary']}")
st.write("---")
# βœ… Display Hindi TTS Audio
st.subheader("πŸ”Š Hindi TTS Audio Output")
audio_file = "output/TestCompany_tts.mp3"
if os.path.exists(audio_file):
with open(audio_file, "rb") as audio:
st.download_button(
label="πŸ”Š Download Hindi TTS Audio",
data=audio,
file_name="Hindi_TTS.mp3",
mime="audio/mpeg"
)
st.audio(audio_file, format="audio/mp3")
st.success("βœ… Hindi TTS audio displayed successfully!")
else:
st.error("❌ TTS file not found.")
else:
st.error("❌ Error analyzing news. Please try again.")