Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -154,10 +154,10 @@ def chunk_text(text, max_chars):
|
|
154 |
Returns:
|
155 |
List[str]: A list of text chunks.
|
156 |
"""
|
157 |
-
if max_chars >
|
158 |
-
max_chars =
|
159 |
-
if max_chars <
|
160 |
-
max_chars =
|
161 |
|
162 |
|
163 |
|
@@ -396,9 +396,9 @@ def infer(ref_audio_orig, ref_text, gen_text, exp_name, remove_silence, cross_fa
|
|
396 |
|
397 |
|
398 |
audio_duration = len(aseg)
|
399 |
-
if audio_duration >
|
400 |
-
gr.Warning("Audio is over
|
401 |
-
aseg = aseg[:
|
402 |
aseg.export(f.name, format="wav")
|
403 |
ref_audio = f.name
|
404 |
|
@@ -427,7 +427,7 @@ def infer(ref_audio_orig, ref_text, gen_text, exp_name, remove_silence, cross_fa
|
|
427 |
audio, sr = torchaudio.load(ref_audio)
|
428 |
|
429 |
# Use the new chunk_text function to split gen_text
|
430 |
-
max_chars = int(speed * 0.5 * (len(ref_text.encode('utf-8')) / (audio.shape[-1] / sr) * (
|
431 |
print(f"text: {max_chars} ")
|
432 |
gen_text_batches = chunk_text(gen_text, max_chars=max_chars)
|
433 |
print('ref_text', ref_text)
|
|
|
154 |
Returns:
|
155 |
List[str]: A list of text chunks.
|
156 |
"""
|
157 |
+
if max_chars > 135:
|
158 |
+
max_chars = 135
|
159 |
+
if max_chars < 50:
|
160 |
+
max_chars = 50
|
161 |
|
162 |
|
163 |
|
|
|
396 |
|
397 |
|
398 |
audio_duration = len(aseg)
|
399 |
+
if audio_duration > 10000:
|
400 |
+
gr.Warning("Audio is over 10s, clipping to only first 10s.")
|
401 |
+
aseg = aseg[:10000]
|
402 |
aseg.export(f.name, format="wav")
|
403 |
ref_audio = f.name
|
404 |
|
|
|
427 |
audio, sr = torchaudio.load(ref_audio)
|
428 |
|
429 |
# Use the new chunk_text function to split gen_text
|
430 |
+
max_chars = int(speed * 0.5 * (len(ref_text.encode('utf-8')) / (audio.shape[-1] / sr) * (20 - audio.shape[-1] / sr )))
|
431 |
print(f"text: {max_chars} ")
|
432 |
gen_text_batches = chunk_text(gen_text, max_chars=max_chars)
|
433 |
print('ref_text', ref_text)
|