Spaces:
Sleeping
Sleeping
Tamanna Alam
commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,3 @@
|
|
| 1 |
-
# for local run: Streamlit run app.py
|
| 2 |
-
|
| 3 |
import streamlit as st
|
| 4 |
import os
|
| 5 |
import subprocess
|
|
@@ -16,7 +14,7 @@ def save_uploaded_file(uploaded_file):
|
|
| 16 |
# Function to process audio file with demucs
|
| 17 |
def process_audio_with_demucs(audio_file_path):
|
| 18 |
try:
|
| 19 |
-
subprocess.run(['demucs', audio_file_path], check=True)
|
| 20 |
return True
|
| 21 |
except subprocess.CalledProcessError as e:
|
| 22 |
st.error(f"Error executing demucs command: {e}")
|
|
@@ -49,12 +47,12 @@ if uploaded_file is not None:
|
|
| 49 |
|
| 50 |
with col2:
|
| 51 |
st.markdown("### Processed Audio (Demucs)")
|
| 52 |
-
if st.button("
|
| 53 |
if process_audio_with_demucs(audio_file_path):
|
| 54 |
-
processed_audio_file_path = os.path.join("separated", "htdemucs", os.path.splitext(uploaded_file.name)[0], "vocals.
|
| 55 |
if os.path.exists(processed_audio_file_path):
|
| 56 |
processed_audio_bytes = open(processed_audio_file_path, "rb").read()
|
| 57 |
-
st.audio(processed_audio_bytes, format='audio/
|
| 58 |
else:
|
| 59 |
st.error("Processed audio file not found.")
|
| 60 |
else:
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import os
|
| 3 |
import subprocess
|
|
|
|
| 14 |
# Function to process audio file with demucs
|
| 15 |
def process_audio_with_demucs(audio_file_path):
|
| 16 |
try:
|
| 17 |
+
subprocess.run(['demucs',"--mp3", audio_file_path], check=True)
|
| 18 |
return True
|
| 19 |
except subprocess.CalledProcessError as e:
|
| 20 |
st.error(f"Error executing demucs command: {e}")
|
|
|
|
| 47 |
|
| 48 |
with col2:
|
| 49 |
st.markdown("### Processed Audio (Demucs)")
|
| 50 |
+
if st.button("Process Audio with Demucs"):
|
| 51 |
if process_audio_with_demucs(audio_file_path):
|
| 52 |
+
processed_audio_file_path = os.path.join("separated", "htdemucs", os.path.splitext(uploaded_file.name)[0], "vocals.mp3")
|
| 53 |
if os.path.exists(processed_audio_file_path):
|
| 54 |
processed_audio_bytes = open(processed_audio_file_path, "rb").read()
|
| 55 |
+
st.audio(processed_audio_bytes, format='audio/mp3', start_time=0)
|
| 56 |
else:
|
| 57 |
st.error("Processed audio file not found.")
|
| 58 |
else:
|