0

I have a wav audio file and i extracted data from that wav using python pydub module and i got this data

[-139 18 -215 34 -196 6 -295 -31 -301 -35 -211 13 -93 47 -60 39 -58 7 -17 2]

(this is first 10 data i got more than 1 million data)

from pydub import AudioSegment
import numpy as np

song = AudioSegment.from_file("test.wav")
extract_data = np.array(song.get_array_of_samples())
print(extract_data[:10])

then i converted wav to mp3 using that module and again extracted data from mp3 file and i got this data

[-108 7 -193 24 -223 11 -239 -31 -248 -43 -203 -10 -101 23 -14 24 10 15 24 16]

(this is first 10 data i got more than 1 million data)

song = AudioSegment.from_file("test.wav")
song.export("test.mp3")
mp3_song = AudioSegment.from_file("test.mp3")
extract_data = np.array(mp3_song.get_array_of_samples())
print(extract_data[:10])

and again i converted mp3 to wav now i got mp3 data instead of wav data.

mp3_song = AudioSegment.from_file("test.mp3")
mp3_song.export("test1.wav", format="wav")

song = AudioSegment.from_file("test1.wav")
extract_data = np.array(song.get_array_of_samples())
print(extract_data[:10])

My point is how to convert mp3 data to original wav data?

please help me,

Thanks.

Yali
  • 1
  • 2

1 Answers1

3

Because .MP3 uses 'lossy' compression, you wont get the same data back when converted as data is 'lossed'. The data is compressed and information is lost in the process.

If you were to convert back and forth indefinetely the data would degrade indefinetely!

Impossible to get the data back!