mrfakename commited on
Commit
6440f80
1 Parent(s): 5967c32

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -20
app.py CHANGED
@@ -32,12 +32,8 @@ for v in voicelist:
32
  def synthesize(text, voice, lngsteps, password, progress=gr.Progress()):
33
  if text.strip() == "":
34
  raise gr.Error("You must enter some text")
35
- if lngsteps > 25:
36
- raise gr.Error("Max 25 steps")
37
- if lngsteps < 5:
38
- raise gr.Error("Min 5 steps")
39
- if len(text) > 5000:
40
- raise gr.Error("Text must be <5k characters")
41
  texts = split_and_recombine_text(text)
42
  v = voice.lower()
43
  audios = []
@@ -61,21 +57,41 @@ def synthesize(text, voice, lngsteps, password, progress=gr.Progress()):
61
  # else:
62
  # raise gr.Error('Wrong access code')
63
  def clsynthesize(text, voice, vcsteps):
 
 
 
 
 
 
 
64
  if text.strip() == "":
65
  raise gr.Error("You must enter some text")
66
- # if global_phonemizer.phonemize([text]) > 300:
67
- if len(text) > 400:
68
- raise gr.Error("Text must be under 400 characters")
69
- # return (24000, styletts2importable.inference(text, styletts2importable.compute_style(voice), alpha=0.3, beta=0.7, diffusion_steps=20, embedding_scale=1))
70
- return (24000, styletts2importable.inference(text, styletts2importable.compute_style(voice), alpha=0.3, beta=0.7, diffusion_steps=vcsteps, embedding_scale=1))
71
- def ljsynthesize(text):
 
 
 
 
 
 
 
 
 
 
72
  if text.strip() == "":
73
  raise gr.Error("You must enter some text")
74
- # if global_phonemizer.phonemize([text]) > 300:
75
- if len(text) > 400:
76
- raise gr.Error("Text must be under 400 characters")
77
- noise = torch.randn(1,1,256).to('cuda' if torch.cuda.is_available() else 'cpu')
78
- return (24000, ljspeechimportable.inference(text, noise, diffusion_steps=7, embedding_scale=1))
 
 
 
79
 
80
 
81
  with gr.Blocks() as vctk: # just realized it isn't vctk but libritts but i'm too lazy to change it rn
@@ -83,7 +99,7 @@ with gr.Blocks() as vctk: # just realized it isn't vctk but libritts but i'm too
83
  with gr.Column(scale=1):
84
  inp = gr.Textbox(label="Text", info="What would you like StyleTTS 2 to read? It works better on full sentences.", interactive=True)
85
  voice = gr.Dropdown(voicelist, label="Voice", info="Select a default voice.", value='m-us-2', interactive=True)
86
- multispeakersteps = gr.Slider(minimum=5, maximum=15, value=7, step=1, label="Diffusion Steps", info="Higher = better quality, but slower", interactive=True)
87
  # use_gruut = gr.Checkbox(label="Use alternate phonemizer (Gruut) - Experimental")
88
  with gr.Column(scale=1):
89
  btn = gr.Button("Synthesize", variant="primary")
@@ -94,7 +110,7 @@ with gr.Blocks() as clone:
94
  with gr.Column(scale=1):
95
  clinp = gr.Textbox(label="Text", info="What would you like StyleTTS 2 to read? It works better on full sentences.", interactive=True)
96
  clvoice = gr.Audio(label="Voice", interactive=True, type='filepath', max_length=300)
97
- vcsteps = gr.Slider(minimum=5, maximum=20, value=20, step=1, label="Diffusion Steps", info="Higher = better quality, but slower", interactive=True)
98
  with gr.Column(scale=1):
99
  clbtn = gr.Button("Synthesize", variant="primary")
100
  claudio = gr.Audio(interactive=False, label="Synthesized Audio")
@@ -114,10 +130,11 @@ with gr.Blocks() as lj:
114
  with gr.Row():
115
  with gr.Column(scale=1):
116
  ljinp = gr.Textbox(label="Text", info="What would you like StyleTTS 2 to read? It works better on full sentences.", interactive=True)
 
117
  with gr.Column(scale=1):
118
  ljbtn = gr.Button("Synthesize", variant="primary")
119
  ljaudio = gr.Audio(interactive=False, label="Synthesized Audio")
120
- ljbtn.click(ljsynthesize, inputs=[ljinp], outputs=[ljaudio], concurrency_limit=4)
121
  with gr.Blocks(title="StyleTTS 2", css="footer{display:none !important}", theme=theme) as demo:
