BTW, I made a simple script that pipes the YouTube audio directly to SoX for the spectrogram. FFmpeg is used for decoding Opus.
#!/bin/bash
if [ -z "$1" ]; then
echo Missing YouTube URL
exit 1
fi
readarray -t vars <<< "$(yt-dlp --print filename,ext,title,duration "$1")"...