Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A quick way to generate spectrograms for a bunch of audio files
### Generate PNG spectrograms using SoX
### Use the input file name as the title within the image as well as the output file name
### Set the width to 2000 (seems to output a ~2140px wide image)
### Generate for FLAC
for file in *.flac;do
outfile="${file%.*}.png"
title_in_pic="${file%.*}"
sox "$file" -n spectrogram -t "$title_in_pic" -o "$outfile" -x 2000
done
### Generate for MP3
for file in *.mp3;do
outfile="${file%.*}.png"
title_in_pic="${file%.*}"
sox "$file" -n spectrogram -t "$title_in_pic" -o "$outfile" -x 2000
done
### Generate for Ogg Vorbis
for file in *.ogg;do
outfile="${file%.*}.png"
title_in_pic="${file%.*}"
sox "$file" -n spectrogram -t "$title_in_pic" -o "$outfile" -x 2000
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.