Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -178,6 +178,11 @@ def generate_speech(text, voice1, voice2, temperature, top_p, repetition_penalty
|
|
178 |
# Normalize the audio
|
179 |
final_audio = np.int16(final_audio / np.max(np.abs(final_audio)) * 32767)
|
180 |
|
|
|
|
|
|
|
|
|
|
|
181 |
return (24000, final_audio)
|
182 |
except Exception as e:
|
183 |
print(f"Error generating speech: {e}")
|
@@ -199,13 +204,13 @@ with gr.Blocks(title="Orpheus Text-to-Speech") as demo:
|
|
199 |
with gr.Column(scale=2):
|
200 |
voice1 = gr.Dropdown(
|
201 |
choices=VOICES,
|
202 |
-
value="
|
203 |
label="Voice 1",
|
204 |
info="Select the first voice for speech generation"
|
205 |
)
|
206 |
voice2 = gr.Dropdown(
|
207 |
choices=VOICES,
|
208 |
-
value="
|
209 |
label="Voice 2",
|
210 |
info="Select the second voice for speech generation"
|
211 |
)
|
|
|
178 |
# Normalize the audio
|
179 |
final_audio = np.int16(final_audio / np.max(np.abs(final_audio)) * 32767)
|
180 |
|
181 |
+
# Trim to 15 seconds if longer
|
182 |
+
max_samples = 24000 * 15
|
183 |
+
if len(final_audio) > max_samples:
|
184 |
+
final_audio = final_audio[:max_samples]
|
185 |
+
|
186 |
return (24000, final_audio)
|
187 |
except Exception as e:
|
188 |
print(f"Error generating speech: {e}")
|
|
|
204 |
with gr.Column(scale=2):
|
205 |
voice1 = gr.Dropdown(
|
206 |
choices=VOICES,
|
207 |
+
value="tara",
|
208 |
label="Voice 1",
|
209 |
info="Select the first voice for speech generation"
|
210 |
)
|
211 |
voice2 = gr.Dropdown(
|
212 |
choices=VOICES,
|
213 |
+
value="dan",
|
214 |
label="Voice 2",
|
215 |
info="Select the second voice for speech generation"
|
216 |
)
|