Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -32,6 +32,7 @@ import traceback
|
|
32 |
from pedalboard import Pedalboard, Reverb, Delay, Chorus, Compressor, Gain, HighpassFilter, LowpassFilter
|
33 |
from pedalboard.io import AudioFile
|
34 |
import numpy as np
|
|
|
35 |
|
36 |
warnings.filterwarnings("ignore")
|
37 |
|
@@ -931,6 +932,78 @@ def sound_separate(media_file, stem, main, dereverb, vocal_effects=True, backgro
|
|
931 |
return outputs
|
932 |
|
933 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
934 |
def audio_conf():
|
935 |
return gr.File(
|
936 |
label="Audio file",
|
@@ -1251,8 +1324,27 @@ def get_gui(theme):
|
|
1251 |
gr.Markdown(title)
|
1252 |
gr.Markdown(description)
|
1253 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1254 |
aud = audio_conf()
|
1255 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1256 |
with gr.Column():
|
1257 |
with gr.Row():
|
1258 |
stem_gui = stem_conf()
|
@@ -1378,4 +1470,3 @@ if __name__ == "__main__":
|
|
1378 |
quiet=False,
|
1379 |
debug=False,
|
1380 |
)
|
1381 |
-
|
|
|
32 |
from pedalboard import Pedalboard, Reverb, Delay, Chorus, Compressor, Gain, HighpassFilter, LowpassFilter
|
33 |
from pedalboard.io import AudioFile
|
34 |
import numpy as np
|
35 |
+
import yt_dlp
|
36 |
|
37 |
warnings.filterwarnings("ignore")
|
38 |
|
|
|
932 |
return outputs
|
933 |
|
934 |
|
935 |
+
def audio_downloader(
|
936 |
+
url_media,
|
937 |
+
):
|
938 |
+
|
939 |
+
url_media = url_media.strip()
|
940 |
+
|
941 |
+
if not url_media:
|
942 |
+
return None
|
943 |
+
|
944 |
+
dir_output_downloads = "downloads"
|
945 |
+
os.makedirs(dir_output_downloads, exist_ok=True)
|
946 |
+
|
947 |
+
media_info = yt_dlp.YoutubeDL(
|
948 |
+
{"quiet": True, "no_warnings": True, "noplaylist": True}
|
949 |
+
).extract_info(url_media, download=False)
|
950 |
+
download_path = f"{os.path.join(dir_output_downloads, media_info['title'])}.m4a"
|
951 |
+
|
952 |
+
ydl_opts = {
|
953 |
+
'format': 'm4a/bestaudio/best',
|
954 |
+
'postprocessors': [{ # Extract audio using ffmpeg
|
955 |
+
'key': 'FFmpegExtractAudio',
|
956 |
+
'preferredcodec': 'm4a',
|
957 |
+
}],
|
958 |
+
'force_overwrites': True,
|
959 |
+
'noplaylist': True,
|
960 |
+
'no_warnings': True,
|
961 |
+
'quiet': True,
|
962 |
+
'ignore_no_formats_error': True,
|
963 |
+
'restrictfilenames': True,
|
964 |
+
'outtmpl': download_path,
|
965 |
+
}
|
966 |
+
with yt_dlp.YoutubeDL(ydl_opts) as ydl_download:
|
967 |
+
ydl_download.download([url_media])
|
968 |
+
|
969 |
+
return download_path
|
970 |
+
|
971 |
+
|
972 |
+
def downloader_conf():
|
973 |
+
return gr.Checkbox(
|
974 |
+
False,
|
975 |
+
label="URL-to-Audio",
|
976 |
+
# info="",
|
977 |
+
container=False,
|
978 |
+
)
|
979 |
+
|
980 |
+
|
981 |
+
def url_media_conf():
|
982 |
+
return gr.Textbox(
|
983 |
+
value="",
|
984 |
+
label="Enter URL",
|
985 |
+
placeholder="www.youtube.com/watch?v=g_9rPvbENUw",
|
986 |
+
visible=False,
|
987 |
+
lines=1,
|
988 |
+
)
|
989 |
+
|
990 |
+
|
991 |
+
def url_button_conf():
|
992 |
+
return gr.Button(
|
993 |
+
"Go",
|
994 |
+
variant="secondary",
|
995 |
+
visible=False,
|
996 |
+
)
|
997 |
+
|
998 |
+
|
999 |
+
def show_components_downloader(value_active):
|
1000 |
+
return gr.update(
|
1001 |
+
visible=value_active
|
1002 |
+
), gr.update(
|
1003 |
+
visible=value_active
|
1004 |
+
)
|
1005 |
+
|
1006 |
+
|
1007 |
def audio_conf():
|
1008 |
return gr.File(
|
1009 |
label="Audio file",
|
|
|
1324 |
gr.Markdown(title)
|
1325 |
gr.Markdown(description)
|
1326 |
|
1327 |
+
downloader_gui = downloader_conf()
|
1328 |
+
with gr.Row():
|
1329 |
+
with gr.Column(scale=2):
|
1330 |
+
url_media_gui = url_media_conf()
|
1331 |
+
with gr.Column(scale=1):
|
1332 |
+
url_button_gui = url_button_conf()
|
1333 |
+
|
1334 |
+
downloader_gui.change(
|
1335 |
+
show_components_downloader,
|
1336 |
+
[downloader_gui],
|
1337 |
+
[url_media_gui, url_button_gui]
|
1338 |
+
)
|
1339 |
+
|
1340 |
aud = audio_conf()
|
1341 |
|
1342 |
+
url_button_gui.click(
|
1343 |
+
audio_downloader,
|
1344 |
+
[url_media_gui],
|
1345 |
+
[aud]
|
1346 |
+
)
|
1347 |
+
|
1348 |
with gr.Column():
|
1349 |
with gr.Row():
|
1350 |
stem_gui = stem_conf()
|
|
|
1470 |
quiet=False,
|
1471 |
debug=False,
|
1472 |
)
|
|