rbarman commited on
Commit
0e6ef53
1 Parent(s): f94e46a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -14
app.py CHANGED
@@ -56,12 +56,14 @@ def separate_audio_by_stem(audio_path, stem_count):
56
  if stem_count == 2:
57
  accompaniment_path = f"{gradio_temp_path}/separated_audio/{audio_filename}/accompaniment.wav"
58
  vocals_path = f"{gradio_temp_path}/separated_audio/{audio_filename}/vocals.wav"
59
- print(f"{accompaniment_path=}")
60
- print(os.path.exists(accompaniment_path))
61
- print(f"{vocals_path=}")
62
- print(os.path.exists(vocals_path))
63
-
64
- return [vocals_path, accompaniment_path]
 
 
65
 
66
  elif stem_count == 4:
67
 
@@ -75,12 +77,15 @@ def separate_audio_by_stem(audio_path, stem_count):
75
  print(f"{bass_path=} \t exists: {os.path.exists(bass_path)}")
76
  print(f"{other_path=} \t exists: {os.path.exists(other_path)}")
77
 
78
-
79
- return [vocals_path, drums_path, bass_path, other_path]
 
 
 
 
80
 
81
  elif stem_count == 5:
82
 
83
-
84
  piano_path = f"{gradio_temp_path}/separated_audio/{audio_filename}/piano.wav"
85
  vocals_path = f"{gradio_temp_path}/separated_audio/{audio_filename}/vocals.wav"
86
  drums_path = f"{gradio_temp_path}/separated_audio/{audio_filename}/drums.wav"
@@ -93,8 +98,13 @@ def separate_audio_by_stem(audio_path, stem_count):
93
  print(f"{bass_path=} \t exists: {os.path.exists(bass_path)}")
94
  print(f"{other_path=} \t exists: {os.path.exists(other_path)}")
95
 
96
-
97
- return [piano_path, vocals_path, drums_path, bass_path, other_path]
 
 
 
 
 
98
 
99
  # Streamlit app content
100
  st.write("Upload an audio file")
@@ -110,9 +120,10 @@ if uploaded_file is not None:
110
  temp_file_path = temp_file.name
111
 
112
  # Process the uploaded audio file
113
- separated_audio_paths = separate_audio_by_stem(temp_file_path, selected_stem_count)
114
 
115
  # Display the output files for download
116
  st.write("Output Files:")
117
- for path in separated_audio_paths:
118
- st.audio(path, format="audio/wav", start_time=0)
 
 
56
  if stem_count == 2:
57
  accompaniment_path = f"{gradio_temp_path}/separated_audio/{audio_filename}/accompaniment.wav"
58
  vocals_path = f"{gradio_temp_path}/separated_audio/{audio_filename}/vocals.wav"
59
+
60
+ print(f"{accompaniment_path=} \t exists: {os.path.exists(accompaniment_path)}")
61
+ print(f"{vocals_path=} \t exists: {os.path.exists(vocals_path)}")
62
+
63
+ return [
64
+ {'description':, 'Accompaniment', 'path':accompaniment_path},
65
+ {'description':, 'Vocals', 'path':vocals_path},
66
+ ]
67
 
68
  elif stem_count == 4:
69
 
 
77
  print(f"{bass_path=} \t exists: {os.path.exists(bass_path)}")
78
  print(f"{other_path=} \t exists: {os.path.exists(other_path)}")
79
 
80
+ return [
81
+ {'description':, 'Vocals', 'path':vocals_path},
82
+ {'description':, 'Drums', 'path':drums_path},
83
+ {'description':, 'Bass', 'path':bass_path},
84
+ {'description':, 'Other', 'path':other_path},
85
+ ]
86
 
87
  elif stem_count == 5:
88
 
 
89
  piano_path = f"{gradio_temp_path}/separated_audio/{audio_filename}/piano.wav"
90
  vocals_path = f"{gradio_temp_path}/separated_audio/{audio_filename}/vocals.wav"
91
  drums_path = f"{gradio_temp_path}/separated_audio/{audio_filename}/drums.wav"
 
98
  print(f"{bass_path=} \t exists: {os.path.exists(bass_path)}")
99
  print(f"{other_path=} \t exists: {os.path.exists(other_path)}")
100
 
101
+ return [
102
+ {'description':, 'Vocals', 'path':vocals_path},
103
+ {'description':, 'Piano', 'path':piano_path},
104
+ {'description':, 'Drums', 'path':drums_path},
105
+ {'description':, 'Bass', 'path':bass_path},
106
+ {'description':, 'Other', 'path':other_path},
107
+ ]
108
 
109
  # Streamlit app content
110
  st.write("Upload an audio file")
 
120
  temp_file_path = temp_file.name
121
 
122
  # Process the uploaded audio file
123
+ separate_audios = separate_audio_by_stem(temp_file_path, selected_stem_count)
124
 
125
  # Display the output files for download
126
  st.write("Output Files:")
127
+ for audio in separate_audios:
128
+ st.write(audio.description)
129
+ st.audio(audio.path, format="audio/wav", start_time=0)