Hev832 commited on
Commit
4d89f7d
·
verified ·
1 Parent(s): ec6e908

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -35
app.py CHANGED
@@ -158,37 +158,15 @@ def zip_directory(directory_path, audio_name):
158
  zipf.write(file_path, arcname)
159
  return zip_file
160
 
161
- # Function to upload zip file to Hugging Face Hub
162
- def upload_to_huggingface(zip_file, repo_id, hf_token):
163
- api = HfApi()
164
- api.upload_file(
165
- path_or_fileobj=zip_file,
166
- path_in_repo=os.path.basename(zip_file),
167
- repo_id=repo_id,
168
- token=hf_token
169
- )
170
- return f"File uploaded to {repo_id}/{os.path.basename(zip_file)}"
171
 
172
  # Gradio interface
173
  def process_audio(url, audio_name):
174
  file_path = download_youtube_audio(url, audio_name)
175
  dataset_path = slice_audio(file_path, audio_name)
176
  zip_file = zip_directory(dataset_path, audio_name)
177
- return zip_file
 
178
 
179
- # upload to hf
180
- def push_to_hub(hf_token, repo_id):
181
- zip_file = zip_directory(dataset_path, audio_name)
182
- upload_message = upload_to_huggingface(zip_file, repo_id, hf_token)
183
- return upload_message
184
-
185
- # create new repository (optional)
186
- def create_new_repo(repoid):
187
- try:
188
- create_repo(repoid)
189
- return f"Repo '{repoid}' created successfully!"
190
- except Exception as e:
191
- return str(e)
192
 
193
 
194
  negra = gr.themes.Base(
@@ -198,27 +176,19 @@ negra = gr.themes.Base(
198
 
199
  with gr.Blocks(theme=negra) as demo:
200
  gr.Markdown("# <div style='text-align: center;'> RVC DATASET MAKER</div>")
201
- gr.Markdown(" <div style='text-align: center;'> only work for audio only vocal!</div>")
202
  with gr.Tabs():
203
  with gr.TabItem("make dataset"):
204
  with gr.Row():
205
  url_input = gr.Textbox(label="YouTube URL", placeholder="https://youtu.be/ZdoiTX1f1tU?si=hZ96tryqaPIYfwg1")
206
  with gr.Row():
207
  audio_name_input = gr.Textbox(label="Audio Name", placeholder="Amy")
208
- with gr.Row():
209
- with gr.Accordion("Export dataset to huggingface (optional)", visible=False):
210
- with gr.Row():
211
- hf_token_input = gr.Textbox(label="Hugging Face Token")
212
- repo_id_input = gr.Textbox(label="Repository ID")
213
- with gr.Row():
214
- push_hub = gr.Button("Hugging Face Upload")
215
- upload_output = gr.Textbox(label="Hugging Face Upload Status")
216
  with gr.Row():
217
  result_output = gr.File(label="Download Sliced Audio Zip")
 
218
  with gr.Row():
219
  run_button = gr.Button("Slice 👾 Audio")
220
- run_button.click(fn=process_audio, inputs=[url_input, audio_name_input], outputs=[result_output])
221
- push_hub.click(fn=push_to_hub, inputs=[result_output, hf_token_input, repo_id_input], outputs=[upload_output])
222
  with gr.TabItem("note"):
223
  with gr.Row():
224
  gr.Markdown(
 
158
  zipf.write(file_path, arcname)
159
  return zip_file
160
 
 
 
 
 
 
 
 
 
 
 
161
 
162
  # Gradio interface
163
  def process_audio(url, audio_name):
164
  file_path = download_youtube_audio(url, audio_name)
165
  dataset_path = slice_audio(file_path, audio_name)
166
  zip_file = zip_directory(dataset_path, audio_name)
167
+ return zip_file, print(f"{zip_file} successfully processed")
168
+
169
 
 
 
 
 
 
 
 
 
 
 
 
 
 
170
 
171
 
172
  negra = gr.themes.Base(
 
176
 
177
  with gr.Blocks(theme=negra) as demo:
178
  gr.Markdown("# <div style='text-align: center;'> RVC DATASET MAKER</div>")
179
+ gr.Markdown(" <div style='text-align: center;'> only work for vocal only audio!</div>")
180
  with gr.Tabs():
181
  with gr.TabItem("make dataset"):
182
  with gr.Row():
183
  url_input = gr.Textbox(label="YouTube URL", placeholder="https://youtu.be/ZdoiTX1f1tU?si=hZ96tryqaPIYfwg1")
184
  with gr.Row():
185
  audio_name_input = gr.Textbox(label="Audio Name", placeholder="Amy")
 
 
 
 
 
 
 
 
186
  with gr.Row():
187
  result_output = gr.File(label="Download Sliced Audio Zip")
188
+ result_process = gr.Textbox(label="Sliced Audio output")
189
  with gr.Row():
190
  run_button = gr.Button("Slice 👾 Audio")
191
+ run_button.click(fn=process_audio, inputs=[url_input, audio_name_input], outputs=[result_output, result_process])
 
192
  with gr.TabItem("note"):
193
  with gr.Row():
194
  gr.Markdown(