✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。
🍎个人主页:Matlab科研工作室
🍊个人信条:格物致知。
更多Matlab仿真内容点击👇
⛄ 内容介绍
语音信号包含了人类丰富的情感信息,本文从离散情感模型出发,选择了高兴,悲伤,愤怒和害怕4种基本情感作为研究对象,利用萤火虫算法实现了支持向量机参数自动寻优,从而提高了识别的效率.为了使测试数据更据代表性,选取了中文和德文数两种据库,400个样本进行训练和测试.实验表明,对SVM分类器进行优化在一定程度上提高了情感识别率.
⛄ 部分代码
clc,clear all
npersons=6;%6种表情
global edit2
global numberoftrain
numberoftrain=25;
load trainfeature.mat
load testfeature.mat
trainfeature=trainfeature(:,1:8100);
testfeature=testfeature(:,1:8100);
gamma=0.01;%gamma=0.0078;
c=10;%c=128;
% scaledface=[trainfeature(1:25,:);trainfeature(101:125,:);trainfeature(201:225,:);trainfeature(301:325,:);trainfeature(401:425,:);trainfeature(501:525,:);];
t=50;
scaledface=trainfeature;
scaledface=[trainfeature(1+t:25+t,:);trainfeature(101+t:125+t,:);trainfeature(201+t:225+t,:);trainfeature(301+t:325+t,:);trainfeature(401+t:425+t,:);trainfeature(501+t:525+t,:);];
multiSVMstruct=multiSVMtrain( scaledface,npersons,gamma,c);
%save('recognize.mat','multiSVMstruct','npersons');%
%save('recognize.mat','multiSVMstruct','npersons','k','mA','V','lowvec','upvec');
save('recognize.mat','multiSVMstruct','npersons');
realclass=[ones(1,numberoftrain)';2*ones(1,numberoftrain)';3*ones(1,numberoftrain)';4*ones(1,numberoftrain)';5*ones(1,numberoftrain)';6*ones(1,numberoftrain)'];
scaledtestface=testfeature;
scaledtestface=[trainfeature(1+t:25+t,:);trainfeature(101+t:125+t,:);trainfeature(201+t:225+t,:);trainfeature(301+t:325+t,:);trainfeature(401+t:425+t,:);trainfeature(501+t:525+t,:);];
%scaledtestface=[testfeature(1+t:25+t,:);testfeature(101+t:125+t,:);testfeature(201+t:225+t,:);testfeature(301+t:325+t,:);testfeature(401+t:425+t,:);testfeature(501+t:525+t,:);];
class= multiSVM(scaledtestface,multiSVMstruct,npersons);
set(edit2,'string','测试完成!')
accuracy=sum(class==realclass)/length(class);
msgbox(['识别准确率:',num2str(accuracy*100),'%。'])
⛄ 运行结果
⛄ 参考文献
[1]常梦容, 王海瑞, 肖杨,等. 基于改进萤火虫算法优化SVM的滚动轴承故障诊断[J]. 化工自动化及仪表, 2021, 48(4):6.
[2]刘明珠, 李晓琴, 陈洪恒. 基于支持向量机的语音情感识别算法研究[J]. 哈尔滨理工大学学报, 2019, 24(4):9.
[3]胡明, 崔冉, 郭健鹏,等. 基于改进型支持向量机的语音信号情感识别研究[J]. 数字技术与应用, 2019, 037(006):P.109-110.