File size: 1,023 Bytes
281bdba
b48ae3c
c0a1d1d
57e8255
c0a1d1d
 
 
281bdba
 
 
 
c0a1d1d
281bdba
c0a1d1d
281bdba
 
 
c0a1d1d
 
 
 
48b26fa
 
 
 
c0a1d1d
 
e75acfd
c0a1d1d
147e144
c0a1d1d
 
 
 
 
 
 
 
 
 
281bdba
 
e9bd556
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import yt_dlp
import gradio as gr
import os


def downloader(video_url, save_folder, audio_format, audio_name):
    save_path = os.path.join(save_folder, audio_name)
    ydl_opts = {
        'format': 'bestaudio/best',
        'postprocessors': [{
            'key': 'FFmpegExtractAudio',
            'preferredcodec': audio_format,
        }],
        'outtmpl': save_path,
    }

    with yt_dlp.YoutubeDL(ydl_opts) as ydl:
        ydl.download([video_url])
    return f"Audio downloaded successfully to {save_path}"

inputs = [
    gr.Textbox(label="YouTube video link"),
    gr.Textbox(label="Audio name"),
    gr.Textbox(label="Output path for downloaded audio files"),
    gr.Radio(["wav", "flac", "mp3"], label="Select the output format")
]

output = gr.Textbox(label="Output")

title = "YouTube Audio Downloader"
description = "Download audio from YouTube videos"

gr.Interface(
    fn=downloader,
    inputs=inputs,
    outputs=output,
    title=title,
    description=description,
    theme="light"
).launch()