XuminYu commited on
Commit
e9ea5d7
1 Parent(s): 84d07ff

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -58,6 +58,7 @@ def predict(prompt, style, audio_file_pth, agree):
58
  None,
59
  )
60
  style = 'en_' + style
 
61
 
62
  else:
63
  if style not in ['default']:
@@ -69,10 +70,11 @@ def predict(prompt, style, audio_file_pth, agree):
69
  None,
70
  )
71
  style = 'cn_' + style
 
72
 
73
  speaker_wav = audio_file_pth
74
 
75
- if len(prompt) < 2:
76
  text_hint += f"[ERROR] Please give a longer prompt text \n"
77
  gr.Warning("Please give a longer prompt text")
78
  return (
@@ -80,8 +82,8 @@ def predict(prompt, style, audio_file_pth, agree):
80
  None,
81
  None,
82
  )
83
- if len(prompt) > 200:
84
- text_hint += f"[ERROR] Text length limited to 200 characters for this demo, please try shorter text. You can clone our open-source repo and try for your usage \n"
85
  gr.Warning(
86
  "Text length limited to 200 characters for this demo, please try shorter text. You can clone our open-source repo for your usage"
87
  )
 
58
  None,
59
  )
60
  style = 'en_' + style
61
+ prompt_length = len(prompt.split(' '))
62
 
63
  else:
64
  if style not in ['default']:
 
70
  None,
71
  )
72
  style = 'cn_' + style
73
+ prompt_length = len(prompt)
74
 
75
  speaker_wav = audio_file_pth
76
 
77
+ if prompt_length < 2:
78
  text_hint += f"[ERROR] Please give a longer prompt text \n"
79
  gr.Warning("Please give a longer prompt text")
80
  return (
 
82
  None,
83
  None,
84
  )
85
+ if prompt_length > 50:
86
+ text_hint += f"[ERROR] Text length limited to 50 words for this demo, please try shorter text. You can clone our open-source repo and try for your usage \n"
87
  gr.Warning(
88
  "Text length limited to 200 characters for this demo, please try shorter text. You can clone our open-source repo for your usage"
89
  )