Spaces:
Running
Running
Rajkumar Pramanik "RJproz
commited on
Commit
·
f8e32a0
1
Parent(s):
3dde740
bug fixes
Browse files
app.py
CHANGED
|
@@ -196,24 +196,23 @@ def generate_speech(description, text, temperature, max_tokens):
|
|
| 196 |
if len(audio) > 2048:
|
| 197 |
audio = audio[2048:]
|
| 198 |
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
|
| 203 |
-
|
| 204 |
|
| 205 |
-
#
|
| 206 |
-
|
| 207 |
-
|
| 208 |
|
| 209 |
-
#
|
| 210 |
-
|
| 211 |
|
| 212 |
-
|
| 213 |
-
|
| 214 |
|
| 215 |
-
|
| 216 |
-
status_msg = "success"
|
| 217 |
return tmp_path, status_msg
|
| 218 |
|
| 219 |
except Exception as e:
|
|
@@ -287,17 +286,17 @@ with gr.Blocks(title="Maya1 - Open Source Emotional TTS", theme=gr.themes.Soft()
|
|
| 287 |
with gr.Column(scale=1):
|
| 288 |
gr.Markdown("### Generated Audio")
|
| 289 |
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
# interactive=False
|
| 294 |
-
# )
|
| 295 |
-
|
| 296 |
-
audio_output = gr.Textbox(
|
| 297 |
-
label="Autio Path",
|
| 298 |
-
lines=3,
|
| 299 |
interactive=False
|
| 300 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 301 |
|
| 302 |
status_output = gr.Textbox(
|
| 303 |
label="Status",
|
|
|
|
| 196 |
if len(audio) > 2048:
|
| 197 |
audio = audio[2048:]
|
| 198 |
|
| 199 |
+
Convert to WAV and save to temporary file
|
| 200 |
+
import tempfile
|
| 201 |
+
import soundfile as sf
|
| 202 |
|
| 203 |
+
audio_int16 = (audio * 32767).astype(np.int16)
|
| 204 |
|
| 205 |
+
# Create temporary file
|
| 206 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix='.wav') as tmp_file:
|
| 207 |
+
tmp_path = tmp_file.name
|
| 208 |
|
| 209 |
+
# Save audio
|
| 210 |
+
sf.write(tmp_path, audio_int16, AUDIO_SAMPLE_RATE)
|
| 211 |
|
| 212 |
+
duration = len(audio) / AUDIO_SAMPLE_RATE
|
| 213 |
+
status_msg = f"Generated {duration:.2f}s of emotional speech!"
|
| 214 |
|
| 215 |
+
|
|
|
|
| 216 |
return tmp_path, status_msg
|
| 217 |
|
| 218 |
except Exception as e:
|
|
|
|
| 286 |
with gr.Column(scale=1):
|
| 287 |
gr.Markdown("### Generated Audio")
|
| 288 |
|
| 289 |
+
audio_output = gr.Audio(
|
| 290 |
+
label="Generated Speech",
|
| 291 |
+
type="filepath",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 292 |
interactive=False
|
| 293 |
)
|
| 294 |
+
|
| 295 |
+
# audio_output = gr.Textbox(
|
| 296 |
+
# label="Autio Path",
|
| 297 |
+
# lines=3,
|
| 298 |
+
# interactive=False
|
| 299 |
+
# )
|
| 300 |
|
| 301 |
status_output = gr.Textbox(
|
| 302 |
label="Status",
|