Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import os, shutil
|
|
|
|
| 3 |
import subprocess, glob
|
| 4 |
from datetime import datetime
|
| 5 |
from tools.useftools import *
|
|
@@ -239,6 +240,31 @@ def refresh():
|
|
| 239 |
def update_audio_player(choice):
|
| 240 |
return os.path.join("audios",choice)
|
| 241 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 242 |
with gr.Blocks() as app:
|
| 243 |
with gr.Row():
|
| 244 |
with gr.Column():
|
|
@@ -285,6 +311,14 @@ with gr.Blocks() as app:
|
|
| 285 |
except:#Version Compatibiliy
|
| 286 |
dropbox = gr.File(label="Drop an audio here.",file_types=['.wav', '.mp3', '.ogg', '.flac', '.aac'], type="file")
|
| 287 |
dropbox.upload(fn=upload_file, inputs=[dropbox],outputs=[audio_picker])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 288 |
with gr.Row():
|
| 289 |
audio_refresher = gr.Button("Refresh")
|
| 290 |
audio_refresher.click(fn=refresh,inputs=[],outputs=[audio_picker,model_picker,index_picker])
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import os, shutil
|
| 3 |
+
import yt_dlp
|
| 4 |
import subprocess, glob
|
| 5 |
from datetime import datetime
|
| 6 |
from tools.useftools import *
|
|
|
|
| 240 |
def update_audio_player(choice):
|
| 241 |
return os.path.join("audios",choice)
|
| 242 |
|
| 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)
|
| 260 |
+
return outtmpl
|
| 261 |
+
|
| 262 |
+
|
| 263 |
+
|
| 264 |
+
|
| 265 |
+
|
| 266 |
+
|
| 267 |
+
|
| 268 |
with gr.Blocks() as app:
|
| 269 |
with gr.Row():
|
| 270 |
with gr.Column():
|
|
|
|
| 311 |
except:#Version Compatibiliy
|
| 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 inputa=[url_yt, audio_name],outputs=[outputs_audiq])
|
| 320 |
+
|
| 321 |
+
|
| 322 |
with gr.Row():
|
| 323 |
audio_refresher = gr.Button("Refresh")
|
| 324 |
audio_refresher.click(fn=refresh,inputs=[],outputs=[audio_picker,model_picker,index_picker])
|