richardorama
commited on
Update app.py
Browse files
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 |
-
|
156 |
-
|
|
|
|
|
|
|
|
|
|
|
157 |
|
158 |
-
st.sidebar.download_button(
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
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)}")
|