Spaces:
Sleeping
Sleeping
Commit
·
76d8129
1
Parent(s):
40aea7b
Fixed errors and conflicts
Browse files- __pycache__/api.cpython-312.pyc +0 -0
- __pycache__/scrapes.cpython-312.pyc +0 -0
- __pycache__/sentiV_v2.cpython-312.pyc +0 -0
- __pycache__/tts_hindi_edgetts.cpython-312.pyc +0 -0
- __pycache__/utils.cpython-312.pyc +0 -0
- api.py +1 -4
- app.py +40 -4
- news_summary.mp3 +0 -0
- sentiment_analysis.png +0 -0
__pycache__/api.cpython-312.pyc
ADDED
Binary file (1.32 kB). View file
|
|
__pycache__/scrapes.cpython-312.pyc
ADDED
Binary file (4.8 kB). View file
|
|
__pycache__/sentiV_v2.cpython-312.pyc
ADDED
Binary file (7.91 kB). View file
|
|
__pycache__/tts_hindi_edgetts.cpython-312.pyc
ADDED
Binary file (1.21 kB). View file
|
|
__pycache__/utils.cpython-312.pyc
ADDED
Binary file (8.35 kB). View file
|
|
api.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
from fastapi import FastAPI
|
2 |
from utils import process_news
|
3 |
-
import os
|
4 |
|
5 |
app = FastAPI(title="News Summarization & TTS API")
|
6 |
|
@@ -21,8 +20,6 @@ def get_news(company_name: str):
|
|
21 |
"""
|
22 |
return process_news(company_name)
|
23 |
|
24 |
-
# Hugging Face automatically runs this service
|
25 |
if __name__ == "__main__":
|
26 |
-
port = int(os.getenv("PORT", 7860)) # Hugging Face assigns a dynamic port
|
27 |
import uvicorn
|
28 |
-
uvicorn.run(app, host="0.0.0.0", port=
|
|
|
1 |
from fastapi import FastAPI
|
2 |
from utils import process_news
|
|
|
3 |
|
4 |
app = FastAPI(title="News Summarization & TTS API")
|
5 |
|
|
|
20 |
"""
|
21 |
return process_news(company_name)
|
22 |
|
|
|
23 |
if __name__ == "__main__":
|
|
|
24 |
import uvicorn
|
25 |
+
uvicorn.run(app, host="0.0.0.0", port=8000)
|
app.py
CHANGED
@@ -1,10 +1,45 @@
|
|
1 |
import os
|
|
|
2 |
import time
|
3 |
import requests
|
4 |
import streamlit as st
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
st.title("News Summarization and Hindi TTS Application")
|
10 |
company = st.text_input("Enter Company Name", "")
|
@@ -14,6 +49,7 @@ if st.button("Fetch News"):
|
|
14 |
st.warning("Please enter a valid company name.")
|
15 |
else:
|
16 |
with st.spinner("Fetching and processing news..."):
|
|
|
17 |
try:
|
18 |
response = requests.get(f"{API_URL}/news/{company}")
|
19 |
if response.status_code == 200:
|
@@ -50,5 +86,5 @@ if st.button("Fetch News"):
|
|
50 |
st.error("Audio file not found or TTS generation failed.")
|
51 |
else:
|
52 |
st.error("Failed to fetch news from the API. Please try again.")
|
53 |
-
except requests.exceptions.
|
54 |
-
st.error(
|
|
|
1 |
import os
|
2 |
+
import threading
|
3 |
import time
|
4 |
import requests
|
5 |
import streamlit as st
|
6 |
+
import uvicorn
|
7 |
+
from fastapi import FastAPI
|
8 |
+
from utils import process_news
|
9 |
+
import asyncio
|
10 |
+
import sys
|
11 |
|
12 |
+
if sys.platform == "win32":
|
13 |
+
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
|
14 |
+
|
15 |
+
import spacy
|
16 |
+
try:
|
17 |
+
spacy.load("en_core_web_sm")
|
18 |
+
except OSError:
|
19 |
+
import os
|
20 |
+
os.system("python -m spacy download en_core_web_sm")
|
21 |
+
|
22 |
+
|
23 |
+
# FastAPI app setup
|
24 |
+
api = FastAPI(title="News Summarization & TTS API")
|
25 |
+
|
26 |
+
@api.get("/")
|
27 |
+
def read_root():
|
28 |
+
return {"message": "Welcome to the News Summarization & TTS API"}
|
29 |
+
|
30 |
+
@api.get("/news/{company_name}")
|
31 |
+
def get_news(company_name: str):
|
32 |
+
return process_news(company_name)
|
33 |
+
|
34 |
+
# # Function to run FastAPI in a separate thread
|
35 |
+
# def run_fastapi():
|
36 |
+
# uvicorn.run(api, host="0.0.0.0", port=8000)
|
37 |
+
|
38 |
+
# # Start FastAPI in a separate thread
|
39 |
+
# threading.Thread(target=run_fastapi, daemon=True).start()
|
40 |
+
|
41 |
+
# # Streamlit app setup
|
42 |
+
API_URL = "http://127.0.0.1:8000" # Since FastAPI runs in the same Space
|
43 |
|
44 |
st.title("News Summarization and Hindi TTS Application")
|
45 |
company = st.text_input("Enter Company Name", "")
|
|
|
49 |
st.warning("Please enter a valid company name.")
|
50 |
else:
|
51 |
with st.spinner("Fetching and processing news..."):
|
52 |
+
time.sleep(2) # Give FastAPI some time to start
|
53 |
try:
|
54 |
response = requests.get(f"{API_URL}/news/{company}")
|
55 |
if response.status_code == 200:
|
|
|
86 |
st.error("Audio file not found or TTS generation failed.")
|
87 |
else:
|
88 |
st.error("Failed to fetch news from the API. Please try again.")
|
89 |
+
except requests.exceptions.ConnectionError:
|
90 |
+
st.error("API is not running yet. Please wait a moment and try again.")
|
news_summary.mp3
ADDED
Binary file (448 kB). View file
|
|
sentiment_analysis.png
ADDED
![]() |