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中实例化class的执行顺序示例详解

前言 本文主要介绍了关于Python实例化class的执行顺序的相关内容,下面话不多说了,来一起看看详细的介绍吧 Python里对类的实例化时有怎样的顺序 一般来说一个类里面有类变量和...

python中学习K-Means和图片压缩

python中学习K-Means和图片压缩

大家在学习python中,经常会使用到K-Means和图片压缩的,我们在此给大家分享一下K-Means和图片压缩的方法和原理,喜欢的朋友收藏一下吧。 通俗的介绍这种压缩方式,就是将原来...

浅析Python pandas模块输出每行中间省略号问题

关于Python数据分析中pandas模块在输出的时候,每行的中间会有省略号出现,和行与行中间的省略号....问题,其他的站点(百度)中的大部分都是瞎写,根本就是复制黏贴以前的版本,你要...

Python把csv数据写入list和字典类型的变量脚本方法

如下所示: #coding=utf8 import csv import logging logging.basicConfig(level=logging.DEBUG,...

初学Python实用技巧两则

本文记录了初学Python常用的两则实用技巧,分享给大家供大家参考之用。具体如下: 1.可变参数 示例代码如下: >>> def powersum(power, *...