Update app.py
Browse files
app.py
CHANGED
|
@@ -387,19 +387,30 @@ def text_to_speech(text):
|
|
| 387 |
}
|
| 388 |
|
| 389 |
response = requests.post(url, headers=headers, json=payload)
|
| 390 |
-
|
|
|
|
| 391 |
if response.status_code == 200:
|
| 392 |
-
|
|
|
|
|
|
|
|
|
|
| 393 |
f.write(response.content)
|
| 394 |
-
print(f"Audio saved to {
|
|
|
|
|
|
|
| 395 |
else:
|
| 396 |
-
print(f"Error: {response.status_code} - {response.text}")
|
|
|
|
|
|
|
| 397 |
|
| 398 |
st.title("Company Sentiment Analyzer")
|
| 399 |
|
| 400 |
company_name = st.text_input("Enter Company Name")
|
| 401 |
|
| 402 |
|
|
|
|
|
|
|
|
|
|
| 403 |
if st.button("Fetch Sentiment Data"):
|
| 404 |
try:
|
| 405 |
web_results = fetch_from_web(company_name)
|
|
@@ -446,8 +457,9 @@ if st.button("Fetch Sentiment Data"):
|
|
| 446 |
st.write(output_dict.get("final_report"))
|
| 447 |
|
| 448 |
st.subheader("π Audio Output")
|
| 449 |
-
|
| 450 |
-
|
|
|
|
| 451 |
|
| 452 |
except requests.exceptions.RequestException as e:
|
| 453 |
st.error(f"Error fetching data: {e}")
|
|
|
|
| 387 |
}
|
| 388 |
|
| 389 |
response = requests.post(url, headers=headers, json=payload)
|
| 390 |
+
|
| 391 |
+
|
| 392 |
if response.status_code == 200:
|
| 393 |
+
|
| 394 |
+
os.makedirs("temp", exist_ok=True)
|
| 395 |
+
output_file_path = os.path.join("temp", "output.mp3")
|
| 396 |
+
with open(output_file_path, "wb") as f:
|
| 397 |
f.write(response.content)
|
| 398 |
+
print(f"β
Audio saved to: {output_file_path}")
|
| 399 |
+
|
| 400 |
+
return output_file_path
|
| 401 |
else:
|
| 402 |
+
print(f"β Error: {response.status_code} - {response.text}")
|
| 403 |
+
return None
|
| 404 |
+
|
| 405 |
|
| 406 |
st.title("Company Sentiment Analyzer")
|
| 407 |
|
| 408 |
company_name = st.text_input("Enter Company Name")
|
| 409 |
|
| 410 |
|
| 411 |
+
|
| 412 |
+
# Save your file with the correct path
|
| 413 |
+
|
| 414 |
if st.button("Fetch Sentiment Data"):
|
| 415 |
try:
|
| 416 |
web_results = fetch_from_web(company_name)
|
|
|
|
| 457 |
st.write(output_dict.get("final_report"))
|
| 458 |
|
| 459 |
st.subheader("π Audio Output")
|
| 460 |
+
if audio_path and os.path.exists(audio_path):
|
| 461 |
+
with open(audio_path, "rb") as audio_file:
|
| 462 |
+
st.audio(audio_file, format="audio/mp3")
|
| 463 |
|
| 464 |
except requests.exceptions.RequestException as e:
|
| 465 |
st.error(f"Error fetching data: {e}")
|