File size: 31,575 Bytes
4818fcf
f088aee
348b8de
 
f088aee
4818fcf
1746592
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f088aee
e8f356e
f088aee
e8f356e
0fcf079
 
f088aee
 
 
 
 
2820d37
f088aee
7348eda
f088aee
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7348eda
 
e8f356e
f088aee
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e8f356e
f088aee
348b8de
e8f356e
 
 
 
 
 
 
2820d37
e8f356e
 
 
 
 
 
 
348b8de
 
e8f356e
 
 
 
 
 
 
 
 
 
e83fe37
 
e8f356e
28c73d5
348b8de
3b5fc1d
011eb76
 
 
 
 
 
 
 
 
3b5fc1d
 
0ba0222
 
 
 
011eb76
 
 
 
 
 
 
 
 
 
 
 
 
3b5fc1d
ccd7c61
087b155
 
 
 
 
 
 
 
 
d35d878
 
3b5fc1d
348b8de
 
 
c057334
348b8de
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
efa3e04
 
 
 
348b8de
 
1acf81a
 
 
 
 
 
 
4818fcf
 
 
 
 
 
1acf81a
4818fcf
 
 
 
82d61fb
4818fcf
 
2bc2108
 
 
 
 
 
 
 
 
011eb76
2bc2108
 
4818fcf
 
2bc2108
 
 
 
 
 
 
1acf81a
2bc2108
 
1acf81a
 
2bc2108
 
 
82d61fb
 
 
011eb76
 
 
 
 
 
 
 
 
82d61fb
 
 
 
 
 
011eb76
 
 
 
 
 
 
 
 
 
 
82d61fb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4818fcf
d963e62
f088aee
82d61fb
f088aee
e7da7b4
 
 
26df1db
e7da7b4
 
f088aee
82d61fb
f088aee
9b27834
82d61fb
9b27834
f088aee
 
 
0a26beb
 
 
7348eda
1746592
0a26beb
f088aee
 
348b8de
f088aee
 
 
 
0a26beb
 
 
9433e9a
0a26beb
 
866fedd
f088aee
e8f356e
f088aee
 
 
28c73d5
e83fe37
0fcf079
e8f356e
 
 
0fcf079
e8f356e
 
 
12ce065
e8f356e
 
0fcf079
348b8de
e8f356e
 
348b8de
3b5fc1d
 
 
 
 
 
ccd7c61
3b5fc1d
 
 
087b155
 
3b5fc1d
348b8de
 
cf6afc4
 
 
348b8de
 
 
 
 
 
 
 
cf6afc4
348b8de
 
 
 
 
4818fcf
82d61fb
 
4818fcf
 
 
 
 
1acf81a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3f41391
46c5adf
3f41391
 
 
 
1acf81a
 
 
 
 
 
4818fcf
 
 
1acf81a
4818fcf
 
82d61fb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3f41391
46c5adf
3f41391
 
 
 
82d61fb
 
 
 
 
 
 
 
 
 
 
 
4818fcf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
348b8de
086b8c8
3f41391
011eb76
82d61fb
1acf81a
77da9c4
82d61fb
348b8de
f088aee
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
import gradio as gr, glob, os, auditok, zipfile, wave, pytube.exceptions, urllib.error, requests, json
from pytube import YouTube
from moviepy.editor import *
import traceback, yt_dlp


def download_video(url, download_as, use_ytdlp):
    if use_ytdlp == True:
        try:
            ydl_opts = {
                'format': f"{download_as}/bestaudio/best",
                'postprocessors': [{
                    'key': 'FFmpegExtractAudio',
                    'preferredcodec': download_as,
                }]
            }
            with yt_dlp.YoutubeDL(ydl_opts) as ydl:
                ydl.download(url)
            for i in glob.glob(f"*.{download_as}"):
                if os.path.exists(i):
                    os.rename(i, f"output.{download_as}")
            return "Finished downloading! Please proceed to next tab."
        except:
            raise gr.Error(traceback.format_exc())
    else:
        try:
            yt = YouTube(url)
        except pytube.exceptions.RegexMatchError:
            raise gr.Error("URL not valid or is empty! Please fix the link or enter one!")
        except urllib.error.HTTPError as not_ok:
            raise gr.Error(f"Recieved {not_ok}")
        except pytube.exceptions.AgeRestrictedError:
            raise gr.Error("The video you inputted is age-restricted! Please try another link.")
        video = yt.streams.get_highest_resolution()
        video.download()
        video_path = f"{video.default_filename}"
        video_clip = VideoFileClip(video_path)
        audio_clip = video_clip.audio
        if download_as == "wav":
            audio_clip.write_audiofile("output.wav")
        elif download_as == "mp3":
            audio_clip.write_audiofile("output.mp3")
        audio_clip.close()
        video_clip.close()
        for removalmp4 in glob.glob("*.mp4"):
            os.remove(removalmp4)
        return "Finished downloading! Please proceed to next tab."

