Update app.py
Browse files
app.py
CHANGED
|
@@ -391,13 +391,8 @@ def text_to_speech(text):
|
|
| 391 |
|
| 392 |
if response.status_code == 200:
|
| 393 |
|
| 394 |
-
|
| 395 |
-
|
| 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
|
|
@@ -439,7 +434,7 @@ if st.button("Fetch Sentiment Data"):
|
|
| 439 |
)
|
| 440 |
|
| 441 |
hindi_translation = translate(final_report , model_provider = "Groq")
|
| 442 |
-
|
| 443 |
|
| 444 |
output_dict = {
|
| 445 |
"company_name": company_name,
|
|
@@ -447,7 +442,7 @@ if st.button("Fetch Sentiment Data"):
|
|
| 447 |
"comparative_sentiment": comparative_sentiment,
|
| 448 |
"final_report": final_report,
|
| 449 |
"hindi_translation": hindi_translation,
|
| 450 |
-
"
|
| 451 |
}
|
| 452 |
|
| 453 |
st.subheader("Company Name")
|
|
@@ -456,10 +451,13 @@ if st.button("Fetch Sentiment Data"):
|
|
| 456 |
st.subheader("Final Report")
|
| 457 |
st.write(output_dict.get("final_report"))
|
| 458 |
|
| 459 |
-
st.
|
| 460 |
-
|
| 461 |
-
|
| 462 |
-
|
|
|
|
|
|
|
|
|
|
| 463 |
|
| 464 |
except requests.exceptions.RequestException as e:
|
| 465 |
st.error(f"Error fetching data: {e}")
|
|
|
|
| 391 |
|
| 392 |
if response.status_code == 200:
|
| 393 |
|
| 394 |
+
return response.content
|
| 395 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 396 |
else:
|
| 397 |
print(f"β Error: {response.status_code} - {response.text}")
|
| 398 |
return None
|
|
|
|
| 434 |
)
|
| 435 |
|
| 436 |
hindi_translation = translate(final_report , model_provider = "Groq")
|
| 437 |
+
audio_data = text_to_speech(hindi_translation)
|
| 438 |
|
| 439 |
output_dict = {
|
| 440 |
"company_name": company_name,
|
|
|
|
| 442 |
"comparative_sentiment": comparative_sentiment,
|
| 443 |
"final_report": final_report,
|
| 444 |
"hindi_translation": hindi_translation,
|
| 445 |
+
"audio_text": audio_data,
|
| 446 |
}
|
| 447 |
|
| 448 |
st.subheader("Company Name")
|
|
|
|
| 451 |
st.subheader("Final Report")
|
| 452 |
st.write(output_dict.get("final_report"))
|
| 453 |
|
| 454 |
+
if st.button("Generate Speech"):
|
| 455 |
+
with st.spinner("Generating audio..."):
|
| 456 |
+
audio_data = output_dict["audio_text"]
|
| 457 |
+
|
| 458 |
+
if audio_data:
|
| 459 |
+
st.audio(audio_data, format="audio/mp3")
|
| 460 |
+
|
| 461 |
|
| 462 |
except requests.exceptions.RequestException as e:
|
| 463 |
st.error(f"Error fetching data: {e}")
|