Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -13,38 +13,31 @@ def separate_audio(audio_path, stem_count):
|
|
| 13 |
print(f"{audio_filename=}")
|
| 14 |
print(f"{stem_count=}")
|
| 15 |
|
| 16 |
-
|
| 17 |
-
randomnumber = str(random.randint(111111111, 999999999))
|
| 18 |
-
output_folder = f"{gradio_temp_path}/separated_audio/{randomnumber}"
|
| 19 |
-
os.makedirs(output_folder, exist_ok=True)
|
| 20 |
-
|
| 21 |
-
command = f"spleeter separate -p spleeter:{stem_count}stems -o {output_folder} {audio_path}"
|
| 22 |
command = command.split()
|
| 23 |
print(f"{command=}")
|
| 24 |
|
| 25 |
-
result = subprocess.run(command
|
| 26 |
print(result)
|
| 27 |
-
|
| 28 |
-
print(f"Error: {result.stderr.decode('utf-8')}")
|
| 29 |
-
return []
|
| 30 |
-
|
| 31 |
-
# Check if the separated files exist and return their paths
|
| 32 |
paths = []
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
|
|
|
|
|
|
| 41 |
|
| 42 |
return paths
|
| 43 |
|
| 44 |
iface = gr.Interface(
|
| 45 |
fn=separate_audio,
|
| 46 |
inputs=[gr.Audio(type="filepath"), gr.Radio([2, 4, 5])],
|
| 47 |
-
outputs=
|
| 48 |
)
|
| 49 |
|
| 50 |
iface.launch()
|
|
|
|
| 13 |
print(f"{audio_filename=}")
|
| 14 |
print(f"{stem_count=}")
|
| 15 |
|
| 16 |
+
command = f"spleeter separate -p spleeter:{stem_count}stems {audio_path}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
command = command.split()
|
| 18 |
print(f"{command=}")
|
| 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])],
|
| 40 |
+
outputs="text",
|
| 41 |
)
|
| 42 |
|
| 43 |
iface.launch()
|