nakas commited on
Commit
780b186
·
1 Parent(s): a69b793

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -20
app.py CHANGED
@@ -3,27 +3,27 @@ import gradio as gr
3
  from scipy.io.wavfile import write
4
  from gradio import components
5
 
6
- def inference(audio):
7
- os.makedirs("out", exist_ok=True)
8
- write('test.wav', audio[0], audio[1])
9
- os.system("python3 -m demucs.separate -n mdx_extra_q -d cpu test.wav -o out")
10
-
11
- # Paths to the output files
12
- files = ["./out/mdx_extra_q/test/vocals.wav",
13
- "./out/mdx_extra_q/test/bass.wav",
14
- "./out/mdx_extra_q/test/drums.wav",
15
- "./out/mdx_extra_q/test/other.wav"]
16
 
17
- # Check for the existence of the files
18
- start_time = time.time()
19
- while True:
20
- if all(os.path.exists(file) for file in files):
21
- break
22
- elif time.time() - start_time > 30: # timeout after 30 seconds
23
- raise TimeoutError("Timeout while waiting for output files to be created.")
24
- time.sleep(1) # wait a bit before checking again
25
-
26
- return tuple(files)
 
 
 
 
 
 
27
 
28
  title = "Demucs"
29
  description = "Forked from here https://huggingface.co/spaces/akhaliq/demucs/ and changed to updated demucs pip source. Gradio demo for Demucs: Music Source Separation in the Waveform Domain. To use it, simply upload your audio, or click one of the examples to load them. Read more at the links below."
 
3
  from scipy.io.wavfile import write
4
  from gradio import components
5
 
6
+ def inference(audio):
7
+ os.makedirs("out", exist_ok=True)
8
+ write('test.wav', audio[0], audio[1])
9
+ os.system("python3 -m demucs.separate -n mdx_extra_q -d cpu test.wav -o out")
 
 
 
 
 
 
10
 
11
+ # Paths to the output files
12
+ files = ["./out/mdx_extra_q/test/vocals.wav",
13
+ "./out/mdx_extra_q/test/bass.wav",
14
+ "./out/mdx_extra_q/test/drums.wav",
15
+ "./out/mdx_extra_q/test/other.wav"]
16
+
17
+ # Check for the existence of the files
18
+ start_time = time.time()
19
+ while True:
20
+ if all(os.path.exists(file) for file in files):
21
+ break
22
+ elif time.time() - start_time > 30: # timeout after 30 seconds
23
+ raise TimeoutError("Timeout while waiting for output files to be created.")
24
+ time.sleep(1) # wait a bit before checking again
25
+
26
+ return tuple(files)
27
 
28
  title = "Demucs"
29
  description = "Forked from here https://huggingface.co/spaces/akhaliq/demucs/ and changed to updated demucs pip source. Gradio demo for Demucs: Music Source Separation in the Waveform Domain. To use it, simply upload your audio, or click one of the examples to load them. Read more at the links below."