TheMaisk commited on
Commit
434a20f
·
1 Parent(s): ea8a6e6

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +51 -0
app.py ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import gradio as gr
3
+ from scipy.io.wavfile import write, read
4
+ import subprocess
5
+
6
+ def inference(audio):
7
+
8
+ os.makedirs("out", exist_ok=True)
9
+ write('mix.wav', audio[0], audio[1])
10
+
11
+ command = "python3 -m demucs -n mdx_extra_q -d cpu mix.wav -o out"
12
+ process = subprocess.run(command,
13
+ shell=True,
14
+ stdin=subprocess.DEVNULL,
15
+ stdout=subprocess.PIPE,
16
+ stderr=subprocess.PIPE
17
+ )
18
+
19
+ # Check if files exist before returning
20
+ files = ["./out/mdx_extra_q/mix/vocals.wav",
21
+ "./out/mdx_extra_q/mix/bass.wav",
22
+ "./out/mdx_extra_q/mix/drums.wav",
23
+ "./out/mdx_extra_q/mix/other.wav"]
24
+
25
+ for file in files:
26
+ if not os.path.isfile(file):
27
+ print(f"File not found: {file}")
28
+ else:
29
+ print(f"File exists: {file}")
30
+
31
+ return files
32
+
33
+ article = "Inspired by <p><a href='https://github.com/facebookresearch/demucs' target='_blank'>Demucs</a></p>\n<p>Copyright &copy; 2023 JP Madsen</p"
34
+
35
+
36
+ demo = gr.Interface(
37
+ inference,
38
+ gr.inputs.Audio(type = "numpy", label = "Input"),
39
+ [gr.outputs.Audio(type = "filepath", label = "Vocals"),
40
+ gr.outputs.Audio(type = "filepath", label = "Bass"),
41
+ gr.outputs.Audio(type = "filepath", label = "Drums"),
42
+ gr.outputs.Audio(type = "filepath", label = "Other")
43
+ ],
44
+ article = article,
45
+ theme = 'NoCrypt/[email protected]',
46
+ allow_flagging = "never",
47
+ css="style.css", # Hinzugefügt
48
+ )
49
+
50
+ #demo.queue(concurrency_count = 10)
51
+ demo.launch()