add mvsep
Browse files
app.py
CHANGED
|
@@ -1,8 +1,9 @@
|
|
| 1 |
-
import gradio as gr, glob, os, auditok, zipfile, wave, pytube.exceptions, urllib.error
|
| 2 |
from pytube import YouTube
|
| 3 |
from moviepy.editor import *
|
| 4 |
import traceback, yt_dlp
|
| 5 |
|
|
|
|
| 6 |
def download_video(url, download_as, use_ytdlp):
|
| 7 |
if use_ytdlp == True:
|
| 8 |
try:
|
|
@@ -195,6 +196,42 @@ def remove_audio_file_from_directory():
|
|
| 195 |
os.remove(w)
|
| 196 |
return gr.Info("File removed.")
|
| 197 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 198 |
|
| 199 |
with gr.Blocks(theme='sudeepshouche/minimalist', title="Global Dataset Maker") as app:
|
| 200 |
gr.HTML(
|
|
@@ -207,7 +244,7 @@ with gr.Blocks(theme='sudeepshouche/minimalist', title="Global Dataset Maker") a
|
|
| 207 |
</p>"""
|
| 208 |
)
|
| 209 |
gr.Markdown(
|
| 210 |
-
"This Space will create a dataset for you, all automatically. **Please be warned that due to not having a GPU on this Space, some steps might take longer to complete.**"
|
| 211 |
)
|
| 212 |
gr.HTML(
|
| 213 |
"<h2> This Space's storage is ephemeral, meaning once you reload this space, all audio files will be lost. </h2>"
|
|
@@ -290,8 +327,42 @@ with gr.Blocks(theme='sudeepshouche/minimalist', title="Global Dataset Maker") a
|
|
| 290 |
None,
|
| 291 |
None
|
| 292 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 293 |
|
| 294 |
with gr.TabItem("Changelog"):
|
|
|
|
| 295 |
gr.Markdown("v0.99.2 - Added an mp4 file converter.")
|
| 296 |
gr.Markdown("v0.99.1 - Removed very old tools (including the 'Upcoming Features' tab) that did not fit with the nature of the program.")
|
| 297 |
gr.Markdown("v0.99 - Added 'Strict Duration' mode for the file splitter.")
|
|
|
|
| 1 |
+
import gradio as gr, glob, os, auditok, zipfile, wave, pytube.exceptions, urllib.error, requests, json
|
| 2 |
from pytube import YouTube
|
| 3 |
from moviepy.editor import *
|
| 4 |
import traceback, yt_dlp
|
| 5 |
|
| 6 |
+
|
| 7 |
def download_video(url, download_as, use_ytdlp):
|
| 8 |
if use_ytdlp == True:
|
| 9 |
try:
|
|
|
|
| 196 |
os.remove(w)
|
| 197 |
return gr.Info("File removed.")
|
| 198 |
|
| 199 |
+
def mvsep_api_request(mvsep_key, audio_file, sep_int):
|
| 200 |
+
url = "https://mvsep.com/api/separation/create"
|
| 201 |
+
files = {
|
| 202 |
+
"audiofile": open(audio_file, 'rb')
|
| 203 |
+
}
|
| 204 |
+
data = {
|
| 205 |
+
"api_token": mvsep_key,
|
| 206 |
+
"sep_type": sep_int
|
| 207 |
+
}
|
| 208 |
+
r = requests.post(url, files=files, data=data)
|
| 209 |
+
json_format = r.json()
|
| 210 |
+
hash_val = json_format['data']['hash']
|
| 211 |
+
return f"Request sent successfully! Your hash is: {hash_val}.\n\nUse the next tab to check the status of your request."
|
| 212 |
+
|
| 213 |
+
def mvsep_check_request(hash_textbox):
|
| 214 |
+
url = "https://mvsep.com/api/separation/get"
|
| 215 |
+
params = {
|
| 216 |
+
"hash": hash_textbox
|
| 217 |
+
}
|
| 218 |
+
r = requests.get(url, params=params)
|
| 219 |
+
rjson = r.json()
|
| 220 |
+
success = rjson['success']
|
| 221 |
+
status = rjson['status']
|
| 222 |
+
return f"Was successful? {str(success)}.\n Status: {status}."
|
| 223 |
+
|
| 224 |
+
def mvsep_download_separated_audio(hash_textbox):
|
| 225 |
+
url = "https://mvsep.com/api/separation/get"
|
| 226 |
+
params = {
|
| 227 |
+
"hash": hash_textbox
|
| 228 |
+
}
|
| 229 |
+
r = requests.get(url, params=params)
|
| 230 |
+
rjson = r.json()
|
| 231 |
+
files = rjson.get('data', {}).get('files', [])
|
| 232 |
+
urls = [file['url'] for file in files]
|
| 233 |
+
return json.dumps(urls, indent=4)
|
| 234 |
+
|
| 235 |
|
| 236 |
with gr.Blocks(theme='sudeepshouche/minimalist', title="Global Dataset Maker") as app:
|
| 237 |
gr.HTML(
|
|
|
|
| 244 |
</p>"""
|
| 245 |
)
|
| 246 |
gr.Markdown(
|
| 247 |
+
"This Space will create a dataset for you and use MVSEP to isolate vocals (EXPERIMENTAL), all automatically. **Please be warned that due to not having a GPU on this Space, some steps might take longer to complete.**"
|
| 248 |
)
|
| 249 |
gr.HTML(
|
| 250 |
"<h2> This Space's storage is ephemeral, meaning once you reload this space, all audio files will be lost. </h2>"
|
|
|
|
| 327 |
None,
|
| 328 |
None
|
| 329 |
)
|
| 330 |
+
with gr.Tab("MVSEP"):
|
| 331 |
+
gr.Markdown("**VERY EXPERIMENTAL!** Use MVSEP to isolate audio.\n\n**You will be required to input your API key, but it will not be saved ever, I don't use anything saved here for bad intentions, nor would I have access to it regardless.**")
|
| 332 |
+
with gr.Tab("Send Request"):
|
| 333 |
+
with gr.Row():
|
| 334 |
+
with gr.Column():
|
| 335 |
+
with gr.Row():
|
| 336 |
+
mvsep_key = gr.Textbox(placeholder="Enter your MVSEP API key.", label="API key")
|
| 337 |
+
audio_file = gr.File(file_count='single', file_types=[".mp3"], label="Audio file")
|
| 338 |
+
sep_int = gr.Number(11, label="Separation type (default is 11).", minimum=0, maximum=40, interactive=True)
|
| 339 |
+
send_req = gr.Button("Send request", variant='primary')
|
| 340 |
+
copy_hash = gr.Button("Copy hash to clipboard", variant='secondary')
|
| 341 |
+
send_req.click(
|
| 342 |
+
mvsep_api_request,
|
| 343 |
+
[mvsep_key, audio_file, sep_int],
|
| 344 |
+
[gr.Text(label="Output")]
|
| 345 |
+
)
|
| 346 |
+
with gr.Tab("Get status of request"):
|
| 347 |
+
with gr.Row():
|
| 348 |
+
with gr.Column():
|
| 349 |
+
with gr.Row():
|
| 350 |
+
hash_textbox = gr.Textbox(label="Hash")
|
| 351 |
+
check_status = gr.Button("Check status", variant='primary')
|
| 352 |
+
download = gr.Button("Download separated audio", variant='secondary')
|
| 353 |
+
check_status.click(
|
| 354 |
+
mvsep_check_request,
|
| 355 |
+
[hash_textbox],
|
| 356 |
+
[gr.Text(label="Status")]
|
| 357 |
+
)
|
| 358 |
+
download.click(
|
| 359 |
+
mvsep_download_separated_audio,
|
| 360 |
+
[hash_textbox],
|
| 361 |
+
[gr.Text(label="Link(s)")]
|
| 362 |
+
)
|
| 363 |
|
| 364 |
with gr.TabItem("Changelog"):
|
| 365 |
+
gr.Markdown("v0.99.3 - Added MVSEP in Misc Tools. This is VERY EXPERIMENTAL and there will be bugs present.")
|
| 366 |
gr.Markdown("v0.99.2 - Added an mp4 file converter.")
|
| 367 |
gr.Markdown("v0.99.1 - Removed very old tools (including the 'Upcoming Features' tab) that did not fit with the nature of the program.")
|
| 368 |
gr.Markdown("v0.99 - Added 'Strict Duration' mode for the file splitter.")
|