Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
-
import
|
4 |
import subprocess
|
5 |
|
6 |
def separate_audio(audio_path, stem_count):
|
@@ -19,29 +19,21 @@ def separate_audio(audio_path, stem_count):
|
|
19 |
|
20 |
result = subprocess.run(command)
|
21 |
print(result)
|
22 |
-
|
23 |
paths = []
|
24 |
if stem_count == 2:
|
25 |
-
paths.append(('Accompaniment', f"{gradio_temp_path}/separated_audio/{
|
26 |
-
paths.append(('Vocals', f"{gradio_temp_path}/separated_audio/{
|
27 |
elif stem_count == 4 or stem_count == 5:
|
28 |
-
paths.append(('Vocals', f"{gradio_temp_path}/separated_audio/{
|
29 |
-
paths.append(('Drums', f"{gradio_temp_path}/separated_audio/{
|
30 |
-
paths.append(('Bass', f"{gradio_temp_path}/separated_audio/{
|
31 |
-
paths.append(('Other', f"{gradio_temp_path}/separated_audio/{
|
32 |
if stem_count == 5:
|
33 |
-
paths.append(('Piano', f"{gradio_temp_path}/separated_audio/{
|
34 |
|
35 |
return paths
|
36 |
|
37 |
-
def gradio_interface(audio_file, stem_count):
|
38 |
-
with tempfile.NamedTemporaryFile(delete=False) as temp_file:
|
39 |
-
temp_file.write(audio_file)
|
40 |
-
temp_file_path = temp_file.name
|
41 |
-
|
42 |
-
separated_audios = separate_audio(temp_file_path, stem_count)
|
43 |
-
return [gr.Audio(file_path, label=description) for description, file_path in separated_audios]
|
44 |
-
|
45 |
iface = gr.Interface(
|
46 |
fn=separate_audio,
|
47 |
inputs=[gr.Audio(type="filepath"), gr.Radio([2, 4, 5])],
|
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
+
import random
|
4 |
import subprocess
|
5 |
|
6 |
def separate_audio(audio_path, stem_count):
|
|
|
19 |
|
20 |
result = subprocess.run(command)
|
21 |
print(result)
|
22 |
+
randomnumber = str(random.randint(111111111, 999999999))
|
23 |
paths = []
|
24 |
if stem_count == 2:
|
25 |
+
paths.append(('Accompaniment', f"{gradio_temp_path}/separated_audio/{randomnumber}/accompaniment.wav"))
|
26 |
+
paths.append(('Vocals', f"{gradio_temp_path}/separated_audio/{randomnumber}/vocals.wav"))
|
27 |
elif stem_count == 4 or stem_count == 5:
|
28 |
+
paths.append(('Vocals', f"{gradio_temp_path}/separated_audio/{randomnumber}/vocals.wav"))
|
29 |
+
paths.append(('Drums', f"{gradio_temp_path}/separated_audio/{randomnumber}/drums.wav"))
|
30 |
+
paths.append(('Bass', f"{gradio_temp_path}/separated_audio/{randomnumber}/bass.wav"))
|
31 |
+
paths.append(('Other', f"{gradio_temp_path}/separated_audio/{randomnumber}/other.wav"))
|
32 |
if stem_count == 5:
|
33 |
+
paths.append(('Piano', f"{gradio_temp_path}/separated_audio/{randomnumber}/piano.wav"))
|
34 |
|
35 |
return paths
|
36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
iface = gr.Interface(
|
38 |
fn=separate_audio,
|
39 |
inputs=[gr.Audio(type="filepath"), gr.Radio([2, 4, 5])],
|