Spaces:
Runtime error
Runtime error
Next
commited on
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
from scipy.io.wavfile import write
|
| 3 |
+
import gradio as gr
|
| 4 |
+
|
| 5 |
+
def separator(audio):
|
| 6 |
+
os.makedirs("output", exist_ok=True)
|
| 7 |
+
write('test.wav', audio[0], audio[1])
|
| 8 |
+
result = os.system("audio-separator test.wav --model_filename model_bs_roformer_ep_317_sdr_12.9755.ckpt --output_dir=./output --output_format=wav")
|
| 9 |
+
|
| 10 |
+
files = [
|
| 11 |
+
"./output/test_(Instrumental)_model_bs_roformer_ep_317_sdr_12.wav",
|
| 12 |
+
"./output/test_(Vocals)_model_bs_roformer_ep_317_sdr_12.wav"
|
| 13 |
+
]
|
| 14 |
+
|
| 15 |
+
for file in files:
|
| 16 |
+
if not os.path.isfile(file):
|
| 17 |
+
print(f"File not found: {file}")
|
| 18 |
+
else:
|
| 19 |
+
print(f"File exists: {file}")
|
| 20 |
+
|
| 21 |
+
return files
|
| 22 |
+
|
| 23 |
+
with gr.Blocks() as demo:
|
| 24 |
+
audio_input = gr.Audio(type="numpy", label="Input")
|
| 25 |
+
|
| 26 |
+
output1 = gr.Audio(type="filepath", label="Stem 1", interactive=False)
|
| 27 |
+
output2 = gr.Audio(type="filepath", label="Stem 2", interactive=False)
|
| 28 |
+
submit_button = gr.Button("Separate")
|
| 29 |
+
submit_button.click(separator, inputs=audio_input, outputs=[output1, output2])
|
| 30 |
+
|
| 31 |
+
demo.launch()
|