Update app.py
Browse files
app.py
CHANGED
@@ -12,6 +12,10 @@ def ensure_directory_exists(directory):
|
|
12 |
if not os.path.exists(directory):
|
13 |
os.makedirs(directory)
|
14 |
|
|
|
|
|
|
|
|
|
15 |
# Function to process the audio
|
16 |
def process_audio(file_path):
|
17 |
# Ensure to navigate to the home directory first
|
@@ -75,21 +79,24 @@ if uploaded_file is not None:
|
|
75 |
|
76 |
# Display and download each generated audio
|
77 |
for file in output_files:
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
|
|
|
|
|
|
|
12 |
if not os.path.exists(directory):
|
13 |
os.makedirs(directory)
|
14 |
|
15 |
+
# Function to check if the file exists
|
16 |
+
def file_exists(file_path):
|
17 |
+
return os.path.isfile(file_path)
|
18 |
+
|
19 |
# Function to process the audio
|
20 |
def process_audio(file_path):
|
21 |
# Ensure to navigate to the home directory first
|
|
|
79 |
|
80 |
# Display and download each generated audio
|
81 |
for file in output_files:
|
82 |
+
if file_exists(file):
|
83 |
+
file_name = os.path.basename(file)
|
84 |
+
if 'vocals.wav' in file_name:
|
85 |
+
st.write('Vocal')
|
86 |
+
elif 'bass.wav' in file_name:
|
87 |
+
st.write('Bass')
|
88 |
+
elif 'drums.wav' in file_name:
|
89 |
+
st.write('Drums')
|
90 |
+
elif 'accompaniment.wav' in file_name:
|
91 |
+
st.write('Music')
|
92 |
+
|
93 |
+
st.audio(file)
|
94 |
+
with open(file, 'rb') as f:
|
95 |
+
st.download_button(
|
96 |
+
label=f'Download {file_name}',
|
97 |
+
data=f,
|
98 |
+
file_name=file_name,
|
99 |
+
mime='audio/wav'
|
100 |
+
)
|
101 |
+
else:
|
102 |
+
st.error(f"Error: {file} not found.")
|