ArkanDash commited on
Commit
514a392
1 Parent(s): 29ebaa9

feat: update infer

Browse files
Files changed (1) hide show
  1. app.py +37 -24
app.py CHANGED
@@ -168,25 +168,17 @@ def cut_vocal_and_inst(url, audio_provider, split_model):
168
  os.mkdir("dl_audio")
169
  if audio_provider == "Youtube":
170
  ydl_opts = {
171
- 'format': 'bestaudio/best',
172
- 'postprocessors': [{
173
- 'key': 'FFmpegExtractAudio',
174
- 'preferredcodec': 'wav',
175
- }],
176
- "outtmpl": 'dl_audio/youtube_audio',
 
177
  }
178
  with yt_dlp.YoutubeDL(ydl_opts) as ydl:
179
  ydl.download([url])
180
  audio_path = "dl_audio/youtube_audio.wav"
181
- else:
182
- # Spotify doesnt work.
183
- # Need to find other solution soon.
184
- '''
185
- command = f"spotdl download {url} --output dl_audio/.wav"
186
- result = subprocess.run(command.split(), stdout=subprocess.PIPE)
187
- print(result.stdout.decode())
188
- audio_path = "dl_audio/spotify_audio.wav"
189
- '''
190
  if split_model == "htdemucs":
191
  command = f"demucs --two-stems=vocals {audio_path} -o output"
192
  result = subprocess.run(command.split(), stdout=subprocess.PIPE)
