Solshine commited on
Commit
24f736a
1 Parent(s): e80c110

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -25
app.py CHANGED
@@ -106,31 +106,31 @@ def launch_bot():
106
  audio_result = st.button("Convert to Audio 🔊")
107
  if audio_result:
108
  with st.chat_message("text-to-speech"):
109
- with st.spinner("Thinking..."):
110
- #text-to-speech
111
- print("Calling in Text-to-speech via suno/bark-small")
112
- synthesiser = pipeline("text-to-speech", "suno/bark-small")
113
-
114
- speech = synthesiser(response, forward_params={"do_sample": True})
115
-
116
- scipy.io.wavfile.write("bark_out.wav", rate=speech["sampling_rate"], data=speech["audio"])
117
- # ST interface for audio
118
- print("Now we try to display the audio file in the app")
119
- audio_file = open('bark_out.wav', 'rb')
120
- audio_bytes = audio_file.read()
121
-
122
- audio_convert = st.audio(audio_bytes, format='bark_out.wav')
123
- st.session_state.messages.append(audio_convert)
124
-
125
- # sample_rate = 44100 # 44100 samples per second
126
- # seconds = 2 # Note duration of 2 seconds
127
- # frequency_la = 440 # Our played note will be 440 Hz
128
- # Generate array with seconds*sample_rate steps, ranging between 0 and seconds
129
- # t = np.linspace(0, seconds, seconds * sample_rate, False)
130
- # Generate a 440 Hz sine wave
131
- # note_la = np.sin(frequency_la * t * 2 * np.pi)
132
-
133
- # st.audio(note_la, sample_rate=sample_rate)
134
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
  if __name__ == "__main__":
136
  launch_bot()
 
106
  audio_result = st.button("Convert to Audio 🔊")
107
  if audio_result:
108
  with st.chat_message("text-to-speech"):
109
+ with st.spinner("Thinking..."):
110
+ #text-to-speech
111
+ print("Calling in Text-to-speech via suno/bark-small")
112
+ synthesiser = pipeline("text-to-speech", "suno/bark-small")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
 
114
+ speech = synthesiser(response, forward_params={"do_sample": True})
115
+
116
+ scipy.io.wavfile.write("bark_out.wav", rate=speech["sampling_rate"], data=speech["audio"])
117
+ # ST interface for audio
118
+ print("Now we try to display the audio file in the app")
119
+ audio_file = open('bark_out.wav', 'rb')
120
+ audio_bytes = audio_file.read()
121
+
122
+ audio_convert = st.audio(audio_bytes, format='audio/wav')
123
+ st.session_state.messages.append(audio_convert)
124
+
125
+ # sample_rate = 44100 # 44100 samples per second
126
+ # seconds = 2 # Note duration of 2 seconds
127
+ # frequency_la = 440 # Our played note will be 440 Hz
128
+ # Generate array with seconds*sample_rate steps, ranging between 0 and seconds
129
+ # t = np.linspace(0, seconds, seconds * sample_rate, False)
130
+ # Generate a 440 Hz sine wave
131
+ # note_la = np.sin(frequency_la * t * 2 * np.pi)
132
+
133
+ # st.audio(note_la, sample_rate=sample_rate)
134
+
135
  if __name__ == "__main__":
136
  launch_bot()