我发现这个语音识别code,我从blog下载。它工作正常,它要求记录声音以创建数据集,然后您必须调用函数来使用神经网络来训练系统。如何在MATLAB中使声音信号长度相同?
我想使用此代码来训练使用我想要识别的20个单词的数据集。
问题: 我有一个包含800个文件的20个单词的数据集,即每个单词来自不同人的40个记录。我用Windows录音机收集文件。 问题是,在代码中,输入文件的大小总是设置为8000,另一方面我的数据集不是常量,有些文件是2秒长,有些是3,这意味着会有不同每个文件中的样本数量。
如果每个输入信号的采样变化,它可能会产生错误。 我想用我的文件来训练系统。 我该怎么做?
代码:
clc;clear all;
load('voicetrainfinal.mat');
Fs=8000;
for l=1:20
clear y1 y2 y3;
display('record voice');
pause();
x=wavrecord(Fs,Fs); % wavrecord(n,Fs) records n samples at a sampling rate of Fs
maxval = max(x);
if maxval<0.04
display('Threshold value is too large!');
end
t=0.04;
j=1;
for i=1:8000
if(abs(x(i))>t)
y1(j)=x(i);
j=j+1;
end
end
y2=y1/(max(abs(y1)));
y3=[y2,zeros(1,3120-length(y2))];
y=filter([1 -0.9],1,y3');%high pass filter to boost the high frequency components
%%frame blocking
blocklen=240;%30ms block
overlap=80;
block(1,:)=y(1:240);
for i=1:18
block(i+1,:)=y(i*160:(i*160+blocklen-1));
end
w=hamming(blocklen);
for i=1:19
a=xcorr((block(i,:).*w'),12);%finding auto correlation from lag -12 to 12
for j=1:12
auto(j,:)=fliplr(a(j+1:j+12));%forming autocorrelation matrix from lag 0 to 11
end
z=fliplr(a(1:12));%forming a column matrix of autocorrelations for lags 1 to 12
alpha=pinv(auto)*z';
lpc(:,i)=alpha;
end
wavplay(x,Fs);
X1=reshape(lpc,1,228);
a1=sigmoid(Theta1*[1;X1']);
h=sigmoid(Theta2*[1;a1]);
m=max(h);
p1=find(h==m);
if(p1==10)
P=0
else
P=p1
end
end
[如何训练并为神经网络制作序列化特征向量?](http://stackoverflow.com/questions/19419098/how-to-train-on-and-make-a-serialized-feature -vector-for-a-neural-network) –