-
-
Save tinpark/ee42c6804ecb23fda638454110aaf6ab to your computer and use it in GitHub Desktop.
A quick way to generate spectrograms for a bunch of audio files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### 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 five arguments, | |
### arg 1 = file type to make spectrograms from, e.g. .wav, | |
### arg 2 = width of the spectrogram | |
### arg 3 = hight of the spectrogram | |
### arg 4 = the dB level of sounds to pick out, ignoring sounds below that threshold | |
### arg 5 = the frequencies to hone in on e.g. 4k will give you a spectrogram that draws sounds up to 2k | |
### usage: bash makeSpectrogram.sh wav 900 600 70 4k, renders a spectrogram 900*600 pixels from every wav file | |
### in your folder focusing on frequenceies below 2k and sounds crossing the 70dB threshold | |
for file in *.$1;do | |
outfile="${file%.*}.png" | |
title_in_pic="${file%.*} $5 all sound above $4dB" | |
sox "$file" -r $5 -n rate spectrogram -t "$title_in_pic" -x $2 -y $3 -z $4 -o "$outfile" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
modded script to include arguments for
file type
width of spectrogram
frequency range
e.g.: bash makeSpectrogram.sh wav 900 4k, renders a spectrogram 1044 pixels wide from every wav file in your folder focusing on frequenceies below 2k