我正在尝试使用python进行声音分析来对机器进行故障检测。
import scipy.io.wavfile as wav
import numpy as np
import speechpy
import os
import pandas as pd
import matplotlib.pyplot as plt
os.chdir('D:\Python\Sound Data')
file_name = 'good8Hz.wav'
Checking_file = 'fault8Hz.wav'
fs, signal = wav.read(file_name)
signal = signal[:,0]
#this is my testing data
fs1, signal1 = wav.read(Checking_file)
signal1 = signal1[:,0]
# pre-emphasizing.
signal_preemphasized = speechpy.processing.preemphasis(signal, cof=0.98)
#pre-emphasizing of testing data .
signal_preemphasized1 = speechpy.processing.preemphasis(signal1, cof=0.98)
#staching frames
frames = speechpy.processing.stack_frames(signal, sampling_frequency=fs,
frame_length=0.020, frame_stride=0.01, filter=lambda x: np.ones((x,)),
zero_padding=True)
# staching frames of testing data .
frames1 = speechpy.processing.stack_frames(signal1, sampling_frequency=fs,
frame_length=0.020, frame_stride=0.01, filter=lambda x: np.ones((x,)),
zero_padding=True)
#extracting power spectrum
power_spectrum = speechpy.processing.power_spectrum(frames, fft_points=512)
print('power spectrum shape=', power_spectrum.shape)
#extracting power spectrum for testing data .
power_spectrum1 = speechpy.processing.power_spectrum(frames1,
fft_points=512)
print('power spectrum shape=', power_spectrum1.shape)
############# Extract MFCC features #############
mfcc = speechpy.feature.mfcc(signal, sampling_frequency=fs,
frame_length=0.020, frame_stride=0.01,
num_filters=40, fft_length=512, low_frequency=0,
high_frequency=None)
mfcc_cmvn =
speechpy.processing.cmvnw(mfcc,win_size=301,variance_normalization=True)
print('mfcc(mean + variance normalized) feature shape=', mfcc_cmvn.shape)
mfcc_feature_cube = speechpy.feature.extract_derivative_feature(mfcc)
print('mfcc feature cube shape=', mfcc_feature_cube.shape)
df=pd.DataFrame(mfcc)
df.to_csv('mfcc.csv')
############# Extract MFCC features for testing data . #############
mfcc1 = speechpy.feature.mfcc(signal1, sampling_frequency=fs,
frame_length=0.020, frame_stride=0.01,
num_filters=40, fft_length=512, low_frequency=0,
high_frequency=None)
mfcc_cmvn1 =
speechpy.processing.cmvnw(mfcc1,win_size=301,variance_normalization=True)
print('mfcc(mean + variance normalized) feature shape=', mfcc_cmvn.shape)
mfcc_feature_cube1 = speechpy.feature.extract_derivative_feature(mfcc1)
print('mfcc feature cube shape=', mfcc_feature_cube1.shape)
df1=pd.DataFrame(mfcc1)
df1.to_csv('mfcc1.csv')
############# Extract logenergy features #############
logenergy = speechpy.feature.lmfe(signal, sampling_frequency=fs,
frame_length=0.020, frame_stride=0.01,
num_filters=40, fft_length=512, low_frequency=0,
high_frequency=None)
logenergy_feature_cube =
speechpy.feature.extract_derivative_feature(logenergy)
print('logenergy features=', logenergy.shape)
如何使用mfcc数据训练我的模型我正在考虑使用SVM或ANN。
mfcc.shape =(1118,13)是好的机器mfcc功能,而mfcc1.shape =(1278,13)] [screenshot of data]这是故障机器的mffc。我还需要使用什么来进行机器故障检测?