[Emotion Recognition] Speech Emotion Recognition Based on Neural Network [With Matlab source code 544]

1. Introduction

BP network (Back Propagation), proposed by a team of scientists led by Rumelhart and McCelland in 1986, is a multi-layer feedforward network trained by error back propagation algorithm, and is currently one of the most widely used neural network models. The BP network can learn and store a large number of input-output pattern mapping relationships without revealing the mathematical equations describing this mapping relationship in advance.
In the history of the development of artificial neural networks, an effective algorithm for adjusting the connection weight of the hidden layer has not been found for a long time. Until the error back propagation algorithm (BP algorithm) was proposed, the problem of weight adjustment of multilayer feedforward neural networks for solving nonlinear continuous functions was successfully solved.

BP (Back Propagation) neural network, the learning process of error back propagation algorithm, consists of two processes: forward propagation of information and back propagation of error. Each neuron in the input layer is responsible for receiving input information from the outside and transmitting it to each neuron in the middle layer; the middle layer is the internal information processing layer and is responsible for information transformation. According to the demand for information change ability, the middle layer can be designed as a single hidden layer or Multi-hidden layer structure; the last hidden layer transmits the information of each neuron in the output layer, after further processing, completes a forward propagation process of learning, and the output layer outputs the information processing result to the outside world. When the actual output does not match the expected output, the error back propagation phase is entered. The error passes through the output layer, corrects the weights of each layer in the way of error gradient descent, and transmits it back to the hidden layer and the input layer layer by layer. The repeated process of forward propagation of information and back propagation of errors is a process of constant adjustment of the weights of each layer, as well as a process of neural network learning and training. This process continues until the error of the network output is reduced to an acceptable level, or preset Up to the set number of studies.

BP neural network model BP network model includes its input and output model, action function model, error calculation model and self-learning model.
Insert picture description here
Insert picture description here
2 BP neural network model and its basic principles
Insert picture description here
3 BP_PID algorithm flow
Insert picture description here

Second, the source code

lc 
close all
clear all
load A_fear fearVec;
load F_happiness hapVec;
load N_neutral neutralVec;
load T_sadness sadnessVec;
load W_anger angerVec;
 trainsample(1:30,1:140)=angerVec(:,1:30)';
 trainsample(31:60,1:140)=hapVec(:,1:30)';
 trainsample(61:90,1:140)=neutralVec(:,1:30)';
 trainsample(91:120,1:140)=sadnessVec(:,1:30)';
 trainsample(121:150,1:140)=fearVec(:,1:30)';
  trainsample(1:30,141)=1;
   trainsample(31:60,141)=2;
   trainsample(61:90,141)=3;
   trainsample(91:120,141)=4; 
   trainsample(121:150,141)=5;
   testsample(1:20,1:140)=angerVec(:,31:50)';
  testsample(21:40,1:140)=hapVec(:,31:50)';
 testsample(41:60,1:140)=neutralVec(:,31:50)';
  testsample(61:80,1:140)=sadnessVec(:,31:50)';
  testsample(81:100,1:140)=fearVec(:,31:50)';
  testsample(1:20,141)=1;
   testsample(21:40,141)=2;
    testsample(41:60,141)=3;
    testsample(61:80,141)=4; 
    testsample(81:100,141)=5;
  class=trainsample(:,141);
sum=bpnn(trainsample,testsample,class);
figure(1)
bar(sum,0.5);
set(gca,'XTickLabel',{
    
    '生气','高兴','中性','悲伤','害怕'});
ylabel('识别率');
xlabel('五种基本情感');

p_train=trainsample(:,1:140)';
t_train=trainsample(:,141)';
p_test=testsample(:,1:140)';
t_test=testsample(:,141)';
sumpnn=pnn(p_train,t_train,p_test,t_test);
figure(2)
bar(sumpnn,0.5);
set(gca,'XTickLabel',{
    
    '生气','高兴','中性','悲伤','害怕'});
