Rozinamax commited on
Commit
0b93855
1 Parent(s): 2f0083d

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -20
app.py CHANGED
@@ -1,28 +1,47 @@
1
- import gradio as gr
2
  import os
 
3
  from scipy.io.wavfile import write
 
4
 
5
  def inference(audio):
6
- os.makedirs("out", exist_ok=True)
7
- write('test.wav', audio[0], audio[1])
8
- os.system("python3 -m demucs.separate -n htdemucs_ft test.wav -o out")
9
- return "./out/htdemucs_ft/test/vocals.wav","./out/htdemucs_ft/test/bass.wav",\
10
- "./out/htdemucs_ft/test/drums.wav","./out/htdemucs_ft/test/other.wav"
11
 
12
- title = "Demucs"
13
- description = "Demucs: Music Source Separation"
14
- article = "<p style='text-align: center'><a href='' target='_blank'></a> | <a href='https://github.com/facebookresearch/demucs' target='_blank'>Github</a></p>"
 
 
 
 
 
15
 
16
- examples=[['test.mp3']]
 
 
 
 
 
 
 
 
 
17
 
18
- iface = gr.Interface(
19
- inference,
20
- gr.inputs.Audio(type="numpy", label="Input"),
21
- [gr.outputs.Audio(type="file", label="Vocals"),gr.outputs.Audio(type="file", label="Bass"),gr.outputs.Audio(type="file", label="Drums"),gr.outputs.Audio(type="file", label="Other")],
22
- title=title,
23
- description=description,
24
- article=article,
25
- examples=examples
26
- )
27
 
28
- iface.launch(enable_queue=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import os
2
+ import gradio as gr
3
  from scipy.io.wavfile import write
4
+ import subprocess
5
 
6
  def inference(audio):
7
+ os.makedirs("out", exist_ok=True)
8
+ write('test.wav', audio[0], audio[1])
 
 
 
9
 
10
+ command = "python3 -m demucs.separate -n htdemucs_ft -d cpu test.wav -o out"
11
+ process = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
12
+ print("Demucs script output:", process.stdout.decode())
13
+
14
+ os.makedirs("out", exist_ok=True)
15
+ write('test.wav', audio[0], audio[1])
16
+ result = os.system("python3 -m demucs.separate -n htdemucs_ft -d cpu test.wav -o out")
17
+ print(f"Demucs script result: {result}")
18
 
19
+ # Check if files exist before returning
20
+ files = ["./out/htdemucs_ft/test/vocals.wav",
21
+ "./out/htdemucs_ft/test/bass.wav",
22
+ "./out/htdemucs_ft/test/drums.wav",
23
+ "./out/htdemucs_ft/test/other.wav"]
24
+ for file in files:
25
+ if not os.path.isfile(file):
26
+ print(f"File not found: {file}")
27
+ else:
28
+ print(f"File exists: {file}")
29
 
30
+ return files
31
+
32
+ title = "Demucs Very Slow"
33
+ description = ""
34
+ article = "<p style='text-align: center'><a href='' target='_blank'>Music Separation Very Slow</a> <a href='' target='_blank'></a></p>"
 
 
 
 
35
 
36
+ examples=[['test.mp3']]
37
+ gr.Interface(
38
+ inference,
39
+ gr.components.Audio(type="numpy", label="Input"),
40
+ [gr.components.Audio(type="filepath", label="Vocals"),
41
+ gr.components.Audio(type="filepath", label="Bass"),
42
+ gr.components.Audio(type="filepath", label="Drums"),
43
+ gr.components.Audio(type="filepath", label="Other")],
44
+ title=title,
45
+ description=description,
46
+ article=article
47
+ ).launch(enable_queue=True)