I used pydub
to load the audio file just as follows,
audio = AudioSegment.from_mp3(file_path).set_frame_rate(22050).set_channel(1)
but if i get the binary data of the audio file, i use the following way,
def get_file_content(filePath):
with open(filePath, 'rb') as fp:
return fp.read()
audio = AudioSegment(data=get_file_content(file_path), sample_width=2, frame_rate=22050, channels=1)
However when i try to use the property audio.get_array_of_samples()
, i got different array from these two ways.
So i want to ask how to make these two way output the same array in reading the same audio.