K. Min
K. Min

Reputation: 1

What is the unit of audio sample in librosa?

These days, I'm using librosa which is a kind of audio processing library. As a basic step to load audio files, one can use the function below.

librosa.core.load()
  1. Then an audio file is represented as audio time series. I think each value of the time series is an amplitude of audio. However, I wonder what the unit of the amplitudes is.
  2. Also, what is the relationship among amplitude, power, dB, and energy?

Upvotes: 0

Views: 825

Answers (2)

B. Latif
B. Latif

Reputation: 52

There are no defined units for amplitude in Librosa's docs. However, you can convert amplitude into decibel units using the following command: librosa.amplitude_to_db(S, ref=1.0, amin=1e-05, top_db=80.0)

Documentation for Librosa's magnitude functions can be found here: https://librosa.org/doc/main/core.html#magnitude-scaling

Upvotes: -1

Jon Nordby
Jon Nordby

Reputation: 6259

librosa.load returns a numpy array of type float32, with values between -1.0 and 1.0. What physical quantity these values correspond to in the real world (or if they do at all) is unknown. So on its own, it is unitless.

If they file was recorded with a microphone, the values are linear with changes in air pressure. If you know the air pressure at time of recording (mean and min/max), you could map the values back to pressure (unit: Pascal).

Upvotes: 2

Related Questions