eaglelandsonce commited on
Commit
01c2e34
·
verified ·
1 Parent(s): 32e6730

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -33
app.py CHANGED
@@ -615,44 +615,44 @@ with tab3:
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
 
 
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