Manishkumaryadav commited on
Commit
c7a5805
Β·
verified Β·
1 Parent(s): 89f3839

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +62 -0
app.py CHANGED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.")