|
import streamlit as st |
|
import os |
|
import tempfile |
|
import subprocess |
|
|
|
|
|
st.title("Audio Processing App") |
|
|
|
|
|
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"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 |
|
|
|
|
|
st.write("Upload an audio file (.wav)") |
|
|
|
uploaded_file = st.file_uploader("Choose a file", type=["wav","mp3"]) |
|
|
|
if uploaded_file is not None: |
|
|
|
vocals_path, accompaniment_path = separate_audio(uploaded_file) |
|
|
|
|
|
st.write("Output Files:") |
|
st.audio(vocals_path, format="audio/wav", start_time=0) |
|
st.audio(accompaniment_path, format="audio/wav", start_time=0) |
|
|