标题: 语音识别实践(识别说话者、孤立词、语种)Matlab实现 [打印本页]

作者: Kxuan163    时间: 2023-10-7 22:41
标题: 语音识别实践(识别说话者、孤立词、语种)Matlab实现
主程序:Recognize.m
% 每次读入1个待识别的mp3语音文件,提取mfcc特征系数,
% 用dtw算法计算与参考模板作匹配,
% 可识别出:说话者、所说的水果名称,所说的语种。
clear ;close ; clc;

load ref_coef_1.mat;
load ref_coef_2.mat;
load ref_coef_3.mat;
load ref_coef_4.mat;
load ref_coef_5.mat;
load data.mat;
N =8;
fprintf('  \n' );

% 读入待测试语音:
while  1
i = input('请选择待测试语音文件的编号 1~40: (输入0 则退出) ') ;
if i == 0
   return;
end   
while (i<1 | i>40 )
  i = input('请选择待测试语音文件的编号 1~40: ') ;
end
f_in = ['.\test_voice\' num2str(i) '.mp3'];
[x,fs]=audioread(f_in);
x = x -mean(x);      
x = x/max(abs(x));   
x = cut(x);
sound(x,fs);

% 提取待测试语音的特征参数:
test.feature = mfcc(x,fs) ;  

% 匹配 -----------------
for j = 1: N
   dist(1,j) = dtw(test.feature, ref_1(j).feature);
end
for j = 1: N
   dist(2,j) = dtw(test.feature, ref_2(j).feature);
end
for j = 1: N
   dist(3,j) = dtw(test.feature, ref_3(j).feature);
end
for j = 1: N
   dist(4,j) = dtw(test.feature, ref_4(j).feature);
end
for j = 1: N
   dist(5,j) = dtw(test.feature, ref_5(j).feature);
end  
[x y]=find(dist==min(min(dist)));
switch (x)
  case 1
    trainer  = '晓辰 '; language = '国语';
  case 2
    trainer  = '晓晓 '; language = '国语';  
  case 3
    trainer  = '云皓 '; language = '国语';  
  case 4
    trainer  = '晓佳 '; language = '粤语';   
  case 5
    trainer  = '云龙 '; language = '粤语';
end   
fprintf('所说水果名称是:%s\n', char(fruit(y)));
fprintf('说话者是:%s', trainer);
fprintf(',语言是%s\n',language);
fprintf('  \n' );
end

%--------------------------------------
运行截图:



其它函数及语音数据在压缩包中:
fruit_recognize.zip (395.99 KB, 下载次数: 26)



作者: 阿飞7812    时间: 2023-10-8 08:59
这是个啥,用在那里的,或者说是用在那类片子里的
作者: Kxuan163    时间: 2023-10-8 13:14
阿飞7812 发表于 2023-10-8 08:59
这是个啥,用在那里的,或者说是用在那类片子里的

顶楼的内容是在电脑运行的语音识别仿真(类似单片机用Proteus仿真)。
若将matlab程序编译为C语言程序,可在stm32或别的种类单片机中运行。
或者,参考matlab程序数据结构和算法自行编写单片机程序,用于语音控制。
例如,用stm32单片机以语音控制小车:前进、后退、左转、右转...另外,亦可用于开门的特定人声纹识别。

作者: 量子工业    时间: 2023-10-8 13:26
做电钢琴,据说取样来自几百万的钢琴声
作者: clyf    时间: 2023-12-10 11:56
老师发布了很多干货,我们需要学习的地方太多了




欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1