julian78w commited on
Commit
f007a1f
1 Parent(s): 1b7f8cd

Add MAX_TXT_LEN limit for the txt input

Browse files
Files changed (1) hide show
  1. app.py +4 -0
app.py CHANGED
@@ -9,6 +9,7 @@ from TTS.utils.synthesizer import Synthesizer
9
 
10
  MODELS = {}
11
  SPEAKERS = {}
 
12
 
13
 
14
  manager = ModelManager()
@@ -24,6 +25,9 @@ print(MODEL_NAMES)
24
 
25
 
26
  def tts(text: str, model_name: str, speaker_idx: str=None):
 
 
 
27
  print(text, model_name)
28
  # download model
29
  model_path, config_path, model_item = manager.download_model(f"tts_models/{model_name}")
 
9
 
10
  MODELS = {}
11
  SPEAKERS = {}
12
+ MAX_TXT_LEN = 150
13
 
14
 
15
  manager = ModelManager()
 
25
 
26
 
27
  def tts(text: str, model_name: str, speaker_idx: str=None):
28
+ if len(text) > MAX_TXT_LEN:
29
+ text = text[:MAX_TXT_LEN]
30
+ print(f"Input text was cutoff since it went over the {MAX_TXT_LEN} character limit.")
31
  print(text, model_name)
32
  # download model
33
  model_path, config_path, model_item = manager.download_model(f"tts_models/{model_name}")