122
  gr.Markdown("""# StyleTTS 2
123
 
 
32
  def synthesize(text, voice, lngsteps, password, progress=gr.Progress()):
33
  if text.strip() == "":
34
  raise gr.Error("You must enter some text")
35
+ if len(text) > 7500:
36
+ raise gr.Error("Text must be <7.5k characters")
 
 
 
 
37
  texts = split_and_recombine_text(text)
38
  v = voice.lower()
39
  audios = []
 
57
  # else:
58
  # raise gr.Error('Wrong access code')
59
  def clsynthesize(text, voice, vcsteps):
60
+ # if text.strip() == "":
61
+ # raise gr.Error("You must enter some text")
62
+ # # if global_phonemizer.phonemize([text]) > 300:
63
+ # if len(text) > 400:
64
+ # raise gr.Error("Text must be under 400 characters")
65
+ # # return (24000, styletts2importable.inference(text, styletts2importable.compute_style(voice), alpha=0.3, beta=0.7, diffusion_steps=20, embedding_scale=1))
66
+ # return (24000, styletts2importable.inference(text, styletts2importable.compute_style(voice), alpha=0.3, beta=0.7, diffusion_steps=vcsteps, embedding_scale=1))
67
  if text.strip() == "":
68
  raise gr.Error("You must enter some text")
69
+ if len(text) > 7500:
70
+ raise gr.Error("Text must be <7.5k characters")
71
+ texts = split_and_recombine_text(text)
72
+ v = voice.lower()
73
+ audios = []
74
+ for t in progress.tqdm(texts):
75
+ audios.append(styletts2importable.inference(t, styletts2importable.compute_style(voice), alpha=0.3, beta=0.7, diffusion_steps=vcsteps, embedding_scale=1))
76
+ return (24000, np.concatenate(audios))
77
+ def ljsynthesize(text, steps):
78
+ # if text.strip() == "":
79
+ # raise gr.Error("You must enter some text")
80
+ # # if global_phonemizer.phonemize([text]) > 300:
81
+ # if len(text) > 400:
82
+ # raise gr.Error("Text must be under 400 characters")
83
+ noise = torch.randn(1,1,256).to('cuda' if torch.cuda.is_available() else 'cpu')
84
+ # return (24000, ljspeechimportable.inference(text, noise, diffusion_steps=7, embedding_scale=1))
85
  if text.strip() == "":
86
  raise gr.Error("You must enter some text")
87
+ if len(text) > 7500:
88
+ raise gr.Error("Text must be <7.5k characters")
89
+ texts = split_and_recombine_text(text)
90
+ v = voice.lower()
91
+ audios = []
92
+ for t in progress.tqdm(texts):
93
+ audios.append(ljspeechimportable.inference(t, noise, diffusion_steps=steps, embedding_scale=1))
94
+ return (24000, np.concatenate(audios))
95
 
96
 
97
  with gr.Blocks() as vctk: # just realized it isn't vctk but libritts but i'm too lazy to change it rn
 
99
  with gr.Column(scale=1):
100
  inp = gr.Textbox(label="Text", info="What would you like StyleTTS 2 to read? It works better on full sentences.", interactive=True)
101
  voice = gr.Dropdown(voicelist, label="Voice", info="Select a default voice.", value='m-us-2', interactive=True)
102
+ multispeakersteps = gr.Slider(minimum=3, maximum=15, value=7, step=1, label="Diffusion Steps", info="Higher = better quality, but slower", interactive=True)
103
  # use_gruut = gr.Checkbox(label="Use alternate phonemizer (Gruut) - Experimental")
104
  with gr.Column(scale=1):
105
  btn = gr.Button("Synthesize", variant="primary")
 
110
  with gr.Column(scale=1):
111
  clinp = gr.Textbox(label="Text", info="What would you like StyleTTS 2 to read? It works better on full sentences.", interactive=True)
112
  clvoice = gr.Audio(label="Voice", interactive=True, type='filepath', max_length=300)
113
+ vcsteps = gr.Slider(minimum=3, maximum=20, value=20, step=1, label="Diffusion Steps", info="Higher = better quality, but slower", interactive=True)
114
  with gr.Column(scale=1):
115
  clbtn = gr.Button("Synthesize", variant="primary")
116
  claudio = gr.Audio(interactive=False, label="Synthesized Audio")
 
130
  with gr.Row():
131
  with gr.Column(scale=1):
132
  ljinp = gr.Textbox(label="Text", info="What would you like StyleTTS 2 to read? It works better on full sentences.", interactive=True)
133
+ ljsteps = gr.Slider(minimum=3, maximum=20, value=20, step=1, label="Diffusion Steps", info="Higher = better quality, but slower", interactive=True)
134
  with gr.Column(scale=1):
135
  ljbtn = gr.Button("Synthesize", variant="primary")
136
  ljaudio = gr.Audio(interactive=False, label="Synthesized Audio")
137
+ ljbtn.click(ljsynthesize, inputs=[ljinp, ljsteps], outputs=[ljaudio], concurrency_limit=4)
138
  with gr.Blocks(title="StyleTTS 2", css="footer{display:none !important}", theme=theme) as demo:
139
  gr.Markdown("""# StyleTTS 2
140