librosa does not normalize wave file between [-1, 1]

1,599 views
Skip to first unread message

Good Robot

unread,
Dec 5, 2020, 1:15:29 PM12/5/20
to librosa

In passing a file via the use:

       librosa_audio, librosa_sample_rate = librosa.load(filename)

The output produces an audio file such that:

Librosa audio file min~max range: -1.2105224 to 1.2942806

The file that I am working on was obtained from https://www.boomlibrary.com/ and had a bit depth of 24. I down sampled to 16 and also up sampled to 32 to work with librosa. Both of these files produced the same min-max range after going through librosa.

Why does this happen?
Is there a way to parse the wav file to Librosa such that the data will fall between [-1,1]?

Brian McFee

unread,
Dec 7, 2020, 9:36:39 AM12/7/20
to librosa
If you want to normalize the audio, you can use librosa.util.normalize.  By default, this will do peak normalization, which should do what you want.

Per your second question: changing bit depth does not necessarily change the normalization of a wav file.  It can, if your sample values are near the limits of the integer range in question, but it sounds like that's not the case for your particular example.

Good Robot

unread,
Dec 7, 2020, 11:00:39 AM12/7/20
to Brian McFee, librosa
Thank you for your response!

Sincerely appreciated!

On Mon, Dec 7, 2020 at 9:36 AM Brian McFee <brian...@nyu.edu> wrote:
    EXTERNAL EMAIL : Exercise caution when responding, opening links, or opening attachments.
 
--
You received this message because you are subscribed to a topic in the Google Groups "librosa" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/librosa/4sQW001w_c8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to librosa+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/librosa/afe71ffb-c922-4acf-9c01-23f613ae7936n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages