DJQmUKV commited on
Commit
b6d83ca
1 Parent(s): b2ed3fb
Files changed (1) hide show
  1. app_multi.py +73 -2
app_multi.py CHANGED
@@ -212,6 +212,61 @@ async def edge_tts_vc_func(
212
  )
213
 
214
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
215
  with app:
216
  gr.Markdown(
217
  '## Simple, Stupid RVC Inference WebUI\n'
@@ -279,6 +334,14 @@ with app:
279
  type='index'
280
  )
281
 
 
 
 
 
 
 
 
 
282
  output_audio = gr.Audio(label='Output audio')
283
  output_msg = gr.Textbox(label='Output message')
284
 
@@ -296,7 +359,7 @@ with app:
296
  feat_ratio
297
  ],
298
  outputs=[output_audio, output_msg, model_info],
299
- fn=vc_func,
300
  cache_examples=args.cache_examples,
301
  run_on_click=args.cache_examples
302
  )
@@ -311,7 +374,7 @@ with app:
311
  f0_method, feat_ratio
312
  ],
313
  outputs=[output_audio, output_msg, model_info],
314
- fn=edge_tts_vc_func,
315
  cache_examples=args.cache_examples,
316
  run_on_click=args.cache_examples
317
  )
@@ -333,6 +396,14 @@ with app:
333
  api_name='tts_conversion'
334
  )
335
 
 
 
 
 
 
 
 
 
336
  app.queue(
337
  concurrency_count=1,
338
  max_size=20,
 
212
  )
213
 
214
 
215
+ def update_model_info(model_index):
216
+ if model_index is None:
217
+ return str(
218
+ '### Model info\n'
219
+ 'Please select a model from dropdown above.'
220
+ )
221
+
222
+ model = loaded_models[model_index]
223
+ model_icon = model['metadata'].get('icon', '')
224
+
225
+ return str(
226
+ '### Model info\n'
227
+ '![model icon]({icon})'
228
+ '**{name}**\n\n'
229
+ 'Author: {author}\n\n'
230
+ 'Source: {source}\n\n'
231
+ '{note}'
232
+ ).format(
233
+ name=model['metadata'].get('name'),
234
+ author=model['metadata'].get('author', 'Anonymous'),
235
+ source=model['metadata'].get('source', 'Unknown'),
236
+ note=model['metadata'].get('note', ''),
237
+ icon=(
238
+ model_icon
239
+ if model_icon.startswith(('http://', 'https://'))
240
+ else '/file/model/%s/%s' % (model['name'], model_icon)
241
+ )
242
+ )
243
+
244
+
245
+ def _example_vc(input_audio, model_index, pitch_adjust, f0_method, feat_ratio):
246
+ (audio, message) = vc_func(
247
+ input_audio, model_index, pitch_adjust, f0_method, feat_ratio
248
+ )
249
+ return (
250
+ audio,
251
+ message,
252
+ update_model_info(model_index)
253
+ )
254
+
255
+
256
+ async def _example_edge_tts(
257
+ input_text, model_index, tts_speaker, pitch_adjust, f0_method, feat_ratio
258
+ ):
259
+ (audio, message) = await edge_tts_vc_func(
260
+ input_text, model_index, tts_speaker, pitch_adjust, f0_method,
261
+ feat_ratio
262
+ )
263
+ return (
264
+ audio,
265
+ message,
266
+ update_model_info(model_index)
267
+ )
268
+
269
+
270
  with app:
271
  gr.Markdown(
272
  '## Simple, Stupid RVC Inference WebUI\n'
 
334
  type='index'
335
  )
336
 
337
+ # Model info
338
+ with gr.Box():
339
+ model_info = gr.Markdown(
340
+ '### Model info\n'
341
+ 'Please select a model from dropdown above.',
342
+ elem_id='model_info'
343
+ )
344
+
345
  output_audio = gr.Audio(label='Output audio')
346
  output_msg = gr.Textbox(label='Output message')
347
 
 
359
  feat_ratio
360
  ],
361
  outputs=[output_audio, output_msg, model_info],
362
+ fn=_example_vc,
363
  cache_examples=args.cache_examples,
364
  run_on_click=args.cache_examples
365
  )
 
374
  f0_method, feat_ratio
375
  ],
376
  outputs=[output_audio, output_msg, model_info],
377
+ fn=_example_edge_tts,
378
  cache_examples=args.cache_examples,
379
  run_on_click=args.cache_examples
380
  )
 
396
  api_name='tts_conversion'
397
  )
398
 
399
+ model_index.change(
400
+ update_model_info,
401
+ inputs=[model_index],
402
+ outputs=[model_info],
403
+ show_progress=False,
404
+ queue=False
405
+ )
406
+
407
  app.queue(
408
  concurrency_count=1,
409
  max_size=20,