Hev832 commited on
Commit
1a0e586
1 Parent(s): 2df22ae

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -243,17 +243,17 @@ def update_audio_player(choice):
243
 
244
 
245
 
246
- def download_from_url(url_yt, audio_name):
247
  ydl_opts = {
248
  'format': 'bestaudio/best',
249
  'postprocessors': [{
250
  'key': 'FFmpegExtractAudio',
251
  'preferredcodec': 'wav',
252
  }],
253
- "outtmpl": f'audios/{audio_name}', # Format output filename
254
  }
255
  with yt_dlp.YoutubeDL(ydl_opts) as ydl:
256
- ydl.download([url_yt])
257
 
258
  def audio_downloader(url):
259
  download_from_url(url)
@@ -312,11 +312,11 @@ with gr.Blocks(theme="ParityError/Interstellar") as app:
312
  dropbox = gr.File(label="Drop an audio here.",file_types=['.wav', '.mp3', '.ogg', '.flac', '.aac'], type="file")
313
  dropbox.upload(fn=upload_file, inputs=[dropbox],outputs=[audio_picker])
314
  with gr.TabItem("download audio acapella"):
315
- url_yt = gr.Textbox(label="YouTube url")
316
- audio_name = gr.Textbox(label="audio name")
317
  outputs_audiq = gr.Textbox(label="audio outputs")
318
  download_yt_button = gr.Button("download")
319
- download_yt_button.click(fn=audio_downloader inputs=[url_yt, audio_name],outputs=[outputs_audiq])
320
 
321
 
322
  with gr.Row():
 
243
 
244
 
245
 
246
+ def download_from_url(url_yt, audioname):
247
  ydl_opts = {
248
  'format': 'bestaudio/best',
249
  'postprocessors': [{
250
  'key': 'FFmpegExtractAudio',
251
  'preferredcodec': 'wav',
252
  }],
253
+ "outtmpl": f'audios/{audioname}', # Format output filename
254
  }
255
  with yt_dlp.YoutubeDL(ydl_opts) as ydl:
256
+ ydl.download([urlyt])
257
 
258
  def audio_downloader(url):
259
  download_from_url(url)
 
312
  dropbox = gr.File(label="Drop an audio here.",file_types=['.wav', '.mp3', '.ogg', '.flac', '.aac'], type="file")
313
  dropbox.upload(fn=upload_file, inputs=[dropbox],outputs=[audio_picker])
314
  with gr.TabItem("download audio acapella"):
315
+ url_yt1 = gr.Textbox(label="YouTube url")
316
+ audio_name2 = gr.Textbox(label="audio name")
317
  outputs_audiq = gr.Textbox(label="audio outputs")
318
  download_yt_button = gr.Button("download")
319
+ download_yt_button.click(fn=audio_downloader inputs=[url_yt1, audio_name2,],outputs=[outputs_audiq])
320
 
321
 
322
  with gr.Row():