Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -139,7 +139,7 @@ E2TTS_ema_model2 = load_custom(
|
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
-
def chunk_text(text, max_chars
|
| 143 |
"""
|
| 144 |
Splits the input text into chunks, ensuring:
|
| 145 |
- Chunks are split by punctuation where possible.
|
|
@@ -233,7 +233,7 @@ def infer_batch(ref_audio, ref_text, gen_text_batches, exp_name, remove_silence,
|
|
| 233 |
ref_text = ref_text + " "
|
| 234 |
|
| 235 |
# Define weights for characters
|
| 236 |
-
punctuation_weights = {",":
|
| 237 |
|
| 238 |
for i, gen_text in enumerate(progress.tqdm(gen_text_batches)):
|
| 239 |
# Prepare the text
|
|
@@ -416,7 +416,7 @@ def infer(ref_audio_orig, ref_text, gen_text, exp_name, remove_silence, cross_fa
|
|
| 416 |
audio, sr = torchaudio.load(ref_audio)
|
| 417 |
|
| 418 |
# Use the new chunk_text function to split gen_text
|
| 419 |
-
max_chars = int(0.5 * (len(ref_text.encode('utf-8')) / (audio.shape[-1] / sr) * (18 - audio.shape[-1] / sr )))
|
| 420 |
print(f"text: {max_chars} ")
|
| 421 |
gen_text_batches = chunk_text(gen_text, max_chars=max_chars)
|
| 422 |
print('ref_text', ref_text)
|
|
|
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
+
def chunk_text(text, max_chars):
|
| 143 |
"""
|
| 144 |
Splits the input text into chunks, ensuring:
|
| 145 |
- Chunks are split by punctuation where possible.
|
|
|
|
| 233 |
ref_text = ref_text + " "
|
| 234 |
|
| 235 |
# Define weights for characters
|
| 236 |
+
punctuation_weights = {",": 2, ".": 2, " ": 2} # Add more punctuation as needed
|
| 237 |
|
| 238 |
for i, gen_text in enumerate(progress.tqdm(gen_text_batches)):
|
| 239 |
# Prepare the text
|
|
|
|
| 416 |
audio, sr = torchaudio.load(ref_audio)
|
| 417 |
|
| 418 |
# Use the new chunk_text function to split gen_text
|
| 419 |
+
max_chars = int(speed * 0.5 * (len(ref_text.encode('utf-8')) / (audio.shape[-1] / sr) * (18 - audio.shape[-1] / sr )))
|
| 420 |
print(f"text: {max_chars} ")
|
| 421 |
gen_text_batches = chunk_text(gen_text, max_chars=max_chars)
|
| 422 |
print('ref_text', ref_text)
|