def split_audio_from_yt_video(mindur, maxdur, name_for_split_files, show_amount_of_files_and_file_dur):
    if show_amount_of_files_and_file_dur == True:
        gr.Warning(f"show_amount_of_files_and_file_dur set to True. This will take longer if your audio file is long.")
    if not os.path.exists("output.mp3") and not os.path.exists("output.wav"):
        raise gr.Error("Neither output.mp3 or output.wav exist! Did the video download correctly?")
    if mindur == maxdur:
        raise gr.Error(f"Cannot split mindur={mindur} and maxdur={maxdur}, min and max are the same number.")
    elif mindur > maxdur:
        raise gr.Error(f"Cannot split mindur={mindur} and maxdur={maxdur}, mindur is higher than maxdur.")
    elif name_for_split_files == None:
        raise gr.Error("Split files name cannot be empty!")
    else:
        audio_path = "output.wav" if not os.path.exists("output.mp3") else "output.mp3"
        audio_regions = auditok.split(
            audio_path,
            min_dur=mindur,
            max_dur=maxdur,
            max_silence=0.3,
            energy_threshold=45
        )
        os.remove(audio_path)
        for i, r in enumerate(audio_regions):
            filename = r.save(f"{name_for_split_files}-{i+1}.wav")
        for f in sorted(glob.glob("*.wav")):
            audio_files = glob.glob("*.wav")
            zip_file_name = "audio_files.zip"
            with zipfile.ZipFile(zip_file_name, "w") as zip_file:
                for audio_file in audio_files:
                    zip_file.write(audio_file, os.path.basename(audio_file))
        if show_amount_of_files_and_file_dur == False:
            for file2 in glob.glob("*.wav"):
                os.remove(file2)
            return "Files split successfully!\nCheck below for zipped files.", zip_file_name
        elif show_amount_of_files_and_file_dur == True:
            largest_file = ("", 0)
            total_files = 0
            total_length = 0.0
            for file_name in glob.glob("*.wav"):
                file_path = os.path.join(os.getcwd(), file_name)
                if file_path.lower().endswith(".wav"):
                    try:
                        with wave.open(file_path, 'r') as audio_file:
                            frames = audio_file.getnframes()
                            rate = audio_file.getframerate()
                            duration = frames / float(rate)
                            file_size = os.path.getsize(file_path)
                            if file_size > largest_file[1]:
                                largest_file = (file_name, file_size)
                            total_length += duration
                            total_files += 1
                    except wave.Error as e:
                        raise gr.Error(f"Error reading file: {e}")
            length_mins = total_length / 60
            for file2 in glob.glob("*.wav"):
                os.remove(file2)
            return f"Files split successfully!\nCheck below for zipped files.\n\n{total_files} files created, {length_mins:.2f} minutes total.", zip_file_name

def split_wav_or_mp3_file(audiofileuploader, mindur2, maxdur2, name_for_split_files2, strict):
    if audiofileuploader == None:
        raise gr.Error("Audio file cannot be empty!")
    if mindur2 == maxdur2:
        raise gr.Error(f"Cannot split mindur={mindur} and maxdur={maxdur}, min and max are the same number.")
    elif mindur2 > maxdur2:
        raise gr.Error(f"Cannot split mindur={mindur} and maxdur={maxdur}, mindur is higher than maxdur.")
    elif name_for_split_files2 == None:
        raise gr.Error("Split files name cannot be empty!")
    else:
        audio_path = audiofileuploader
        audio_regions = auditok.split(
            audio_path,
            min_dur=mindur2,
            max_dur=maxdur2,
            max_silence=0.3,
            energy_threshold=45,
            strict_min_dur=True if strict == True else False
        )
        os.remove(audio_path)
        for i, r in enumerate(audio_regions):
            filename = r.save(f"{name_for_split_files2}-{i+1}.wav")
        for f in sorted(glob.glob("*.wav")):
            audio_files = glob.glob("*.wav")
            zip_file_name2 = "audio_files.zip"
            with zipfile.ZipFile(zip_file_name2, "w") as zip_file:
                for audio_file in audio_files:
                    zip_file.write(audio_file, os.path.basename(audio_file))
    for file2 in glob.glob("*.wav"):
        os.remove(file2)
    return f"File split successfully!\nCheck below for zipped files.\nAmount created: {len(audio_files)}", zip_file_name2

