Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -613,41 +613,48 @@ with tab3:
|
|
| 613 |
# Display the graph
|
| 614 |
agraph(nodes=graph_store.getNodes(), edges=graph_store.getEdges(), config=agraph_config)
|
| 615 |
|
| 616 |
-
image = Image.open('./data/incentive_image.jpg')
|
| 617 |
-
st.image(image, caption='Sensor Insentive Program')
|
| 618 |
|
| 619 |
-
|
| 620 |
-
|
| 621 |
-
|
| 622 |
-
|
| 623 |
-
'Choose a voice:',
|
| 624 |
-
['alloy', 'echo', 'fable', 'onyx', 'nova', 'shimmer'],key='key5'
|
| 625 |
-
)
|
| 626 |
-
|
| 627 |
|
| 628 |
-
|
| 629 |
-
|
| 630 |
-
|
| 631 |
-
|
| 632 |
-
|
| 633 |
-
|
| 634 |
-
|
| 635 |
-
|
| 636 |
-
|
| 637 |
-
|
| 638 |
-
|
| 639 |
-
|
| 640 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 641 |
|
| 642 |
-
|
| 643 |
-
|
| 644 |
-
|
| 645 |
-
|
| 646 |
-
|
| 647 |
-
|
| 648 |
-
else:
|
| 649 |
-
st.error("Please enter some text to convert.")
|
| 650 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 651 |
|
| 652 |
|
| 653 |
with tab4:
|
|
|
|
| 613 |
# Display the graph
|
| 614 |
agraph(nodes=graph_store.getNodes(), edges=graph_store.getEdges(), config=agraph_config)
|
| 615 |
|
|
|
|
|
|
|
| 616 |
|
| 617 |
+
col3, col4 = st.columns(2)
|
| 618 |
+
with col3:
|
| 619 |
+
|
| 620 |
+
st.markdown(query3)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 621 |
|
| 622 |
+
# Displaying the audio player below the text
|
| 623 |
+
voice_option3 = st.selectbox(
|
| 624 |
+
'Choose a voice:',
|
| 625 |
+
['alloy', 'echo', 'fable', 'onyx', 'nova', 'shimmer'],key='key5'
|
| 626 |
+
)
|
| 627 |
+
|
| 628 |
+
|
| 629 |
+
if st.button('Convert to Speech', key='key6'):
|
| 630 |
+
if query2:
|
| 631 |
+
try:
|
| 632 |
+
response = oai_client.audio.speech.create(
|
| 633 |
+
model="tts-1",
|
| 634 |
+
voice=voice_option3,
|
| 635 |
+
input=query3,
|
| 636 |
+
)
|
| 637 |
+
|
| 638 |
+
# Stream or save the response as needed
|
| 639 |
+
# For demonstration, let's assume we save then provide a link for downloading
|
| 640 |
+
audio_file_path = "output.mp3"
|
| 641 |
+
response.stream_to_file(audio_file_path)
|
| 642 |
+
|
| 643 |
+
# Display audio file to download
|
| 644 |
+
st.audio(audio_file_path, format='audio/mp3')
|
| 645 |
+
st.success("Conversion successful!")
|
| 646 |
|
| 647 |
+
except Exception as e:
|
| 648 |
+
st.error(f"An error occurred: {e}")
|
| 649 |
+
else:
|
| 650 |
+
st.error("Please enter some text to convert.")
|
| 651 |
+
|
| 652 |
+
with col4:
|
|
|
|
|
|
|
| 653 |
|
| 654 |
+
image = Image.open('./data/incentive_image.jpg')
|
| 655 |
+
st.image(image, caption='Sensor Insentive Program')
|
| 656 |
+
|
| 657 |
+
|
| 658 |
|
| 659 |
|
| 660 |
with tab4:
|