Hev832 commited on
Commit
eae0213
1 Parent(s): 9da3955

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -243,20 +243,19 @@ def update_audio_player(choice):
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
- return f"outtmpl"
259
-
260
 
261
 
262
 
@@ -314,7 +313,7 @@ with gr.Blocks(theme="ParityError/Interstellar") as app:
314
  audio_name2 = gr.Textbox(label="audio name")
315
  outputs_audiq = gr.Textbox(label="audio outputs")
316
  download_yt_button = gr.Button("download")
317
- download_yt_button.click(fn=download_from_url, inputs=[url_yt1, audio_name2,],outputs=[outputs_audiq])
318
 
319
 
320
  with gr.Row():
 
243
 
244
 
245
 
246
+ def download_audio(url, audio_name):
247
  ydl_opts = {
248
  'format': 'bestaudio/best',
249
  'postprocessors': [{
250
  'key': 'FFmpegExtractAudio',
251
  'preferredcodec': 'wav',
252
+ 'preferredquality': '192',
253
  }],
254
+ 'outtmpl' f'audios/{audio_name}',
255
  }
256
  with yt_dlp.YoutubeDL(ydl_opts) as ydl:
257
+ ydl.download([url])
258
+ return "outtmpl"
 
 
259
 
260
 
261
 
 
313
  audio_name2 = gr.Textbox(label="audio name")
314
  outputs_audiq = gr.Textbox(label="audio outputs")
315
  download_yt_button = gr.Button("download")
316
+ download_yt_button.click(fn=download_audio, inputs=[url_yt1, audio_name2,],outputs=[outputs_audiq])
317
 
318
 
319
  with gr.Row():