5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

scipyとか使ってみる

Posted at

octaveからscipy/numpy/matplotlibに移行する事にした.

octaveも別に悪くはないんだけど,GUIとの連携が弱すぎた…

とりあえず,このサイトを参考にしてスペクトログラムを表示してみた.

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()

spec.png

5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?