Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -22,12 +22,14 @@ button_click = st.button("Run Analysis", type="primary")
|
|
22 |
|
23 |
# load song
|
24 |
input_file = os.path.join(os.path.dirname(__file__), 'test1.mp3')
|
25 |
-
output_file = os.path.join(os.path.dirname(__file__))
|
|
|
26 |
|
27 |
# preprocess and crop audio file
|
28 |
|
29 |
def audio_preprocess():
|
30 |
# separate music and vocal
|
|
|
31 |
separator = Separator('spleeter:2stems')
|
32 |
separator.separate_to_file(input_file, output_file)
|
33 |
|
@@ -35,7 +37,8 @@ def audio_preprocess():
|
|
35 |
start_time = 60000 # e.g. 30 seconds, 30000
|
36 |
end_time = 110000 # e.g. 40 seconds, 40000
|
37 |
|
38 |
-
audio = AudioSegment.from_file(os.path.join(os.path.dirname(__file__), 'vocals.wav'))
|
|
|
39 |
cropped_audio = audio[start_time:end_time]
|
40 |
cropped_audio.export(os.path.join(os.path.dirname(__file__), 'cropped_vocals.wav'), format='wav') # save vocal audio file
|
41 |
|
|
|
22 |
|
23 |
# load song
|
24 |
input_file = os.path.join(os.path.dirname(__file__), 'test1.mp3')
|
25 |
+
#output_file = os.path.join(os.path.dirname(__file__))
|
26 |
+
output_file = None
|
27 |
|
28 |
# preprocess and crop audio file
|
29 |
|
30 |
def audio_preprocess():
|
31 |
# separate music and vocal
|
32 |
+
global output_file, cropped_audio
|
33 |
separator = Separator('spleeter:2stems')
|
34 |
separator.separate_to_file(input_file, output_file)
|
35 |
|
|
|
37 |
start_time = 60000 # e.g. 30 seconds, 30000
|
38 |
end_time = 110000 # e.g. 40 seconds, 40000
|
39 |
|
40 |
+
#audio = AudioSegment.from_file(os.path.join(os.path.dirname(__file__), 'vocals.wav'))
|
41 |
+
audio = AudioSegment.from_file(output_file[0]) # Use the global output_file variable for vocal part
|
42 |
cropped_audio = audio[start_time:end_time]
|
43 |
cropped_audio.export(os.path.join(os.path.dirname(__file__), 'cropped_vocals.wav'), format='wav') # save vocal audio file
|
44 |
|