Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -188,22 +188,21 @@ def infer_batch(ref_audio, ref_text, gen_text_batches, exp_name, remove_silence,
|
|
188 |
generated_waves = []
|
189 |
spectrograms = []
|
190 |
|
191 |
-
|
192 |
-
|
193 |
for i, gen_text in enumerate(progress.tqdm(gen_text_batches)):
|
194 |
# Prepare the text
|
195 |
-
if len(ref_text[-1].encode('utf-8')) == 1:
|
196 |
-
ref_text = ref_text + " "
|
197 |
text_list = [ref_text + gen_text]
|
198 |
final_text_list = convert_char_to_pinyin(text_list)
|
199 |
|
200 |
-
# Calculate duration
|
201 |
ref_audio_len = audio.shape[-1] // hop_length
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
|
|
|
|
207 |
# Print the calculated duration
|
208 |
print(f"Duration: {duration} seconds")
|
209 |
# inference
|
|
|
188 |
generated_waves = []
|
189 |
spectrograms = []
|
190 |
|
191 |
+
if len(ref_text[-1].encode("utf-8")) == 1:
|
192 |
+
ref_text = ref_text + " "
|
193 |
for i, gen_text in enumerate(progress.tqdm(gen_text_batches)):
|
194 |
# Prepare the text
|
|
|
|
|
195 |
text_list = [ref_text + gen_text]
|
196 |
final_text_list = convert_char_to_pinyin(text_list)
|
197 |
|
|
|
198 |
ref_audio_len = audio.shape[-1] // hop_length
|
199 |
+
if fix_duration is not None:
|
200 |
+
duration = int(fix_duration * target_sample_rate / hop_length)
|
201 |
+
else:
|
202 |
+
# Calculate duration
|
203 |
+
ref_text_len = len(ref_text.encode("utf-8"))
|
204 |
+
gen_text_len = len(gen_text.encode("utf-8"))
|
205 |
+
duration = ref_audio_len + int(ref_audio_len / ref_text_len * gen_text_len / speed)
|
206 |
# Print the calculated duration
|
207 |
print(f"Duration: {duration} seconds")
|
208 |
# inference
|