eaglelandsonce commited on
Commit
d7f25cc
·
verified ·
1 Parent(s): 6b30a3e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -44
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
- # Displaying the text above on the right
697
- with col2:
698
-
699
- st.markdown(query4)
700
-
701
- # Displaying the audio player below the text
702
- voice_option = st.selectbox(
703
- 'Choose a voice:',
704
- ['alloy', 'echo', 'fable', 'onyx', 'nova', 'shimmer'], key='key7'
705
- )
706
-
707
 
708
- if st.button('Convert to Speech', key='key8'):
709
- if query4:
710
- try:
711
- response = oai_client.audio.speech.create(
712
- model="tts-1",
713
- voice=voice_option,
714
- input=query4,
715
- )
716
-
717
- # Stream or save the response as needed
718
- # For demonstration, let's assume we save then provide a link for downloading
719
- audio_file_path = "output.mp3"
720
- response.stream_to_file(audio_file_path)
721
-
722
- # Display audio file to download
723
- st.audio(audio_file_path, format='audio/mp3')
724
- st.success("Conversion successful!")
725
 
726
-
727
- except Exception as e:
728
- st.error(f"An error occurred: {e}")
729
- else:
730
- st.error("Please enter some text to convert.")
 
 
 
 
 
 
 
 
 
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