mrfakename commited on
Commit
4cbfe7b
1 Parent(s): 635f007

Add concurrency limit

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -16,8 +16,10 @@ voices = {
16
  def synthesize(text, voice):
17
  if text.strip() == "":
18
  raise gr.Error("You must enter some text")
 
 
19
  v = voice.lower()
20
- return (24000, styletts2importable.inference(text, voices[v], alpha=0.3, beta=0.7, diffusion_steps=15, embedding_scale=1))
21
 
22
  with gr.Blocks(title="StyleTTS 2", css="footer{display:none !important}", theme=theme) as demo:
23
  gr.Markdown("""# StyleTTS 2
@@ -39,8 +41,8 @@ Is there a long queue on this space? Duplicate it and add a GPU to skip the wait
39
  with gr.Column(scale=1):
40
  btn = gr.Button("Synthesize")
41
  audio = gr.Audio(interactive=False, label="Synthesized Audio")
42
- btn.click(synthesize, inputs=[inp, voice], outputs=[audio])
43
 
44
  if __name__ == "__main__":
45
- demo.launch(show_api=False)
46
 
 
16
  def synthesize(text, voice):
17
  if text.strip() == "":
18
  raise gr.Error("You must enter some text")
19
+ if len(text) > 500:
20
+ raise gr.Error("Text must be under 500 characters")
21
  v = voice.lower()
22
+ return (24000, styletts2importable.inference(text, voices[v], alpha=0.3, beta=0.7, diffusion_steps=7, embedding_scale=1))
23
 
24
  with gr.Blocks(title="StyleTTS 2", css="footer{display:none !important}", theme=theme) as demo:
25
  gr.Markdown("""# StyleTTS 2
 
41
  with gr.Column(scale=1):
42
  btn = gr.Button("Synthesize")
43
  audio = gr.Audio(interactive=False, label="Synthesized Audio")
44
+ btn.click(synthesize, inputs=[inp, voice], outputs=[audio], concurrency_limit=4)
45
 
46
  if __name__ == "__main__":
47
+ demo.queue(api_open=False, max_size=15).launch(show_api=False)
48