1. 程式人生 > >語音識別(4)-- 提取頻域特徵

語音識別(4)-- 提取頻域特徵

提取頻域特徵

# -*- coding:utf-8 -*-
'''
  提取頻域特徵 --使用梅爾頻率倒譜系數
'''
import numpy as np
import matplotlib.pyplot as plt
from scipy.io import wavfile
from python_speech_features import mfcc,logfbank

# 讀取輸入音訊檔案
sampling_freq,audio=wavfile.read('input_freq.wav')
# 提取mfcc和過濾器特徵
mfcc_features=mfcc(audio,sampling_freq)
filter_features=logfbank(audio,sampling_freq)
# 列印引數
print '\nMFCC :\n Number of window =',mfcc_features.shape[0] print '每個特徵的長度為: ',mfcc_features.shape[1] print '\n Filter bank: \n Number of window =',filter_features.shape[0] print '每個特徵的長度為: ',filter_features.shape[1] # 畫出特徵圖 mfcc_features=mfcc_features.T plt.matshow(mfcc_features) plt.title('MFCC') filterbank_features=filter_features.T plt.matshow(filter_features) plt.title('Filter bank'
) plt.show()

MFCC效果圖如下:

這裡寫圖片描述

濾波器特徵影象如下:

這裡寫圖片描述

輸出結果如下:

MFCC :
 Number of window = 40
每個特徵的長度為:  13

 Filter bank: 
 Number of window = 40
每個特徵的長度為:  26