Skip to content

Instantly share code, notes, and snippets.

@hrywlms
Last active November 29, 2022 20:43
Show Gist options
  • Save hrywlms/5fca1ab19670363a2d43 to your computer and use it in GitHub Desktop.
Save hrywlms/5fca1ab19670363a2d43 to your computer and use it in GitHub Desktop.
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