I decided to move from octave to scipy / numpy / matplotlib.
Octave isn't bad either, but the integration with the GUI was too weak ...
For the time being, [this site](http://kaiseki-web.lhd.nifs.ac.jp/wiki/index.php/Python_%E3%81%AB%E3%82%88%E3%82%8B%E3 % 82% AA% E3% 83% BC% E3% 83% 87% E3% 82% A3% E3% 82% AA% E5% 87% A6% E7% 90% 86 "This site") as a reference spectrogram I tried to display.
spectrogram.py
#!/usr/bin/env python
import sys
import wave
import urllib2
import scipy as sp
import matplotlib.pyplot as plt
if __name__ == "__main__":
if len( sys.argv ) > 1:
wo = wave.open( sys.argv[1], 'rb' )
else:
url = 'http://www.it.ice.uec.ac.jp/SRV-DB/archive/HENSHU00_PF00/HENSHU00_PF00_0951.wav'
wo = wave.openfp( urllib2.urlopen( url ).fp, 'rb' )
chunk = 65536
data = sp.fromstring( wo.readframes( chunk ), sp.int16 )
srate = wo.getframerate()
nFFT = 1024
window = sp.hamming(nFFT)
Pxx, freq, bins, im = plt.specgram(
data,
NFFT=nFFT,
Fs=srate,
noverlap=512,
window=window)
plt.show()
Recommended Posts