ylabel('识别率');
xlabel('五种基本情感');
sumlvq=lvq(trainsample,testsample,class);
function sum=bpnn(trainsample,testsample,class)
%输入参数:trainsample是训练样本,testsample是测试样本,class表示训练样本的类别,与trainsample中数据对应
%sum:五种基本情感的识别率
for i=1:140
    feature(:,i)= trainsample(:,i);
end
%特征值归一化
[input,minI,maxI] = premnmx( feature')  ;

%构造输出矩阵
s = length( class ) ;
output = zeros( s , 5  ) ;
for i = 1 : s 
   output( i , class( i )  ) = 1 ;
end

%创建神经网络
net = newff( minmax(input) , [10 5] , {
    
     'logsig' 'purelin' } , 'traingdx' ) ;   %创建前馈神经网络

%设置训练参数
net.trainparam.show = 50 ;
net.trainparam.epochs = 150 ;
net.trainparam.goal = 0.1 ;
net.trainParam.lr = 0.05 ;

%开始训练
net = train( net, input , output' ) ;

%读取测试数据
for i=1:140
    featuretest(:,i)= testsample(:,i);
end
 c=testsample(:,141);
%测试数据归一化
testInput = tramnmx(featuretest' , minI, maxI ) ;

%仿真
Y = sim( net , testInput ) 
sum=[0 0 0 0 0]; %每类情感正确识别个数
%统计识别正确样本数 
for i=1:20
    if Y(1,i)>Y(2,i)&&Y(1,i)>Y(3,i)&&Y(1,i)>Y(4,i)&&Y(1,i)>Y(5,i)
        sum(1)=sum(1)+1;
    end
    function sumlvq=lvq(trainsample,testsample,class)
P=trainsample(:,1:140)';
C=class';
T=ind2vec(C);
net=newlvq(minmax(P),20,[0.2 0.2 0.2 0.2 0.2],0.1); %创建lvq网络
w1=net.IW{
    
    1};
net.trainParam.epochs=100;
net=train(net,P,T);
y=sim(net,testsample(:,1:140)');
y3c=vec2ind(y);
sumlvq=[0 0 0 0 0]; %每类情感正确识别个数
%统计识别正确样本数 
for i=1:20
    if y3c(i)==1
        sumlvq(1)=sumlvq(1)+1;
    end
end
for i=21:40
    if y3c(i)==2
        sumlvq(2)=sumlvq(2)+1;
    end
end
for i=41:60
    if y3c(i)==3
        sumlvq(3)=sumlvq(3)+1;
    end
end
for i=61:80
    if y3c(i)==4
        sumlvq(4)=sumlvq(4)+1;
    end
end
for i=81:100
end

Three, running results

Insert picture description here
Insert picture description here

Four, remarks

Complete code or writing add QQ 1564658423 past review
>>>>>>
[Feature extraction] Audio watermark embedding and extraction based on matlab wavelet transform [Include Matlab source code 053]
[Speech processing] Voice signal processing based on matlab GUI [Include Matlab Source code issue 290]
[Voice acquisition] based on matlab GUI voice signal collection [including Matlab source code 291]
[Voice modulation] based on matlab GUI voice amplitude modulation [including Matlab source code 292]
[Speech synthesis] based on matlab GUI voice synthesis [including Matlab Source code issue 293]
[Voice encryption] Voice signal encryption and decryption based on matlab GUI [With Matlab source code 295]
[Speech enhancement] Matlab wavelet transform-based voice enhancement [Matlab source code 296]
[Voice recognition] Based on matlab GUI voice base frequency Recognition [Including Matlab source code 294]
[Speech enhancement] Matlab GUI Wiener filtering based voice enhancement [Including Matlab source code 298]
[Speech processing] Based on matlab GUI voice signal processing [Including Matlab source code 299]
[Signal processing] Based on Matlab speech signal spectrum analyzer [including Matlab source code 325]
[Modulation signal] Digital modulation signal simulation based on matlab GUI [including Matlab source code 336]
[Emotion recognition] Voice emotion recognition based on matlab BP neural network [including Matlab source code 349 Issue]
[Voice Steganography] Quantified Audio Digital Watermarking Based on Matlab Wavelet Transform [Include Matlab Source Code Issue 351]
[Feature extraction] based on matlab audio watermark embedding and extraction [including Matlab source code 350 period]
[speech denoising] based on matlab low pass and adaptive filter denoising [including Matlab source code 352 period]
[emotion recognition] based on matlab GUI voice emotion classification Recognition [Including Matlab source code 354 period]
[Basic processing] Matlab-based speech signal preprocessing [Including Matlab source code 364 period]
[Speech recognition] Matlab Fourier transform 0-9 digital speech recognition [Including Matlab source code 384 period]
[Speech Recognition] 0-9 digital speech recognition based on matlab GUI DTW [including Matlab source code 385]
[Voice playback] Matlab GUI MP3 design [including Matlab source code 425]
[Voice processing] Speech enhancement algorithm based on human ear masking effect Noise ratio calculation [Including Matlab source code 428]
[Speech denoising] Based on matlab spectral subtraction denoising [Including Matlab source code 429]
[Speech recognition] BP neural network speech recognition based on the momentum item of matlab [Including Matlab source code 430]
[Voice steganography] based on matlab LSB voice hiding [including Matlab source code 431]
[Voice recognition] based on matlab male and female voice recognition [including Matlab source code 452]
[Voice processing] based on matlab voice noise adding and noise reduction processing [including Matlab source code Issue 473]
[Speech denoising] based on matlab least squares (LMS) adaptive filter [including Matlab source code 481]
[Speech enhancement] based on matlab spectral subtraction, least mean square and Wiener filter speech enhancement [including Matlab source code 482 period】
[Communication] based on matlab GUI digital frequency band (ASK, PSK, QAM) modulation simulation [including Matlab source code 483]
[Signal processing] based on matlab ECG signal processing [including Matlab source code 484]
[Voice broadcast] based on matlab voice Broadcast [Including Matlab source code 507]
[Signal processing] Matlab wavelet transform based on EEG signal feature extraction [Including Matlab source code 511]
[Voice processing] Based on matlab GUI dual tone multi-frequency (DTMF) signal detection [Including Matlab source code 512 】
【Voice steganography】based on matlab LSB to realize the digital watermark of speech signal 【Include Matlab source code 513】
【Speech enhancement】Speech recognition based on matlab matched filter 【Include Matlab source code 514】
【Speech processing】Based on matlab GUI voice Frequency domain spectrogram analysis [including Matlab source code 527]
[Speech denoising] based on matlab LMS, RLS algorithm voice denoising [including Matlab source code 528]
[Voice denoising] based on matlab LMS spectral subtraction voice denoising [including Matlab Source code issue 529]
[Voice denoising] based on matlab soft threshold, hard threshold, compromise threshold voice denoising [including Matlab source code 530]
[Voice recognition] based on matlab specific person's voice recognition discrimination [including Matlab source code 534]
[ Speech denoising] based on matlab wavelet soft threshold speech noise reduction [including Matlab source code 531]
[speech denoising] based on matlab wavelet hard threshold speech noise reduction [including Matlab source code 532]
[speech recognition] based on matlab MFCC and SVM specific Human gender recognition [including Matlab source code 533]
[Voice recognition] GMM speech recognition based on MFCC [including Matlab source code 535]
[Voice recognition] based on matlab VQ specific person isolated words voice recognition [including Matlab source code 536]
[Voice recognition] based on matlab GUI voiceprint recognition [including Matlab] Source code issue 537]
[Acquisition and reading] based on matlab voice collection and reading [including Matlab source code 538]
[Voice editing] based on matlab voice editing [including Matlab source code 539]
[Voice model] based on matlab voice signal mathematical model [including Matlab source code 540]
[Speech soundness] based on matlab voice intensity and loudness [including Matlab source code 541]
[Emotion recognition] based on matlab K nearest neighbor classification algorithm voice emotion recognition [including Matlab source code 542]
[Emotion recognition] based on matlab Support vector machine (SVM) speech emotion recognition [including Matlab source code 543]

Guess you like

Origin blog.csdn.net/TIQCmatlab/article/details/114954783