Hev832 commited on
Commit
03466f0
Β·
verified Β·
1 Parent(s): ec3d048

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +45 -0
app.py ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import spaces
3
+ import gradio as gr
4
+ from scipy.io.wavfile import write
5
+
6
+ @spaces.GPU()
7
+ def inference(audio):
8
+ os.makedirs("out", exist_ok=True)
9
+ write('test.wav', audio[0], audio[1])
10
+ os.system("python3 -m demucs.separate -n htdemucs --two-stems=vocals -d cpu test.wav -o out")
11
+ return "./out/htdemucs/test/vocals.wav","./out/htdemucs/test/no_vocals.wav"
12
+
13
+ title = "# Ilaria UVR πŸ’–"
14
+ description = "Drag and drop an audio file to easily separate it! [Join AI Hub Discord Server](https://discord.gg/aihub).</p>"
15
+ article = "Made with πŸ’– by Ilaria"
16
+
17
+ examples = [['test.mp3']]
18
+
19
+ with gr.Blocks(title="Ilaria UVR πŸ’–") as demo:
20
+ gr.Markdown(f"# {title}")
21
+ gr.Markdown(description)
22
+ with gr.Row():
23
+ audio_input = gr.Audio(type="numpy", label="Song")
24
+ with gr.Row():
25
+ vocals_output = gr.Audio(type="filepath", label="Vocals")
26
+ with gr.Row():
27
+ instrumentals_output = gr.Audio(type="filepath", label="Instrumentals")
28
+ with gr.Row():
29
+ gr.Examples(examples, inputs=audio_input)
30
+ with gr.Row():
31
+ btn = gr.Button("Separate Vocals")
32
+ with gr.Row():
33
+ gr.Markdown(article)
34
+ btn.click(
35
+ inference,
36
+ inputs=[
37
+ audio_input,
38
+ ],
39
+ outputs=[
40
+ vocals_output,
41
+ instrumentals_output,
42
+ ],
43
+ )
44
+
45
+ demo.launch()