Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
d9c449e
1
Parent(s):
8517188
fix
Browse files
app.py
CHANGED
|
@@ -117,8 +117,16 @@ def generate_speech(
|
|
| 117 |
else:
|
| 118 |
audio_np = generated_audio
|
| 119 |
|
| 120 |
-
|
| 121 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
|
| 123 |
return (24000, audio_np)
|
| 124 |
|
|
|
|
| 117 |
else:
|
| 118 |
audio_np = generated_audio
|
| 119 |
|
| 120 |
+
# Ensure audio is properly normalized and in the correct format
|
| 121 |
+
if audio_np.ndim == 2 and audio_np.shape[0] == 1:
|
| 122 |
+
audio_np = audio_np.squeeze(0) # Remove batch dimension if present
|
| 123 |
+
|
| 124 |
+
# Normalize audio to [-1, 1] range if needed
|
| 125 |
+
if np.abs(audio_np).max() > 1.0:
|
| 126 |
+
audio_np = audio_np / np.abs(audio_np).max()
|
| 127 |
+
|
| 128 |
+
# Ensure audio is in float32 format
|
| 129 |
+
audio_np = audio_np.astype(np.float32)
|
| 130 |
|
| 131 |
return (24000, audio_np)
|
| 132 |
|