Gregniuki commited on
Commit
18a354d
·
1 Parent(s): 6185ee4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -95
app.py CHANGED
@@ -146,90 +146,44 @@ async def main(
146
  )
147
  else:
148
  voice_model_names = []
149
- for current in onnx_models:
150
  voice_struct = current.split("/")[5]
151
  voice_model_names.append(voice_struct)
152
- if enhanced_accessibility:
153
- playaudio("selectmodel")
154
- selection = widgets.Dropdown(
155
- options=voice_model_names,
156
- description=f'{lan.translate(lang, "Select voice package")}:',
157
- )
158
- load_btn = widgets.Button(
159
- description=lan.translate(lang, "Load it!")
160
- )
161
- config = None
162
- def load_model(button):
163
- nonlocal config
164
- global onnx_model
165
- nonlocal model
166
- nonlocal models_path
167
- selected_voice = selection.value
168
- onnx_model = f"{models_path}/{selected_voice}"
169
- model, config = load_onnx(onnx_model, sess_options, providers)
170
- if enhanced_accessibility:
171
- playaudio("loaded")
172
- if config["num_speakers"] > 1:
173
- speaker_selection.options = config["speaker_id_map"].values()
174
- speaker_selection.layout.visibility = 'visible'
175
- if enhanced_accessibility:
176
- playaudio("multispeaker")
177
- else:
178
- speaker_selection.layout.visibility = 'hidden'
179
-
180
- load_btn.on_click(load_model)
181
- display(selection, load_btn)
182
- display(speaker_selection)
183
- speed_slider = widgets.FloatSlider(
184
- value=1,
185
- min=0.25,
186
- max=4,
187
- step=0.1,
188
- description=lan.translate(lang, "Rate scale"),
189
- orientation='horizontal',
190
- )
191
- noise_scale_slider = widgets.FloatSlider(
192
- value=0.667,
193
- min=0.25,
194
- max=4,
195
- step=0.1,
196
- description=lan.translate(lang, "Phoneme noise scale"),
197
- orientation='horizontal',
198
- )
199
- noise_scale_w_slider = widgets.FloatSlider(
200
- value=1,
201
- min=0.25,
202
- max=4,
203
- step=0.1,
204
- description=lan.translate(lang, "Phoneme stressing scale"),
205
- orientation='horizontal',
206
- )
207
- play = widgets.Checkbox(
208
- value=True,
209
- description=lan.translate(lang, "Auto-play"),
210
- disabled=False
211
- )
212
- text_input = widgets.Text(
213
- value='',
214
- placeholder=f'{lan.translate(lang, "Enter your text here")}:',
215
- description=lan.translate(lang, "Text to synthesize"),
216
- layout=widgets.Layout(width='80%')
217
- )
218
- synthesize_button = widgets.Button(
219
- description=lan.translate(lang, "Synthesize"),
220
- button_style='success', # 'success', 'info', 'warning', 'danger' or ''
221
- tooltip=lan.translate(lang, "Click here to synthesize the text."),
222
- icon='check'
223
- )
224
- close_button = widgets.Button(
225
- description=lan.translate(lang, "Exit"),
226
- tooltip=lan.translate(lang, "Closes this GUI."),
227
- icon='check'
228
- )
229
- return {"message": f"Text to synthesize: {text_input}, Speed: {speed_slider}, Play: {play}"}
230
 
231
 
232
- def on_synthesize_button_clicked(b):
233
  if model is None:
234
  if enhanced_accessibility:
235
  playaudio("nomodel")
@@ -245,20 +199,8 @@ async def main(
245
  auto_play = play.value
246
  inferencing(model, config, sid, text, rate, noise_scale, noise_scale_w, auto_play)
247
 
248
- def on_close_button_clicked(b):
249
- clear_output()
250
- if enhanced_accessibility:
251
- playaudio("exit")
252
-
253
- synthesize_button.on_click(on_synthesize_button_clicked)
254
- close_button.on_click(on_close_button_clicked)
255
- display(text_input)
256
- display(speed_slider)
257
- display(noise_scale_slider)
258
- display(noise_scale_w_slider)
259
- display(play)
260
- display(synthesize_button)
261
- display(close_button)
262
 
263
  def load_onnx(model, sess_options, providers = ["CPUExecutionProvider"]):
264
  _LOGGER.debug("Loading model from %s", model)
@@ -453,7 +395,7 @@ async def read_root(request: Request):
453
 
454
 
455
  if __name__ == "__main__":
456
- main()
457
  import uvicorn
458
  uvicorn.run(app, host="0.0.0.0", port=7860)
459
  # main()
 
146
  )
147
  else:
148
  voice_model_names = []
149
+ # for current in onnx_models:
150
  voice_struct = current.split("/")[5]
151
  voice_model_names.append(voice_struct)
152
+ # if enhanced_accessibility:
153
+ # playaudio("selectmodel")
154
+ # selection = widgets.Dropdown(
155
+ # options=voice_model_names,
156
+ # description=f'{lan.translate(lang, "Select voice package")}:',
157
+ # )
158
+ # load_btn = widgets.Button(
159
+ # description=lan.translate(lang, "Load it!")
160
+ # )
161
+ # config = None
162
+ # def load_model(button):
163
+ # nonlocal config
164
+ # global onnx_model
165
+ # nonlocal model
166
+ # nonlocal models_path
167
+ # selected_voice = selection.value
168
+ onnx_model = f"{models_path}/{selected_voice}"
169
+ model, config = load_onnx(onnx_model, sess_options, providers)
170
+ # if enhanced_accessibility:
171
+ # playaudio("loaded")
172
+ # if config["num_speakers"] > 1:
173
+ # speaker_selection.options = config["speaker_id_map"].values()
174
+ # speaker_selection.layout.visibility = 'visible'
175
+ # if enhanced_accessibility:
176
+ # playaudio("multispeaker")
177
+ # else:
178
+ # speaker_selection.layout.visibility = 'hidden'
179
+
180
+ # load_btn.on_click(load_model)
181
+ # display(selection, load_btn)
182
+ # display(speaker_selection)
183
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
184
 
185
 
186
+
187
  if model is None:
188
  if enhanced_accessibility:
189
  playaudio("nomodel")
 
199
  auto_play = play.value
200
  inferencing(model, config, sid, text, rate, noise_scale, noise_scale_w, auto_play)
201
 
202
+
203
+ return {"message": f"Text to synthesize: {text_input}, Speed: {speed_slider}, Play: {play}"}
 
 
 
 
 
 
 
 
 
 
 
 
204
 
205
  def load_onnx(model, sess_options, providers = ["CPUExecutionProvider"]):
206
  _LOGGER.debug("Loading model from %s", model)
 
395
 
396
 
397
  if __name__ == "__main__":
398
+ # main()
399
  import uvicorn
400
  uvicorn.run(app, host="0.0.0.0", port=7860)
401
  # main()