def decoding_stems(file_name):
audio, sr = sp.read_stems(file_name, sample_rate=22050)
swap_ad = np.swapaxes(audio, 1 , 2) # swaps the first and second axis because most libraries execpt num channels in the second axis and the data in the first
duration = lb.get_duration(swap_ad[1])
duration_length = (duration // 0.6) * 6 # rounds the song duration to be divisilbe by 6 so that each sound segment is in equal length
return stft_frame(file_name, int(duration_length), 6)
this is the code that I ran for getting de constructed files. When I called this and ran for the train code
train_audio_data = []
for i in range(len(train_song_names)):
file_path = path + '/train/' + train_song_names[i] + '.mp4'
audio_seg = decoding_stems(file_path)
train_audio_data.append(audio_seg)
it ran but gave an error for the test part
this is the code for the test part
test_audio_data = []
for i in range(len(test_song_names)):
file_path = path + '/test/' + test_song_names[i] + '.mp4'
audio_seg = decoding_stems(file_path)
test_audio_data.append(audio_seg)
the error that I got was
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-19-3f8fadcdbe66> in <cell line: 6>()
7
8 file_path = path + '/test/' + test_song_names[i] + '.mp4'
----> 9 audio_seg = decoding_stems(file_path)
10
11
<ipython-input-12-359828c0d17d> in decoding_stems(file_name)
10
11 swap_ad = np.swapaxes(audio, 1 , 2) # swaps the first and second axis because most libraries execpt num channels in the second axis and the data in the first
---> 12 duration = lb.get_duration(swap_ad[1])
13
14 duration_length = (duration // 0.6) * 6 # rounds the song duration to be divisilbe by 6 so that each sound segment is in equal length
TypeError: get_duration() takes 0 positional arguments but 1 was given
use this :