Python提取频域特征知识点浅析

yipeiwu_com6年前Python基础

在多数的现代语音识别系统中,人们都会用到频域特征。梅尔频率倒谱系数(MFCC),首先计算信号的功率谱,然后用滤波器和离散余弦变换的变换来提取特征。本文重点介绍如何提取MFCC特征。

首先创建有一个Python文件,并导入库文件:     from scipy.io import wavfile     from python_speech_features import mfcc, logfbank     import matplotlib.pylab as plt1、首先创建有一个Python文件,并导入库文件:     from scipy.io import wavfile     from python_speech_features import mfcc, logfbank     import matplotlib.pylab as plt

读取音频文件:

samplimg_freq, audio = wavfile.read("data/input_freq.wav")

提取MFCC特征和过滤器特征:

     mfcc_features = mfcc(audio, samplimg_freq)

     filterbank_features = logfbank(audio, samplimg_freq)

打印参数,查看可生成多少个窗体:

   print('\nMFCC:\nNumber of windows =', mfcc_features.shape[0])

   print('Length of each feature =', mfcc_features.shape[1])

   print('\nFilter bank:\nNumber of windows=', filterbank_features.shape                                                         [0])

   print('Length of each feature =', filterbank_features.shape[1])

将MFCC特征可视化。转换矩阵,使得时域是水平的:

   mfcc_features = mfcc_features.T

   plt.matshow(mfcc_features)

   plt.title('MFCC')

将滤波器组特征可视化。转化矩阵,使得时域是水平的:

   filterbank_features = filterbank_features.T

   plt.matshow(filterbank_features)

   plt.title('Filter bank')

   

   plt.show()

相关文章

Python读写docx文件的方法

Python读写word文档有现成的库可以处理。我这里采用 python-docx。可以用pip install python-docx安装一下。 这里说一句,ppt和excel也有类似...

linux下python抓屏实现方法

本文实例讲述了linux下python抓屏实现方法。分享给大家供大家参考。具体实现代码如下: #!/usr/bin/python '''by zevolo, 2012.12.20 '...

基于Python实现的扫雷游戏实例代码

本文实例借鉴mvc模式,核心数据为model,维护1个矩阵,0表无雷,1表雷,-1表已经检测过。 本例使用python的tkinter做gui,由于没考虑可用性问题,因此UI比较难看,p...

python中import与from方法总结(推荐)

一、模块&包简介 模块:所谓模块就是一个.py文件,用来存放变量,方法的文件,便于在其他python文件中导入(通过import或from)。 包(package): 包是更大的组织单位...

Python/Django后端使用PIL Image生成头像缩略图

本文实例为大家分享了Python/Django后端使用PIL Image生成头像缩略图的具体代码,供大家参考,具体内容如下 import os from django.views.g...