Spaces:
Sleeping
Sleeping
Delete app.py
Browse files
app.py
DELETED
@@ -1,62 +0,0 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
import requests
|
3 |
-
import pandas as pd
|
4 |
-
|
5 |
-
# β
Replace with your Hugging Face backend URL
|
6 |
-
# β
Use the deployed backend Space URL
|
7 |
-
BACKEND_URL = "https://manishkumaryadav-news-summarize.hf.space/analyze"
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
st.title("π News Sentiment Analysis & TTS in Hindi")
|
12 |
-
|
13 |
-
# Input field for company name
|
14 |
-
company_name = st.text_input("Enter Company Name", "")
|
15 |
-
|
16 |
-
if st.button("Analyze"):
|
17 |
-
if not company_name:
|
18 |
-
st.warning("β οΈ Please enter a company name.")
|
19 |
-
else:
|
20 |
-
st.info(f"π Analyzing news for {company_name}...")
|
21 |
-
|
22 |
-
# Send request to Flask backend
|
23 |
-
response = requests.post(
|
24 |
-
BACKEND_URL,
|
25 |
-
json={"company_name": company_name}
|
26 |
-
)
|
27 |
-
|
28 |
-
if response.status_code == 200:
|
29 |
-
data = response.json()
|
30 |
-
|
31 |
-
st.success("β
Analysis Complete!")
|
32 |
-
|
33 |
-
# β
Display Sentiment Summary
|
34 |
-
st.subheader("π Sentiment Summary")
|
35 |
-
st.json(data["sentiment_summary"])
|
36 |
-
|
37 |
-
# β
Display Articles
|
38 |
-
st.subheader("π° Extracted Articles")
|
39 |
-
|
40 |
-
df = pd.DataFrame(data["articles"])
|
41 |
-
|
42 |
-
for _, article in df.iterrows():
|
43 |
-
st.markdown(f"### [{article['title']}]({article['url']})")
|
44 |
-
st.write(f"**Summary:** {article['summary']}")
|
45 |
-
st.write("---")
|
46 |
-
|
47 |
-
# β
Display Hindi TTS Audio
|
48 |
-
st.subheader("π Hindi TTS Audio Output")
|
49 |
-
|
50 |
-
audio_file_url = f"{BACKEND_URL}/{data['audio_file']}"
|
51 |
-
|
52 |
-
st.audio(audio_file_url, format="audio/mp3")
|
53 |
-
|
54 |
-
st.download_button(
|
55 |
-
label="β¬οΈ Download Hindi TTS Audio",
|
56 |
-
data=requests.get(audio_file_url).content,
|
57 |
-
file_name=f"{company_name}_TTS.mp3",
|
58 |
-
mime="audio/mpeg"
|
59 |
-
)
|
60 |
-
|
61 |
-
else:
|
62 |
-
st.error("β Error analyzing news. Please try again.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|