def download_video_as_audio_only(yt_video, audio_output_format):      
    try:
        ydl_opts = {
            'format': f"{audio_output_format}/bestaudio/best",
            'postprocessors': [{
                'key': 'FFmpegExtractAudio',
                'preferredcodec': "mp3"
            }]
        }
        with yt_dlp.YoutubeDL(ydl_opts) as ydl:
            ydl.download(yt_video)
    except pytube.exceptions.RegexMatchError:
        raise gr.Error("URL not valid or is empty! Please fix the link or enter one!")
    except urllib.error.HTTPError as not_ok:
        raise gr.Error(f"Recieved {not_ok}")
    except pytube.exceptions.AgeRestrictedError:
        raise gr.Error("The video you inputted is age-restricted! Please try another link.")
    #video = yt.streams.get_audio_only()
    #video.download()
    #video_path = f"{video.default_filename}"
    #video_clip = VideoFileClip(video_path)
    #audio_clip = video_clip.audio
    #if audio_output_format == "wav":
    #    audio_clip.write_audiofile("output.wav")
    #elif audio_output_format == "mp3":
    #    audio_clip.write_audiofile("output.mp3")
    #audio_clip.close()
    #video_clip.close()
    #for mp4remove in glob.glob("*.mp4"):
    #    os.remove(mp4remove)
    single_zip_name = "only_audio.zip"
    audio_files = glob.glob("*.wav") if audio_output_format == "wav" else glob.glob("*.mp3")
    with zipfile.ZipFile(single_zip_name, 'w') as zip_file:
        for audio_file in audio_files:
            zip_file.write(audio_file, os.path.basename(audio_file))
    for outputwavremoval in glob.glob("*.wav"):
        if os.path.exists(outputwavremoval):
            os.remove(outputwavremoval)
    for outputmp3removal in glob.glob("*.mp3"):
        if os.path.exists(outputmp3removal):
            os.remove(outputmp3removal)
    #return f"Done! Download the zip file below! This only contains the audio file.\n\nYou have downloaded a video.", single_zip_name
    return "Done! Download the zip file below! This only contains the audio file.", single_zip_name

def mp4_to_wav_or_mp3(mp4fileuploader, file_format):
    if mp4fileuploader == None:
        raise gr.Error("Input cannot be empty!")
    else:
        try:
            if file_format == "wav":
                videoinput = AudioFileClip(mp4fileuploader)
                videoinput.write_audiofile("convertedaudio.wav")
                videoinput.close()
            elif file_format == "mp3":
                videoinput = AudioFileClip(mp4fileuploader)
                videoinput.write_audiofile("convertedaudio.mp3")
                videoinput.close()
            what_to_return = "convertedaudio.wav" if file_format == "wav" else "convertedaudio.mp3"
            os.remove(mp4fileuploader)
            return "Converted mp4 file successfully!", what_to_return
        except:
            raise gr.Error(traceback.format_exc())
        
def remove_audio_file_from_directory():
    for r in glob.glob("*.wav"):
        os.remove(r)
    for w in glob.glob("*.mp3"):
        os.remove(w)
    for y in glob.glob("convertedaudio.mp3"):
        os.remove(y)
    for a in glob.glob("convertedaudio.wav"):
        os.remove(a)
    return gr.Info("File removed.")

def mvsep_api_request(mvsep_key, audio_file, sep_dropdown):
    if mvsep_key == "":
        return gr.Warning("You must have an MVSEP API key for this to work!")
    if audio_file == None:
        return gr.Warning("Please select an audio file!")
    if sep_dropdown == "-------------------------------------------------------------------------------------------------":
        return gr.Warning("This option is not a model!")
    url = "https://mvsep.com/api/separation/create"
    files = {
        "audiofile": open(audio_file, 'rb')
    }
    data = {
        "api_token": mvsep_key,
        "sep_type": sep_dropdown
    }
    r = requests.post(url, files=files, data=data)
    json_format = r.json()
    hash_val = json_format['data']['hash']
    return f"Request sent successfully! Your hash is: {hash_val}\n\nUse the 'Get Status' tab to check the status of your request."

