Gregniuki commited on
Commit
4a1c5cf
·
verified ·
1 Parent(s): 0ca9d9b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -159,10 +159,17 @@ def infer_batch(ref_audio, ref_text, gen_text_batches, exp_name, remove_silence,
159
  final_text_list = convert_char_to_pinyin(text_list)
160
 
161
  # Calculate duration
 
 
 
 
 
 
162
  ref_audio_len = audio.shape[-1] // hop_length
163
- zh_pause_punc = r"。,、;:?!,"
 
164
  gen_text_len = len(gen_text.encode('utf-8')) + 3 * len(re.findall(zh_pause_punc, gen_text))
165
- duration = min(10, max(1, int(round(gen_text_len / (speed * 10)))))*100
166
  print(f"Duration: {duration} seconds")
167
 
168
  # inference
 
159
  final_text_list = convert_char_to_pinyin(text_list)
160
 
161
  # Calculate duration
162
+ # ref_audio_len = audio.shape[-1] // hop_length
163
+ # zh_pause_punc = r"。,、;:?!,"
164
+ # gen_text_len = len(gen_text.encode('utf-8')) + 3 * len(re.findall(zh_pause_punc, gen_text))
165
+ # duration = min(10, max(1, int(round(gen_text_len / (speed * 10)))))*100
166
+
167
+ # Calculate duration
168
  ref_audio_len = audio.shape[-1] // hop_length
169
+ zh_pause_punc = r"。,、;:?!"
170
+ ref_text_len = len(ref_text.encode('utf-8')) + 3 * len(re.findall(zh_pause_punc, ref_text))
171
  gen_text_len = len(gen_text.encode('utf-8')) + 3 * len(re.findall(zh_pause_punc, gen_text))
172
+ duration = ref_audio_len + int(ref_audio_len / ref_text_len * gen_text_len / speed)
173
  print(f"Duration: {duration} seconds")
174
 
175
  # inference