Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -207,6 +207,10 @@ class ParlerTTSStreamer(BaseStreamer):
|
|
207 |
else:
|
208 |
return value
|
209 |
|
|
|
|
|
|
|
|
|
210 |
def numpy_to_mp3(audio_array, sampling_rate):
|
211 |
# Normalize audio_array if it's floating-point
|
212 |
if np.issubdtype(audio_array.dtype, np.floating):
|
@@ -230,12 +234,9 @@ def numpy_to_mp3(audio_array, sampling_rate):
|
|
230 |
mp3_bytes = mp3_io.getvalue()
|
231 |
mp3_io.close()
|
232 |
|
233 |
-
gr.Info(f"Bytes returned")
|
234 |
return mp3_bytes
|
235 |
|
236 |
-
sampling_rate = model.audio_encoder.config.sampling_rate
|
237 |
-
frame_rate = model.audio_encoder.config.frame_rate
|
238 |
-
|
239 |
@spaces.GPU
|
240 |
def generate_base(text, description, play_steps_in_s=2.0):
|
241 |
play_steps = int(frame_rate * play_steps_in_s)
|
@@ -258,7 +259,7 @@ def generate_base(text, description, play_steps_in_s=2.0):
|
|
258 |
thread.start()
|
259 |
|
260 |
for new_audio in streamer:
|
261 |
-
gr.Info(f"Sample of length {round(new_audio.shape[0] / sampling_rate, 2)} seconds ready")
|
262 |
yield numpy_to_mp3(new_audio, sampling_rate=sampling_rate)
|
263 |
|
264 |
|
|
|
207 |
else:
|
208 |
return value
|
209 |
|
210 |
+
sampling_rate = model.audio_encoder.config.sampling_rate
|
211 |
+
frame_rate = model.audio_encoder.config.frame_rate
|
212 |
+
|
213 |
+
|
214 |
def numpy_to_mp3(audio_array, sampling_rate):
|
215 |
# Normalize audio_array if it's floating-point
|
216 |
if np.issubdtype(audio_array.dtype, np.floating):
|
|
|
234 |
mp3_bytes = mp3_io.getvalue()
|
235 |
mp3_io.close()
|
236 |
|
237 |
+
gr.Info(f"Bytes returned", duration=0.8)
|
238 |
return mp3_bytes
|
239 |
|
|
|
|
|
|
|
240 |
@spaces.GPU
|
241 |
def generate_base(text, description, play_steps_in_s=2.0):
|
242 |
play_steps = int(frame_rate * play_steps_in_s)
|
|
|
259 |
thread.start()
|
260 |
|
261 |
for new_audio in streamer:
|
262 |
+
gr.Info(f"Sample of length {round(new_audio.shape[0] / sampling_rate, 2)} seconds ready", duration=0.8)
|
263 |
yield numpy_to_mp3(new_audio, sampling_rate=sampling_rate)
|
264 |
|
265 |
|