def mvsep_check_request(hash_textbox):
    try:
        url = "https://mvsep.com/api/separation/get"
        params = {
            "hash": hash_textbox
        }
        r = requests.get(url, params=params)
        rjson = r.json()
        success = rjson['success']
        status = rjson['status']
        return f"Was successful? {str(success)}.\nStatus: {status}."
    except requests.exceptions.JSONDecodeError:
        return gr.Info("Status not available or request not sent.")

def mvsep_download_separated_audio(hash_textbox):
    try:
        url = "https://mvsep.com/api/separation/get"
        params = {
            "hash": hash_textbox
        }
        r = requests.get(url, params=params)
        rjson = r.json()
        status = rjson['status']
        files = rjson.get('data', {}).get('files', [])
        urls = [file['url'] for file in files]
        if status == "waiting" or status == "processing":
            return gr.Info("Job not finished yet, so nothing to download for now.")
        return json.dumps(urls, indent=4)
    except requests.exceptions.JSONDecodeError:
        return gr.Info("Nothing to download yet. Check back later.")
    
def mvsep_yt_link_request(mvsep_key2, sep_dropdown2, yt_link):
        try:
            ydl_opts = {
            'format': "mp3/bestaudio/best",
            'postprocessors': [{
                'key': 'FFmpegExtractAudio',
                'preferredcodec': "mp3"
            }]
            }
            with yt_dlp.YoutubeDL(ydl_opts) as ydl:
                ydl.download(yt_link)
        except pytube.exceptions.RegexMatchError:
            raise gr.Error("URL not valid or is empty! Please fix the link or enter one!")
        except urllib.error.HTTPError as not_ok:
            raise gr.Error(f"Recieved {not_ok}")
        except pytube.exceptions.AgeRestrictedError:
            raise gr.Error("The video you inputted is age-restricted! Please try another link.")
        #video = yt.streams.get_highest_resolution()
        #video.download()
        #video_path = f"{video.default_filename}"
        #video_clip = VideoFileClip(video_path)
        #audio_clip = video_clip.audio
        #audio_clip.write_audiofile("output.mp3")
        #audio_clip.close()
        #video_clip.close()
        for rename in glob.glob("*.mp3"):
            if os.path.exists(rename):
                os.rename(rename, "output.mp3")
        for removalmp4 in glob.glob("*.mp4"):
            os.remove(removalmp4)

        url = "https://mvsep.com/api/separation/create"
        files = {
            "audiofile": open("output.mp3", 'rb')
        }
        data = {
            "api_token": mvsep_key2,
            "sep_type": sep_dropdown2
        }
        r = requests.post(url, files=files, data=data)
        json_format = r.json()
        hash_val = json_format['data']['hash']
        return f"Request sent successfully! Your hash is: {hash_val}\n\nUse the next tab to check the status of your request."
        

