mrfakename commited on
Commit
6cdd8f9
1 Parent(s): 73dbaa9
Files changed (1) hide show
  1. app.py +18 -14
app.py CHANGED
@@ -27,15 +27,18 @@ def synthesize(text, voice):
27
  raise gr.Error("Text must be under 300 characters")
28
  v = voice.lower()
29
  return (24000, styletts2importable.inference(text, voices[v], alpha=0.3, beta=0.7, diffusion_steps=7, embedding_scale=1))
30
- def longsynthesize(text, voice, progress=gr.Progress()):
31
- if text.strip() == "":
32
- raise gr.Error("You must enter some text")
33
- texts = split_and_recombine_text(text)
34
- v = voice.lower()
35
- audios = []
36
- for t in progress.tqdm(texts):
37
- audios.append(styletts2importable.inference(text, voices[v], alpha=0.3, beta=0.7, diffusion_steps=7, embedding_scale=1))
38
- return (24000, np.concatenate(audios))
 
 
 
39
  def clsynthesize(text, voice):
40
  if text.strip() == "":
41
  raise gr.Error("You must enter some text")
@@ -73,12 +76,13 @@ with gr.Blocks() as clone:
73
  with gr.Blocks() as longText:
74
  with gr.Row():
75
  with gr.Column(scale=1):
76
- clinp = gr.Textbox(label="Text", info="What would you like StyleTTS 2 to read? It works better on full sentences.", interactive=True)
77
- clvoice = gr.Audio(label="Voice", interactive=True, type='filepath', max_length=300)
 
78
  with gr.Column(scale=1):
79
- clbtn = gr.Button("Synthesize", variant="primary")
80
- claudio = gr.Audio(interactive=False, label="Synthesized Audio")
81
- clbtn.click(longsynthesize, inputs=[clinp, clvoice], outputs=[claudio], concurrency_limit=4)
82
  with gr.Blocks() as lj:
83
  with gr.Row():
84
  with gr.Column(scale=1):
 
27
  raise gr.Error("Text must be under 300 characters")
28
  v = voice.lower()
29
  return (24000, styletts2importable.inference(text, voices[v], alpha=0.3, beta=0.7, diffusion_steps=7, embedding_scale=1))
30
+ def longsynthesize(text, voice, password, progress=gr.Progress()):
31
+ if password == os.environ['ACCESS_CODE']:
32
+ if text.strip() == "":
33
+ raise gr.Error("You must enter some text")
34
+ texts = split_and_recombine_text(text)
35
+ v = voice.lower()
36
+ audios = []
37
+ for t in progress.tqdm(texts):
38
+ audios.append(styletts2importable.inference(text, voices[v], alpha=0.3, beta=0.7, diffusion_steps=7, embedding_scale=1))
39
+ return (24000, np.concatenate(audios))
40
+ else:
41
+ raise gr.Error('Wrong access code')
42
  def clsynthesize(text, voice):
43
  if text.strip() == "":
44
  raise gr.Error("You must enter some text")
 
76
  with gr.Blocks() as longText:
77
  with gr.Row():
78
  with gr.Column(scale=1):
79
+ lnginp = gr.Textbox(label="Text", info="What would you like StyleTTS 2 to read? It works better on full sentences.", interactive=True)
80
+ lngvoice = gr.Dropdown(voicelist, label="Voice", info="Select a default voice.", value='m-us-1', interactive=True)
81
+ lngpwd = gr.Textbox(label="Access code", info="This feature is in beta. You need an access code to use it as it uses more resources and we would like to prevent abuse")
82
  with gr.Column(scale=1):
83
+ lngbtn = gr.Button("Synthesize", variant="primary")
84
+ lngaudio = gr.Audio(interactive=False, label="Synthesized Audio")
85
+ lngbtn.click(longsynthesize, inputs=[lnginp, lngvoice, lngpwd], outputs=[lngaudio], concurrency_limit=4)
86
  with gr.Blocks() as lj:
87
  with gr.Row():
88
  with gr.Column(scale=1):