Spaces:
Sleeping
Sleeping
import streamlit as st | |
import requests | |
import pandas as pd | |
# β Replace with your Hugging Face backend URL | |
# β Use the deployed backend Space URL | |
BACKEND_URL = "https://manishkumaryadav-news-summarize.hf.space/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}...") | |
# Send request to Flask backend | |
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_url = f"{BACKEND_URL}/{data['audio_file']}" | |
st.audio(audio_file_url, format="audio/mp3") | |
st.download_button( | |
label="β¬οΈ Download Hindi TTS Audio", | |
data=requests.get(audio_file_url).content, | |
file_name=f"{company_name}_TTS.mp3", | |
mime="audio/mpeg" | |
) | |
else: | |
st.error("β Error analyzing news. Please try again.") | |