specgram python
生活随笔
收集整理的這篇文章主要介紹了
specgram python
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
# -*- coding: utf-8 -*
import numpy as np
import scipy as sp
import wave
import struct
import matplotlib.pylab as pl
#********************參數設置********************%
winsize=512;?????????????? #%%幀長設置為512
shift=256;???????????????? #??? %%幀移設置為256
fh=600;??????????????????? #??? %%設定最高基音頻率
fl=60;???????????????????? #??? %%設定最低基音頻率
# 讀取語音
filename = 'test.wav'
wavefile = wave.open(filename, 'r') # open for writing
#讀取wav文件的四種信息的函數
nchannels = wavefile.getnchannels()
sample_width = wavefile.getsampwidth()
framerate = wavefile.getframerate()
numframes = wavefile.getnframes()
print 'nchannels: ' + str(nchannels)
print 'sample_width: ' +? str(sample_width)
print 'framerate: ' +? str(framerate)
print 'numframes: ' +? str(numframes)
# get wav_data
wav_data = wavefile.readframes(-1)
wav_data = np.fromstring(wav_data, 'Int16')
Time=np.linspace(0, len(wav_data)/framerate, num=len(wav_data))
pl.figure(1)
pl.title('Signal Wave...')
pl.plot(Time,wav_data)
pl.show()
#framerate就是16000, specgram!
Fs = framerate
pl.figure(2)
pl.specgram(wav_data, NFFT=1024, Fs=Fs, noverlap=512)
pl.show()
與50位技術專家面對面20年技術見證,附贈技術全景圖
import numpy as np
import scipy as sp
import wave
import struct
import matplotlib.pylab as pl
#********************參數設置********************%
winsize=512;?????????????? #%%幀長設置為512
shift=256;???????????????? #??? %%幀移設置為256
fh=600;??????????????????? #??? %%設定最高基音頻率
fl=60;???????????????????? #??? %%設定最低基音頻率
# 讀取語音
filename = 'test.wav'
wavefile = wave.open(filename, 'r') # open for writing
#讀取wav文件的四種信息的函數
nchannels = wavefile.getnchannels()
sample_width = wavefile.getsampwidth()
framerate = wavefile.getframerate()
numframes = wavefile.getnframes()
print 'nchannels: ' + str(nchannels)
print 'sample_width: ' +? str(sample_width)
print 'framerate: ' +? str(framerate)
print 'numframes: ' +? str(numframes)
# get wav_data
wav_data = wavefile.readframes(-1)
wav_data = np.fromstring(wav_data, 'Int16')
Time=np.linspace(0, len(wav_data)/framerate, num=len(wav_data))
pl.figure(1)
pl.title('Signal Wave...')
pl.plot(Time,wav_data)
pl.show()
#framerate就是16000, specgram!
Fs = framerate
pl.figure(2)
pl.specgram(wav_data, NFFT=1024, Fs=Fs, noverlap=512)
pl.show()
與50位技術專家面對面20年技術見證,附贈技術全景圖
總結
以上是生活随笔為你收集整理的specgram python的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux查看正在运行的窗口,获取lin
- 下一篇: springboot2稳定版本_重要版本