Spaces:
Sleeping
Sleeping
Update app.py
Browse files157 unmodified lines1581591601611621631641651661671681691701611621631641651661771671681691791801811821831841851861871881891901911701711723 unmodified lines176177178201179180181182183184185208209210211212213214215186187188189190220221191192193194157 unmodified lines zipf.write(file_path, arcname) return zip_file
# Function to upload zip file to Hugging Face Hubdef upload_to_huggingface(zip_file, repo_id, hf_token): api = HfApi() api.upload_file( path_or_fileobj=zip_file, path_in_repo=os.path.basename(zip_file), repo_id=repo_id, token=hf_token ) return f"File uploaded to {repo_id}/{os.path.basename(zip_file)}"
# Gradio interfacedef process_audio(url, audio_name): file_path = download_youtube_audio(url, audio_name) dataset_path = slice_audio(file_path, audio_name) zip_file = zip_directory(dataset_path, audio_name) return zip_file return zip_file, print(f"{zip_file} successfully processed")
# upload to hfdef push_to_hub(hf_token, repo_id): zip_file = zip_directory(dataset_path, audio_name) upload_message = upload_to_huggingface(zip_file, repo_id, hf_token) return upload_message # create new repository (optional)def create_new_repo(repoid): try: create_repo(repoid) return f"Repo '{repoid}' created successfully!" except Exception as e: return str(e)
negra = gr.themes.Base(3 unmodified lines
with gr.Blocks(theme=negra) as demo: gr.Markdown("# <div style='text-align: center;'> RVC DATASET MAKER</div>") gr.Markdown(" <div style='text-align: center;'> only work for audio only vocal!</div>") gr.Markdown(" <div style='text-align: center;'> only work for vocal only audio!</div>") with gr.Tabs(): with gr.TabItem("make dataset"): with gr.Row(): url_input = gr.Textbox(label="YouTube URL", placeholder="https://youtu.be/ZdoiTX1f1tU?si=hZ96tryqaPIYfwg1") with gr.Row(): audio_name_input = gr.Textbox(label="Audio Name", placeholder="Amy") with gr.Row(): with gr.Accordion("Export dataset to huggingface (optional)", visible=False): with gr.Row(): hf_token_input = gr.Textbox(label="Hugging Face Token") repo_id_input = gr.Textbox(label="Repository ID") with gr.Row(): push_hub = gr.Button("Hugging Face Upload") upload_output = gr.Textbox(label="Hugging Face Upload Status") with gr.Row(): result_output = gr.File(label="Download Sliced Audio Zip") result_process = gr.Textbox(label="Sliced Audio output") with gr.Row(): run_button = gr.Button("Slice 👾 Audio") run_button.click(fn=process_audio, inputs=[url_input, audio_name_input], outputs=[result_output]) push_hub.click(fn=push_to_hub, inputs=[result_output, hf_token_input, repo_id_input], outputs=[upload_output]) run_button.click(fn=process_audio, inputs=[url_input, audio_name_input], outputs=[result_output, result_process]) with gr.TabItem("note"): with gr.Row(): gr.Markdown(app.py+5-35