Unfortunately, I don't have the answer to your question :-(
However, here are some clues. I need a waveform too in my project, and I'm using ffmpeg for that, with
OS.execute("./ffmpeg/ffmpeg.exe", ["-i", audio.ogg, "-filter_complex", "compand=gain=-6,showwavespic=s=1280x240:colors=blue,drawbox=x=(iw-w)/2:y=(ih-h)/2:w=iw:h=1:replace=1:color=blue-frames:v", "1", waveform.png, "-y"], true)
It might seem obscure, but here is the doc for that
It generates a png image that I scale afterward.Not the best solution, but it fits my needs.
If you want to know how they did it in Godot, here are useful links in the source code:
I'm not really good in audio technology, nor C++, so I have difficulties analysing that code, but you might find it intersting ;-)