Gregniuki commited on
Commit
092ec62
·
verified ·
1 Parent(s): 15de9b1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
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 > 105:
158
- max_chars = 105
159
- if max_chars < 40:
160
- max_chars = 40
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 > 8000:
400
- gr.Warning("Audio is over 8s, clipping to only first 8s.")
401
- aseg = aseg[:8000]
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) * (18 - 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)