In FastAPI, I have (abbreviated):
import librosa
y, sr = librosa.load("somefile.mp3", sr=None)
print(y)
which gives me an array of numbers that starts with:
[-2.7663191e-08 -2.4432666e-08 -1.3060344e-09 ...
But for the same exact MP3, doing this in WaveSurfer (abbreviated):
wavesurfer.on("ready", () => {
let waveformData = wavesurfer.backend.getPeaks(300, 0, 300)
console.log(waveformData)
gives me an array of numbers that starts with:
[0.00575189059600234, -0.006252573803067207, 0.2315024882555008....]
I’m probably using Librosa incorrectly. How can I get Librosa to give me the same output WaveSurfer does? I want to batch process my audio files server-side, store the waveform data, then have Wavesurfer use that data later in the client.
The best clue I’ve found so far is WaveSurfer documentation which recommends doing this for server-side conversions:
audiowaveform -i somefile.mp3 -o somefile.json --pixels-per-second 20 --bits 8
But there’s no Python package for audiowaveform. And I’m pretty sure Librosa can do this. What am I doing wrong?