Manishkumaryadav commited on
Commit
95917a1
Β·
verified Β·
1 Parent(s): ce599f4

Create app.py

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