Spaces:
Runtime error
Runtime error
File size: 1,758 Bytes
e62200f 8482b0b e62200f 8482b0b bd1f851 8482b0b 20d74ef 8482b0b 20d74ef 8482b0b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
import streamlit as st
import os
import tempfile
import subprocess
# Set Streamlit app title
st.title("Audio Processing App")
# Function to process the audio file
def separate_audio(audio_path):
print(f"{audio_path=}")
head, tail = os.path.split(audio_path)
gradio_temp_path = head
audio_filename = tail.split('.')[0]
print(f"{gradio_temp_path=}")
print(f"{audio_filename=}")
# command = f"spleeter separate -o {gradio_temp_path} -p spleeter:2stems {audio_path}"
# command = f"ls {gradio_temp_path}"
command = f"cp {audio_path} output/test.wav"
command = command.split()
print(f"{command=}")
result = subprocess.run(command)
print(result)
print("--------")
accompaniment_path = f"{gradio_temp_path}/{audio_filename}/accompaniment.wav"
vocals_path = f"{gradio_temp_path}/{audio_filename}/vocals.wav"
print(f"{accompaniment_path=}")
print(os.path.exists(accompaniment_path))
print(f"{vocals_path=}")
print(os.path.exists(vocals_path))
return vocals_path, accompaniment_path
# Streamlit app content
st.write("Upload an audio file (.wav)")
uploaded_file = st.file_uploader("Choose a file", type=["wav","mp3"])
if uploaded_file is not None:
# Save the uploaded file to a temporary location
with tempfile.NamedTemporaryFile(delete=False) as temp_file:
temp_file.write(uploaded_file.read())
temp_file_path = temp_file.name
# Process the uploaded audio file
vocals_path, accompaniment_path = separate_audio(temp_file_path)
# Display the output files for download
st.write("Output Files:")
st.audio(vocals_path, format="audio/wav", start_time=0)
st.audio(accompaniment_path, format="audio/wav", start_time=0)
|