[PYTHON] Try using scipy

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

spec.png

Recommended Posts

Try using scipy
Try using Tkinter
Try using docker-py
Try using cookiecutter
Try using PDFMiner
Try using geopandas
Try using Selenium
Try using pandas.DataFrame
Try using django-swiftbrowser
Try using matplotlib
Try using tf.metrics
Try using PyODE
Try using virtualenv (virtualenvwrapper)
[Azure] Try using Azure Functions
Try using virtualenv now
Try using W & B
Try using Django templates.html
[Kaggle] Try using LGBM
Try using Python's feedparser.
Try using Python's Tkinter
Try using Tweepy [Python2.7]
Try using Pytorch's collate_fn
[Python] Try using Tkinter's canvas
Try using Jupyter's Docker image
Try using scikit-learn (1) --K-means clustering
Try function optimization using Hyperopt
Try using matplotlib with PyCharm
Try using Azure Logic Apps
Try using Kubernetes Client -Python-
[Kaggle] Try using xg boost
Try using OpenCV on Windows
Try using Jupyter Notebook dynamically
Try using AWS SageMaker Studio
Try tweeting automatically using Selenium.
Try using SQLAlchemy + MySQL (Part 1)
Try using the Twitter API
Try using SQLAlchemy + MySQL (Part 2)
Try using Django's template feature
Try using the PeeringDB 2.0 API
Try using Pelican's draft feature
Try using pytest-Overview and Samples-
Try using folium with anaconda
Try using Janus gateway's Admin API
[Statistics] [R] Try using quantile regression.
Harmonic mean with Python Harmonic mean (using SciPy)
Try using Spyder included in Anaconda
Try using Pillow on iPython (Part 1)
Try using Pleasant's API (python / FastAPI)
Try using PyCharm's remote debugging feature
Try using ArUco on Raspberry Pi
Try using cheap LiDAR (Camsense X1)
[Sakura rental server] Try using flask.
Try using Pillow on iPython (Part 3)
Reinforcement learning 8 Try using Chainer UI
Try to get statistics using e-Stat
Try using Python argparse's action API
Try using the Python Cmd module
Try using Python's networkx with AtCoder
Try using Leap Motion in Python
Try using GCP Handwriting Recognition (OCR)
Try using Amazon DynamoDB from Python