Spaces:
Running
Running
Update src/covergen.py
Browse files5 unmodified lines67899101112131415161718192019 unmodified lines40414243444546474849505152535455565758596061626364656667686969 unmodified lines1391401411421431441451461471481491501511521531541551561573 unmodified lines1611621631641651661671681691701715 unmodified linesfrom modules.model_management import ignore_files, update_models_list, download_from_url, upload_zip_model, upload_separate_filesfrom modules.ui_updates import show_hop_slider, update_f0_method, update_button_text_voc, update_button_text_inst, swap_visibility, swap_buttonsfrom modules.file_processing import process_file_upload
import osimport reimport randomfrom scipy.io.wavfile import writefrom scipy.io.wavfile import readimport numpy as npimport gradio as grimport yt_dlpimport subprocess
separator = Separator()
19 unmodified lines {"model_name": "UVR-DeEcho-DeReverb by FoxJoy", "checkpoint": "UVR-DeEcho-DeReverb.pth"},]
def download_audio(url): ydl_opts = { 'format': 'bestaudio/best', 'outtmpl': 'ytdl/%(title)s.%(ext)s', 'postprocessors': [{ 'key': 'FFmpegExtractAudio', 'preferredcodec': 'wav', 'preferredquality': '192', }], }
with yt_dlp.YoutubeDL(ydl_opts) as ydl: info_dict = ydl.extract_info(url, download=True) file_path = ydl.prepare_filename(info_dict).rsplit('.', 1)[0] + '.wav' sample_rate, audio_data = read(file_path) audio_array = np.asarray(audio_data, dtype=np.int16)
return sample_rate, audio_array
def inf_handler(audio, model_name): model_found = False for model_info in UVR_5_MODELS:69 unmodified lines
with gr.Tab(" π§ Vocal Separator (UVR)"): gr.Markdown("β Separate vocals and instruments from an audio file using UVR models.")
with gr.Accordion("π Separation by Link", open=False): with gr.Row(): mdx23c_link = gr.Textbox(label="π Link",placeholder="π Paste the link here",interactive=True) with gr.Row(): gr.Markdown("π‘ You can paste the link to the video/audio from many sites, check the complete list [here](https://github.com/yt-dlp/yt-dlp/blob/master/supportedsites.md)") with gr.Row(): mdx23c_download_button = gr.Button("β¬οΈ Download!",variant="primary")
uvr5_audio_file = gr.Audio(label=" π² Audio File",type="filepath")
with gr.Row():3 unmodified lines uvr5_output_voc = gr.Audio(type="filepath", label="Output 1",) uvr5_output_inst = gr.Audio(type="filepath", label="Output 2",)
mdx23c_download_button.click(download_audio, [mdx23c_link], [uvr5_audio_file])
uvr5_button.click(inference, [uvr5_audio_file, uvr5_model], [uvr5_output_voc, uvr5_output_inst])
src/covergen.py+51-1