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 反转字符串(reverse)的方法小结

前段时间看到letcode上的元音字母字符串反转的题目,今天来研究一下字符串反转的内容。主要有三种方法: 1.切片法(最简洁的一种) #切片法 def reverse1(): s=...

python读取word 中指定位置的表格及表格数据

python读取word 中指定位置的表格及表格数据

1.Word文档如下: 2.代码 # -*- coding: UTF-8 -*- from docx import Document def readSpecTable(filen...

Scrapy框架使用的基本知识

scrapy是一个基于Twisted的异步处理框架,可扩展性很强。优点此处不再一一赘述。 下面介绍一些概念性知识,帮助大家理解scrapy。 一、数据流向 要想熟练掌握这个框架,一定要明...

Python里隐藏的“禅”

在 python的lib目录里有一个:this.py,它其实是隐藏着一首诗,源码如下:复制代码 代码如下:s = """Gur Mra bs Clguba, ol Gvz Crgref...

python2.7+selenium2实现淘宝滑块自动认证功能

python2.7+selenium2实现淘宝滑块自动认证功能

本文为大家分享了python2.7+selenium2实现淘宝滑块自动认证的具体代码,供大家参考,具体内容如下 1.编译环境 操作系统:win7;语言:python2.7+selen...