freddyaboulton HF Staff commited on
Commit
5b58cc8
·
1 Parent(s): ee4aecd
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -216,14 +216,13 @@ def generate_base(subject, setting, ):
216
 
217
  play_steps_in_s = 4.0
218
  play_steps = int(frame_rate * play_steps_in_s)
219
- streamer = ParlerTTSStreamer(model, device=device, play_steps=play_steps)
220
 
221
  description = "Jenny speaks at an average pace with a calm delivery in a very confined sounding environment with clear audio quality."
222
  inputs = tokenizer(description, return_tensors="pt").to(device)
223
 
224
- gr.Info("Reading story", duration=3)
225
 
226
- for sentence in model_input:
 
227
 
228
  prompt = tokenizer(sentence, return_tensors="pt").to(device)
229
 
@@ -241,6 +240,8 @@ def generate_base(subject, setting, ):
241
  thread.start()
242
 
243
  for new_audio in streamer:
 
 
244
  print(f"Sample of length: {round(new_audio.shape[0] / sampling_rate, 2)} seconds")
245
  yield story, numpy_to_mp3(new_audio, sampling_rate=sampling_rate)
246
 
 
216
 
217
  play_steps_in_s = 4.0
218
  play_steps = int(frame_rate * play_steps_in_s)
 
219
 
220
  description = "Jenny speaks at an average pace with a calm delivery in a very confined sounding environment with clear audio quality."
221
  inputs = tokenizer(description, return_tensors="pt").to(device)
222
 
 
223
 
224
+ for i, sentence in enumerate(model_input):
225
+ streamer = ParlerTTSStreamer(model, device=device, play_steps=play_steps)
226
 
227
  prompt = tokenizer(sentence, return_tensors="pt").to(device)
228
 
 
240
  thread.start()
241
 
242
  for new_audio in streamer:
243
+ if i == 0:
244
+ gr.Info("Reading story", duration=3)
245
  print(f"Sample of length: {round(new_audio.shape[0] / sampling_rate, 2)} seconds")
246
  yield story, numpy_to_mp3(new_audio, sampling_rate=sampling_rate)
247