richardorama
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -147,24 +147,19 @@ if STATEMENT:
|
|
147 |
if st.sidebar.button('Convert Text to Speech'):
|
148 |
text = STATEMENT
|
149 |
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
file_name="generated_audio.wav",
|
164 |
-
mime="audio/wav"
|
165 |
-
)
|
166 |
-
|
167 |
-
st.sidebar.write('Text converted to speech (download available)')
|
168 |
else:
|
169 |
st.sidebar.button('Convert Text to Speech', disabled=True)
|
170 |
# st.warning(' Please enter Statement!')
|
|
|
147 |
if st.sidebar.button('Convert Text to Speech'):
|
148 |
text = STATEMENT
|
149 |
|
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 |
+
st.sidebar.download_button(
|
155 |
+
label="Download Audio",
|
156 |
+
data=wav_bytes,
|
157 |
+
file_name="generated_audio.wav",
|
158 |
+
mime="audio/wav"
|
159 |
+
)
|
160 |
+
st.sidebar.write('Text converted to speech (download available)')
|
161 |
+
except Exception as e:
|
162 |
+
st.sidebar.write(f"Error: {str(e)}")
|
|
|
|
|
|
|
|
|
|
|
163 |
else:
|
164 |
st.sidebar.button('Convert Text to Speech', disabled=True)
|
165 |
# st.warning(' Please enter Statement!')
|