Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -676,58 +676,55 @@ with tab3:
|
|
676 |
image = Image.open('./data/incentive_image.jpg')
|
677 |
st.image(image, caption='Sensor Insentive Program')
|
678 |
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
|
683 |
|
684 |
with tab4:
|
685 |
st.header("Agent")
|
686 |
-
st.header("A day in the Life of Aya Green Data City")
|
687 |
|
688 |
-
# Creating columns for the layout
|
689 |
-
col1, col2 = st.columns([1, 2])
|
690 |
-
|
691 |
-
# Displaying the image in the left column
|
692 |
-
with col1:
|
693 |
-
image = Image.open('./data/green_image.jpg')
|
694 |
-
st.image(image, caption='Green Space')
|
695 |
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
731 |
|
732 |
|
733 |
|
|
|
676 |
image = Image.open('./data/incentive_image.jpg')
|
677 |
st.image(image, caption='Sensor Insentive Program')
|
678 |
|
|
|
|
|
|
|
679 |
|
680 |
|
681 |
with tab4:
|
682 |
st.header("Agent")
|
|
|
683 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
684 |
|
685 |
+
# Creating columns for the layout
|
686 |
+
col1, col2 = st.columns([1, 2])
|
687 |
+
|
688 |
+
# Displaying the image in the left column
|
689 |
+
with col1:
|
690 |
+
image = Image.open('./data/green_image.jpg')
|
691 |
+
st.image(image, caption='Green Space')
|
692 |
+
|
693 |
+
# Displaying the text above on the right
|
694 |
+
with col2:
|
|
|
695 |
|
696 |
+
st.markdown(query4)
|
697 |
+
|
698 |
+
# Displaying the audio player below the text
|
699 |
+
voice_option = st.selectbox(
|
700 |
+
'Choose a voice:',
|
701 |
+
['alloy', 'echo', 'fable', 'onyx', 'nova', 'shimmer'], key='key7'
|
702 |
+
)
|
703 |
+
|
704 |
+
|
705 |
+
if st.button('Convert to Speech', key='key8'):
|
706 |
+
if query4:
|
707 |
+
try:
|
708 |
+
response = oai_client.audio.speech.create(
|
709 |
+
model="tts-1",
|
710 |
+
voice=voice_option,
|
711 |
+
input=query4,
|
712 |
+
)
|
713 |
|
714 |
+
# Stream or save the response as needed
|
715 |
+
# For demonstration, let's assume we save then provide a link for downloading
|
716 |
+
audio_file_path = "output.mp3"
|
717 |
+
response.stream_to_file(audio_file_path)
|
718 |
+
|
719 |
+
# Display audio file to download
|
720 |
+
st.audio(audio_file_path, format='audio/mp3')
|
721 |
+
st.success("Conversion successful!")
|
722 |
+
|
723 |
+
|
724 |
+
except Exception as e:
|
725 |
+
st.error(f"An error occurred: {e}")
|
726 |
+
else:
|
727 |
+
st.error("Please enter some text to convert.")
|
728 |
|
729 |
|
730 |
|