test.m
上传用户:jzquartz
上传日期:2008-06-09
资源大小:389k
文件大小:1k
- function test(testdir, n, code)
- % Speaker Recognition: Testing Stage
- %
- % Input:
- % testdir : string name of directory contains all test sound files
- % n : number of test files in testdir
- % code : codebooks of all trained speakers
- %
- % Note:
- % Sound files in testdir is supposed to be:
- % s1.wav, s2.wav, ..., sn.wav
- %
- % Example:
- % >> test('C:dataamintest', 8, code);
- %%%%%%%%%%%%%%%%%%
- %
- % Author: Amin Koohi(Sohrevardi)
- % AminSohrevardi@yahoo.com , AminKoohi@yahoo.com
- %*******************
- for k = 1:n % read test sound file of each speaker
- file = sprintf('%ss%d.wav', testdir, k);
- [s, fs] = wavread(file);
-
- v = mfcc(s, fs); % Compute MFCC's
-
- distmin = inf;
- k1 = 0;
-
- for l = 1:length(code) % each trained codebook, compute distortion
- d = disteu(v, code{l});
- dist = sum(min(d,[],2)) / size(d,1);
-
- if dist < distmin
- distmin = dist;
- k1 = l;
- end
- end
-
- msg = sprintf('Speaker %d matches with speaker %d', k, k1);
- disp(msg);
- end