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

yipeiwu_com5年前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实现的读写json文件功能示例

本文实例讲述了Python实现的读写json文件功能。分享给大家供大家参考,具体如下: 相比java,python对json文件的处理就简单很多。java操作json文件的话需要引用ja...

python实现聊天小程序

python实现聊天小程序

本文实例为大家分享了python实现聊天小程序的具体代码,供大家参考,具体内容如下 我这里实现的是客户端与服务端进行通信的功能,比较简单,与上一篇文章的群聊不太一样。 服务端server...

使用Python读取大文件的方法

背景 最近处理文本文档时(文件约2GB大小),出现memoryError错误和文件读取太慢的问题,后来找到了两种比较快Large File Reading 的方法,本文将介绍这两种读取方...

Python3 log10()函数简单用法

描述 log10() 方法返回以10为基数的x对数,x>0。 语法 以下是 log10() 方法的语法: import math math.log10( x ) 注意...

python 调用钉钉机器人的方法

以text格式的消息为例:(只需修改content后的内容) Import json Import requests url='https://oapi.dingtalk.com...