richardorama commited on
Commit
fab61e0
·
verified ·
1 Parent(s): 5a5be61

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -9
app.py CHANGED
@@ -150,17 +150,22 @@ if STATEMENT:
150
  try:
151
  speech = tts(text)
152
  audio_data = speech['audio']
153
- wav_bytes = sf.write(None, audio_data, samplerate=speech['sampling_rate'], format='wav')
154
 
155
- with open('output_tts.wav', 'wb') as f:
156
- f.write(wav_bytes)
 
 
 
 
 
157
 
158
- st.sidebar.download_button(
159
- label="Download Audio",
160
- data=wav_bytes,
161
- file_name="generated_audio.wav",
162
- mime="audio/wav"
163
- )
164
  st.sidebar.write('Text converted to speech (download available)')
165
  except Exception as e:
166
  st.sidebar.write(f"Error: {str(e)}")
 
150
  try:
151
  speech = tts(text)
152
  audio_data = speech['audio']
153
+ #wav_bytes = sf.write(None, audio_data, samplerate=speech['sampling_rate'], format='wav')
154
 
155
+ wav_bytes = sf.write(None, audio_data, samplerate=speech['sampling_rate'], format='wav')
156
+ base64_audio = base64.b64encode(wav_bytes).decode('utf-8')
157
+
158
+ st.sidebar.markdown(f'<a href="data:audio/wav;base64,{base64_audio}" download="generated_audio.wav">Download Audio</a>', unsafe_allow_html=True)
159
+
160
+ # with open('output_tts.wav', 'wb') as f:
161
+ # f.write(wav_bytes)
162
 
163
+ # st.sidebar.download_button(
164
+ # label="Download Audio",
165
+ # data=wav_bytes,
166
+ # file_name="generated_audio.wav",
167
+ # mime="audio/wav"
168
+ # )
169
  st.sidebar.write('Text converted to speech (download available)')
170
  except Exception as e:
171
  st.sidebar.write(f"Error: {str(e)}")