with gr.Blocks(theme='sudeepshouche/minimalist', title="Global Dataset Maker") as app:
    gr.HTML(
        "<h1> Welcome to the Cafeteria (formally GDMGS)!</h1>"
    )
    gr.Markdown("## Duplicate this space if you want to make your own changes!")
    gr.HTML(
        """<p style="margin:5px auto;display: flex;justify-content: left;">
            <a href="https://huggingface.co/spaces/Kryptone/GDMGS?duplicate=true"><img src="https://huggingface.co/datasets/huggingface/badges/resolve/main/duplicate-this-space-md-dark.svg" alt="Duplicate this Space"></a>
        </p>"""
    )
    gr.Markdown(
        "This Space will create a dataset for you and use MVSEP to isolate vocals, all automatically. **Please be warned that due to not having a GPU on this Space, some steps might take longer to complete.**"
    )
    gr.HTML(
        "<h2> This Space's storage is ephemeral, meaning all audio files are visible to you only. I do not have access to any of this, nor would I do anything with it anyway. </h2>"
    )
    with gr.Tabs():
        with gr.TabItem("Download Video"):
            with gr.Row():
                with gr.Column():
                    with gr.Row():
                        url = gr.Textbox(label="URL")
                        download_as = gr.Radio(["wav", "mp3"], label="Audio format output", value="wav", info="What should the audio format be output as?")
                        use_ytdlp = gr.Checkbox(False, label="Use yt_dlp instead of pytube?", info="Sometimes Pytube refuses to download a video. If that happens, check this box to download using yt_dlp instead.")
                        convertion = gr.Button("Download", variant='primary')
            convertion.click(
                fn=download_video,
                inputs=[url, download_as, use_ytdlp],
                outputs=gr.Text(label="Output")
            )
        with gr.TabItem("Split audio files"):
            with gr.Row():
                with gr.Column():
                    with gr.Row():
                        mindur = gr.Number(label="Min duration", minimum=1, maximum=10, value=1)
                        maxdur = gr.Number(label="Max duration", minimum=1, maximum=10, value=5)
                        name_for_split_files = gr.Textbox(label="Name for split files")
                        show_amount_of_files_and_file_dur = gr.Checkbox(False, label="Show total amount of files and duration?")
                        splitbtn = gr.Button("Split", variant='primary')
            splitbtn.click(
                split_audio_from_yt_video,
                inputs=[mindur, maxdur, name_for_split_files, show_amount_of_files_and_file_dur],
                outputs=[gr.Text(label="Output"), gr.File(label="Zipped files")]
            )
        with gr.TabItem("Misc tools"):
            with gr.Tab("File splitter"):
                gr.Markdown("If you would rather split a single WAV or mp3 audio file, use this method instead.")
                with gr.Row():
                    with gr.Column():
                        with gr.Row():
                            audiofileuploader = gr.File(file_count='single', file_types=[".wav", ".mp3"], label="WAV or mp3 file")
                            mindur2 = gr.Number(label="Min duration", minimum=1, maximum=10, value=1)
                            maxdur2 = gr.Number(label="Max duration", minimum=1, maximum=10, value=5)
                            name_for_split_files2 = gr.Textbox(label="Name for split files")
                            strict = gr.Checkbox(False, label="Enable strict duration?", info="Use this option if you want to minimize the '(audio_file) is less than 0.76 seconds' warning on Colab. Keep in mind that this only applies for min duration, max is ignored.")
                            audiofileuploadbtn = gr.Button("Split", variant='primary')
                        audiofileuploadbtn.click(
                            split_wav_or_mp3_file,
                            [audiofileuploader, mindur2, maxdur2, name_for_split_files2, strict],
                            [gr.Text(label="Output"), gr.File(label="Zipped files")]
                        )

            with gr.Tab("Audio only download"):
                gr.Markdown("If you want to download only the audio (to isolate bgm using UVR, etc), use this method, which will only extract audio and not split the audio.")
                with gr.Row():
                    with gr.Column():
                        with gr.Row():
                            yt_video = gr.Textbox(label="URL")
                            audio_output_format = gr.Radio(["wav", "mp3"], value="wav", label="Download audio as:")
                            commence_download = gr.Button("Download", variant='primary')
                        commence_download.click(
                            download_video_as_audio_only,
                            [yt_video, audio_output_format],
                            [gr.Text(label="Output"), gr.File(label="Zipped audio file")]
                        )
            with gr.Tab("MP4 to mp3/wav converter"):
                gr.Markdown("If you have an mp4 file, you can convert it to mp3 or wav here. Only click the 'Remove file' button when done.")
                with gr.Row():
                    with gr.Column():
                        with gr.Row():
                            mp4fileuploader = gr.File(file_count='single', file_types=[".mp4"], label="mp4 file")
                            file_format = gr.Radio(["wav", "mp3"], value="mp3", label="Convert mp4 file to:")
                            convert_btn = gr.Button("Convert", variant='primary')
                            remove_file_btn = gr.Button("Remove file from directory", variant='secondary')
                        convert_btn.click(
                            mp4_to_wav_or_mp3,
                            [mp4fileuploader, file_format],
                            [gr.Text(label="Output"), gr.File(label="Converted audio file")]
                        )
                        remove_file_btn.click(
                            remove_audio_file_from_directory,
                            None,
                            None
                        )
            with gr.Tab("MVSEP"):
                gr.Markdown("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.**")
                with gr.Tab("Send Request via audio file"):
                    with gr.Row():
                        with gr.Column():
                            with gr.Row():
                                mvsep_key = gr.Textbox(placeholder="Enter your MVSEP API key.", label="API key")
                                audio_file = gr.File(file_count='single', file_types=[".mp3"], label="Audio file")
                                sep_dropdown = gr.Dropdown(
                                    ["0 - spleeter (vocals, music)",
                                    "1 - spleeter (vocals, drums, bass, other)",
                                    "2 - spleeter (vocals, drums, bass, piano, other)",
                                    "3 - unmix XL (vocals, drums, bass, other)",
                                    "4 - unmix HQ (vocals, drums, bass, other)",
                                    "5 - unmix SD (vocals, drums, bass, other)",
                                    "6 - unmix SE (vocals, music)",
                                    "7 - MDX A (vocals, drums, bass, other)",
                                    "8 - MDX B (vocals, drums, bass, other)",
                                    "9 - UVR HQ (vocals, music)",
                                    "10 - Demucs3 Model A (vocals, drums, bass, other)",
                                    "11 - Demucs3 Model B (vocals, drums, bass, other)",
                                    "12 - MDX-B Karaoke (lead/back vocals)",
                                    "13 - Demucs2 (vocals, drums, bass, other)",
                                    "14 - Zero Shot (Query Based) (LQ)",
                                    "15 - Danna sep (vocals, drums, bass, other)",
                                    "16 - Byte Dance (vocals, drums, bass, other)",
                                    "17 - UVRv5 Demucs (vocals, music)",
                                    "18 - MVSep DNR (music, sfx, speech)",
                                    "19 - MVSep Vocal Model (vocals, music)",
                                    "20 - Demucs4 HT (vocals, drums, bass, other)",
                                    "--------------------------------------------------------------------------------------------------",
                                    "22 - FoxJoy Reverb Removal (other)",
                                    "23 - MDX B (vocals, instrumental)",
                                    "24 - MVSep Demucs4HT DNR (dialog, sfx, music)",
                                    "25 - MDX23C (vocals, instrumental)",
                                    "26 - Ensemble (vocals, instrumental) [PREMIUM ONLY]",
                                    "27 - Demucs4 Vocals 2023 (vocals, instrumental)",
                                    "28 - Ensemble (vocals, instrumental, bass, drums, other) [PREMIUM ONLY]",
                                    "29 - MVSep Piano (piano, other)",
                                    "30 - Ensemble All-In (vocals, bass, drums, piano, guitar, lead/back vocals, other) [PREMIUM ONLY]",
                                    "31 - MVSep Guitar (guitar, other)",
                                    "-------------------------------------------------------------------------------------------------",
                                    "33 - Vit Large 23 (vocals, instrum)",
                                    "34 - MVSep Crowd removal (crowd, other)",
                                    "35 - MVSep MelBand Roformer (vocals, instrum)",
                                    "36 - BandIt Plus (speech, music, effects)",
                                    "37 - DrumSep (kick, snare, cymbals, toms)",
                                    "38 - LarsNet (kick, snare, cymbals, toms, hihat)",
                                    "39 - Whisper (extract text from audio)",
                                    "40 - BS Roformer (vocals, instrumental)",
                                    "41 - MVSep Bass (bass, other)",
                                    "42 - MVSep MultiSpeaker (MDX23C)",
                                    "43 - MVSEP Multichannel BS (vocals, inst)",
                                    "44 - MVSep Drums (drums, other)",
                                    "45 - Bandit v2 (speech, music, effects)"
                                    ],
                                    max_choices=1,
                                    value="11 - Demucs3 Model B (vocals, drums, bass, other)",
                                    label="Model type:",
                                    interactive=True,
                                    type='index'
                                )
                                send_req = gr.Button("Send request", variant='primary')
                            send_req.click(
                                mvsep_api_request,
                                [mvsep_key, audio_file, sep_dropdown],
                                [gr.Text(label="Output")]
                            )
                with gr.Tab("Send Request via yt link"):
                    with gr.Row():
                        with gr.Column():
                            with gr.Row():
                                mvsep_key2 = gr.Textbox(placeholder="Enter your MVSEP API key.", label="API key")
                                yt_link = gr.Textbox(label="YouTube link")
                                sep_dropdown2 = gr.Dropdown(
                                    ["0 - spleeter (vocals, music)",
                                    "1 - spleeter (vocals, drums, bass, other)",
                                    "2 - spleeter (vocals, drums, bass, piano, other)",
                                    "3 - unmix XL (vocals, drums, bass, other)",
                                    "4 - unmix HQ (vocals, drums, bass, other)",
                                    "5 - unmix SD (vocals, drums, bass, other)",
                                    "6 - unmix SE (vocals, music)",
                                    "7 - MDX A (vocals, drums, bass, other)",
                                    "8 - MDX B (vocals, drums, bass, other)",
                                    "9 - UVR HQ (vocals, music)",
                                    "10 - Demucs3 Model A (vocals, drums, bass, other)",
                                    "11 - Demucs3 Model B (vocals, drums, bass, other)",
                                    "12 - MDX-B Karaoke (lead/back vocals)",
                                    "13 - Demucs2 (vocals, drums, bass, other)",
                                    "14 - Zero Shot (Query Based) (LQ)",
                                    "15 - Danna sep (vocals, drums, bass, other)",
                                    "16 - Byte Dance (vocals, drums, bass, other)",
                                    "17 - UVRv5 Demucs (vocals, music)",
                                    "18 - MVSep DNR (music, sfx, speech)",
                                    "19 - MVSep Vocal Model (vocals, music)",
                                    "20 - Demucs4 HT (vocals, drums, bass, other)",
                                    "--------------------------------------------------------------------------------------------------",
                                    "22 - FoxJoy Reverb Removal (other)",
                                    "23 - MDX B (vocals, instrumental)",
                                    "24 - MVSep Demucs4HT DNR (dialog, sfx, music)",
                                    "25 - MDX23C (vocals, instrumental)",
                                    "26 - Ensemble (vocals, instrumental) [PREMIUM ONLY]",
                                    "27 - Demucs4 Vocals 2023 (vocals, instrumental)",
                                    "28 - Ensemble (vocals, instrumental, bass, drums, other) [PREMIUM ONLY]",
                                    "29 - MVSep Piano (piano, other)",
                                    "30 - Ensemble All-In (vocals, bass, drums, piano, guitar, lead/back vocals, other) [PREMIUM ONLY]",
                                    "31 - MVSep Guitar (guitar, other)",
                                    "-------------------------------------------------------------------------------------------------",
                                    "33 - Vit Large 23 (vocals, instrum)",
                                    "34 - MVSep Crowd removal (crowd, other)",
                                    "35 - MVSep MelBand Roformer (vocals, instrum)",
                                    "36 - BandIt Plus (speech, music, effects)",
                                    "37 - DrumSep (kick, snare, cymbals, toms)",
                                    "38 - LarsNet (kick, snare, cymbals, toms, hihat)",
                                    "39 - Whisper (extract text from audio)",
                                    "40 - BS Roformer (vocals, instrumental)",
                                    "41 - MVSep Bass (bass, other)",
                                    "42 - MVSep MultiSpeaker (MDX23C)",
                                    "43 - MVSEP Multichannel BS (vocals, inst)",
                                    "44 - MVSep Drums (drums, other)",
                                    "45 - Bandit v2 (speech, music, effects)"
                                    ],
                                    max_choices=1,
                                    value="11 - Demucs3 Model B (vocals, drums, bass, other)",
                                    label="Model type:",
                                    interactive=True,
                                    type='index'
                                )
                                send_req2 = gr.Button("Send request", variant='primary')
                            send_req2.click(
                                mvsep_yt_link_request,
                                [mvsep_key2, sep_dropdown2, yt_link],
                                [gr.Text(label="Output")]
                            )
                with gr.Tab("Get status of request"):
                    with gr.Row():
                        with gr.Column():
                            with gr.Row():
                                hash_textbox = gr.Textbox(label="Hash")
                                check_status = gr.Button("Check status", variant='primary')
                                download = gr.Button("Download separated audio", variant='secondary')
                            check_status.click(
                                mvsep_check_request,
                                [hash_textbox],
                                [gr.Text(label="Status")]
                            )
                            download.click(
                                mvsep_download_separated_audio,
                                [hash_textbox],
                                [gr.Text(label="Link(s)")]
                            )

        with gr.TabItem("Changelog"):
            gr.Markdown("v0.99.8 - Added new MVSep models.")
            gr.Markdown("v0.99.7 - Temporarily fixed an issue causing a 400 error to happen whenever a youtube url was placed.")
            gr.Markdown("v0.99.6 - Added a yt link request method for MVSEP.")
            gr.Markdown("v0.99.5 - Added bug fixes and Dropdown instead of button for MVSEP.")
            gr.Markdown("v0.99.4 - Added a button to display the available models for MVSEP.")
            gr.Markdown("v0.99.3 - Added MVSEP in Misc Tools.")
        
app.launch()