@@ -239,6 +231,7 @@ def change_audio_mode(vc_audio_mode):
239
  return (
240
  # Input & Upload
241
  gr.Textbox.update(visible=True),
 
242
  gr.Audio.update(visible=False),
243
  # Youtube
244
  gr.Dropdown.update(visible=False),
@@ -259,6 +252,7 @@ def change_audio_mode(vc_audio_mode):
259
  return (
260
  # Input & Upload
261
  gr.Textbox.update(visible=False),
 
262
  gr.Audio.update(visible=True),
263
  # Youtube
264
  gr.Dropdown.update(visible=False),
@@ -279,6 +273,7 @@ def change_audio_mode(vc_audio_mode):
279
  return (
280
  # Input & Upload
281
  gr.Textbox.update(visible=False),
 
282
  gr.Audio.update(visible=False),
283
  # Youtube
284
  gr.Dropdown.update(visible=True),
@@ -299,6 +294,7 @@ def change_audio_mode(vc_audio_mode):
299
  return (
300
  # Input & Upload
301
  gr.Textbox.update(visible=False),
 
302
  gr.Audio.update(visible=False),
303
  # Youtube
304
  gr.Dropdown.update(visible=False),
@@ -319,6 +315,7 @@ def change_audio_mode(vc_audio_mode):
319
  return (
320
  # Input & Upload
321
  gr.Textbox.update(visible=False),
 
322
  gr.Audio.update(visible=True),
323
  # Youtube
324
  gr.Dropdown.update(visible=False),
@@ -336,6 +333,12 @@ def change_audio_mode(vc_audio_mode):
336
  gr.Dropdown.update(visible=False)
337
  )
338
 
 
 
 
 
 
 
339
  if __name__ == '__main__':
340
  load_hubert()
341
  categories = load_model()
@@ -343,10 +346,12 @@ if __name__ == '__main__':
343
  voices = [f"{v['ShortName']}-{v['Gender']}" for v in tts_voice_list]
344
  with gr.Blocks() as app:
345
  gr.Markdown(
346
- "# <center> RVC Genshin Impact\n"
347
- "### <center> [Recommended to use Google Colab to use more character & more feature](https://colab.research.google.com/drive/110kiMZTdP6Ri1lY9-NbQf17GVPPhHyeT?usp=sharing)\n"
348
- "#### From [Retrieval-based-Voice-Conversion](https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI)\n"
349
- "### This spaces use [Multi Model RVC Inference](https://github.com/ArkanDash/Multi-Model-RVC-Inference)"
 
 
350
  )
351
  for (folder_title, folder, description, models) in categories:
352
  with gr.TabItem(folder_title):
@@ -371,9 +376,11 @@ if __name__ == '__main__':
371
  with gr.Row():
372
  with gr.Column():
373
  vc_audio_mode = gr.Dropdown(label="Input voice", choices=audio_mode, allow_custom_value=False, value="Upload audio")
374
- # Input and Upload
375
  vc_input = gr.Textbox(label="Input audio path", visible=False)
376
- vc_upload = gr.Audio(label="Upload audio file", visible=True, interactive=True)
 
 
377
  # Youtube
378
  vc_download_audio = gr.Dropdown(label="Provider", choices=["Youtube"], allow_custom_value=False, visible=False, value="Youtube", info="Select provider (Default: Youtube)")
379
  vc_link = gr.Textbox(label="Youtube URL", visible=False, info="Example: https://www.youtube.com/watch?v=Nc0sB1Bmf-A", placeholder="https://www.youtube.com/watch?v=...")
@@ -457,7 +464,7 @@ if __name__ == '__main__':
457
  fn=vc_fn,
458
  inputs=[
459
  vc_audio_mode,
460
- vc_input,
461
  vc_upload,
462
  tts_text,
463
  tts_voice,
@@ -481,11 +488,17 @@ if __name__ == '__main__':
481
  inputs=[vc_output, vc_volume, vc_split_model],
482
  outputs=[vc_combined_output]
483
  )
 
 
 
 
 
484
  vc_audio_mode.change(
485
  fn=change_audio_mode,
486
  inputs=[vc_audio_mode],
487
  outputs=[
488
- vc_input,
 
489
  vc_upload,
490
  vc_download_audio,
491
  vc_link,
@@ -501,4 +514,4 @@ if __name__ == '__main__':
501
  tts_voice
502
  ]
503
  )
504
- app.queue(concurrency_count=1, max_size=50, api_open=config.api).launch(share=config.colab)
 
168
  os.mkdir("dl_audio")
169
  if audio_provider == "Youtube":
170
  ydl_opts = {
171
+ 'noplaylist': True,
172
+ 'format': 'bestaudio/best',
173
+ 'postprocessors': [{
174
+ 'key': 'FFmpegExtractAudio',
175
+ 'preferredcodec': 'wav',
176
+ }],
177
+ "outtmpl": 'dl_audio/youtube_audio',
178
  }
179
  with yt_dlp.YoutubeDL(ydl_opts) as ydl:
180
  ydl.download([url])
181
  audio_path = "dl_audio/youtube_audio.wav"
 
 
 
 
 
 
 
 
 
182
  if split_model == "htdemucs":
183
  command = f"demucs --two-stems=vocals {audio_path} -o output"
184
  result = subprocess.run(command.split(), stdout=subprocess.PIPE)
 
231
  return (
232
  # Input & Upload
233
  gr.Textbox.update(visible=True),
234
+ gr.Checkbox.update(visible=False),
235
  gr.Audio.update(visible=False),
236
  # Youtube
237
  gr.Dropdown.update(visible=False),
 
252
  return (
253
  # Input & Upload
254
  gr.Textbox.update(visible=False),
255
+ gr.Checkbox.update(visible=True),
256
  gr.Audio.update(visible=True),
257
  # Youtube
258
  gr.Dropdown.update(visible=False),
 
273
  return (
274
  # Input & Upload
275
  gr.Textbox.update(visible=False),
276
+ gr.Checkbox.update(visible=False),
277
  gr.Audio.update(visible=False),
278
  # Youtube
279
  gr.Dropdown.update(visible=True),
 
294
  return (
295
  # Input & Upload
296
  gr.Textbox.update(visible=False),
297
+ gr.Checkbox.update(visible=False),
298
  gr.Audio.update(visible=False),
299
  # Youtube
300
  gr.Dropdown.update(visible=False),
 
315
  return (
316
  # Input & Upload
317
  gr.Textbox.update(visible=False),
318
+ gr.Checkbox.update(visible=True),
319
  gr.Audio.update(visible=True),
320
  # Youtube
321
  gr.Dropdown.update(visible=False),
 
333
  gr.Dropdown.update(visible=False)
334
  )
335
 
336
+ def use_microphone(microphone):
337
+ if microphone == True:
338
+ return gr.Audio.update(source="microphone")
339
+ else:
340
+ return gr.Audio.update(source="upload")
341
+
342
  if __name__ == '__main__':
343
  load_hubert()
344
  categories = load_model()
 
346
  voices = [f"{v['ShortName']}-{v['Gender']}" for v in tts_voice_list]
347
  with gr.Blocks() as app:
348
  gr.Markdown(
349
+ "<div align='center'>\n\n"+
350
+ "# RVC Genshin Impact\n\n"+
351
+ "[![Repository](https://img.shields.io/badge/Github-Multi%20Model%20RVC%20Inference-blue?style=for-the-badge&logo=github)](https://github.com/ArkanDash/Multi-Model-RVC-Inference)\n"+
352
+ "[![Colab](https://img.shields.io/badge/Colab-RVC%20Genshin%20Impact-blue?style=for-the-badge&logo=googlecolab)](https://colab.research.google.com/drive/110kiMZTdP6Ri1lY9-NbQf17GVPPhHyeT?usp=sharing)\n\n"+
353
+ "### Recommended to use Google Colab to use other character and feature.\n\n"+
354
+ "</div>"
355
  )
356
  for (folder_title, folder, description, models) in categories:
357
  with gr.TabItem(folder_title):
 
376
  with gr.Row():
377
  with gr.Column():
378
  vc_audio_mode = gr.Dropdown(label="Input voice", choices=audio_mode, allow_custom_value=False, value="Upload audio")
379
+ # Input
380
  vc_input = gr.Textbox(label="Input audio path", visible=False)
381
+ # Upload
382
+ vc_microphone_mode = gr.Checkbox(label="Use Microphone", value=False, visible=True, interactive=False)
383
+ vc_upload = gr.Audio(label="Upload audio file", source="upload", visible=True, interactive=True)
384
  # Youtube
385
  vc_download_audio = gr.Dropdown(label="Provider", choices=["Youtube"], allow_custom_value=False, visible=False, value="Youtube", info="Select provider (Default: Youtube)")
386
  vc_link = gr.Textbox(label="Youtube URL", visible=False, info="Example: https://www.youtube.com/watch?v=Nc0sB1Bmf-A", placeholder="https://www.youtube.com/watch?v=...")
 
464
  fn=vc_fn,
465
  inputs=[
466
  vc_audio_mode,
467
+ vc_input,
468
  vc_upload,
469
  tts_text,
470
  tts_voice,
 
488
  inputs=[vc_output, vc_volume, vc_split_model],
489
  outputs=[vc_combined_output]
490
  )
491
+ vc_microphone_mode.change(
492
+ fn=use_microphone,
493
+ inputs=vc_microphone_mode,
494
+ outputs=vc_upload
495
+ )
496
  vc_audio_mode.change(
497
  fn=change_audio_mode,
498
  inputs=[vc_audio_mode],
499
  outputs=[
500
+ vc_input,
501
+ vc_microphone_mode,
502
  vc_upload,
503
  vc_download_audio,
504
  vc_link,
 
514
  tts_voice
515
  ]
516
  )
517
+ app.queue(concurrency_count=1, max_size=20, api_open=config.api).launch(share=config.colab)