Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -72,6 +72,12 @@ def infer(sample_audio_path, target_text, progress=gr.Progress()):
|
|
| 72 |
prompt_wav = torchaudio.transforms.Resample(orig_freq=sample_rate, new_freq=16000)(waveform_mono)
|
| 73 |
prompt_text = whisper_turbo_pipe(prompt_wav[0].numpy())['text'].strip()
|
| 74 |
progress(0.5, 'Transcribed! Generating speech...')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
|
| 76 |
input_text = prompt_text + ' ' + target_text
|
| 77 |
|
|
@@ -104,7 +110,7 @@ def infer(sample_audio_path, target_text, progress=gr.Progress()):
|
|
| 104 |
# Generate the speech autoregressively
|
| 105 |
outputs = model.generate(
|
| 106 |
input_ids,
|
| 107 |
-
max_length=
|
| 108 |
eos_token_id= speech_end_id ,
|
| 109 |
do_sample=True,
|
| 110 |
top_p=1,
|
|
|
|
| 72 |
prompt_wav = torchaudio.transforms.Resample(orig_freq=sample_rate, new_freq=16000)(waveform_mono)
|
| 73 |
prompt_text = whisper_turbo_pipe(prompt_wav[0].numpy())['text'].strip()
|
| 74 |
progress(0.5, 'Transcribed! Generating speech...')
|
| 75 |
+
|
| 76 |
+
if len(target_text) == 0:
|
| 77 |
+
return None
|
| 78 |
+
elif len(target_text) > 300:
|
| 79 |
+
gr.warning("Text is too long. Please keep it under 300 characters.")
|
| 80 |
+
target_text = target_text[:300]
|
| 81 |
|
| 82 |
input_text = prompt_text + ' ' + target_text
|
| 83 |
|
|
|
|
| 110 |
# Generate the speech autoregressively
|
| 111 |
outputs = model.generate(
|
| 112 |
input_ids,
|
| 113 |
+
max_length=2048, # We trained our model with a max length of 2048
|
| 114 |
eos_token_id= speech_end_id ,
|
| 115 |
do_sample=True,
|
| 116 |
top_p=1,
|