pythonpython-3.xaudiolibrosapyaudioanalysis

How do I find amplitude of wav file in python?


I am working with wav files analysis using the librosa library in python. I used librosa.load() to load the audio file. Apparently this function loads the wav file into a numpy array with normalised amplitude values in the range -1 to 1. But I need to get the actual amplitude values for processing. How can I find that?

Thanks in advance!


Solution

  • You can't. As Hendrik mentioned, the signal is digital and the amplitude in the WAV file won't tell you anything about the actual sound wave amplitude / sound power. That's completely lost the moment it was digitalised to WAV.

    That being said, you can compute e.g. loudness, a relative perception of the sound power. If you are dealing with human auditory system, one of the recommended approaches is to:

    1. Use to the Bark scale (Bark scale better reflects how we hear).
    2. Compute energy in each bin.
    3. (Optional) Normalise by the overall sum.

    If you don't want to compute it yourself, check out e.g. YAAFE.