% 讀入待測(cè)試語(yǔ)音:
while 1
i = input('請(qǐng)選擇待測(cè)試語(yǔ)音文件的編號(hào) 1~40: (輸入0 則退出) ') ;
if i == 0
return;
end
while (i<1 | i>40 )
i = input('請(qǐng)選擇待測(cè)試語(yǔ)音文件的編號(hào) 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);
% 匹配 -----------------
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 = '國(guó)語(yǔ)';
case 2
trainer = '曉曉 '; language = '國(guó)語(yǔ)';
case 3
trainer = '云皓 '; language = '國(guó)語(yǔ)';
case 4
trainer = '曉佳 '; language = '粵語(yǔ)';
case 5
trainer = '云龍 '; language = '粵語(yǔ)';
end
fprintf('所說(shuō)水果名稱是:%s\n', char(fruit(y)));
fprintf('說(shuō)話者是:%s', trainer);
fprintf(',語(yǔ)言是%s\n',language);
fprintf(' \n' );
end