File size: 742 Bytes
281bdba
 
 
1b36440
 
281bdba
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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

import gradio as gr
import yt_dlp
import os 


def download_youtube_wav(url, custom_name):
    ydl_opts = {
        'format': 'bestaudio/best',
        'postprocessors': [{
            'key': 'FFmpegExtractAudio',
            'preferredcodec': 'wav',
            'preferredquality': '192',
        }],
        'outtmpl': custom_name + '.%(ext)s',
    }

    with yt_dlp.YoutubeDL(ydl_opts) as ydl:
        ydl.download([url])
    
    return f'File "{custom_name}.wav" telah di-download!'

iface = gr.Interface(
    fn=download_youtube_wav,
    inputs=['text', 'text'],
    outputs='text',
    title='YouTube to WAV Downloader',
    description='Enter the YouTube URL and custom name for the WAV file you want to download.'
)

iface.launch()