Run this script to convert wav files to spectrograms, which are saved as png files. Is able to run on a folder structure with class labels:
root/dog/0001.wav
root/dog/0002.wav
root/cat/0001.wav
root/cat/0002.wav etc.
Or otherwise on single files.
Example use:
For class folder structure
python ./wav2png.py folder --rootdir [rootdir]
For single files
python ./wav2png.py single --filename [filename.wav]
Scaling is done on the STFT output to be compatible with 8-bit png format. The script searches the dataset for the maximum and minimum values, rounds up and down to the nearest integer respectively then scales to [0,255].
Run to convert individual png spectrograms back to wav. Script assumes (and inverts) similar scaling as in wav2png. Griffin-Lim algortihm is initialized with SPSI. SPSI code originally from here.
Example use:
For single png spectrogram
python ./png2wav.py [filename.png]
This script is to transform a linear frequency scaled spectrogram image (like the ones generated by wav2png) to a pseudo constant-Q (CQT) scaled spectrogram. Algorithm is adapted from Matlab code written by Dan Ellis.
Example use:
For linear to cqt
python ./cqtconv.py --rootdir [rootdir] --outdir [outdir] --conversion spec2cqt
For cqt to linear
python ./cqtconv.py --rootdir [rootdir] --outdir [outdir] --conversion cqt2spec