tdtw1.m
资源名称:speech.rar [点击查看]
上传用户:ay_070428
上传日期:2014-12-04
资源大小:11427k
文件大小:1k
源码类别:
语音合成与识别
开发平台:
Matlab
- % Compare the difference between dtwmex1 and dtwmex1n
- fprintf('This test script compares the difference between dtwmex1.dll (DTW minimizing the total distance) and dtwmex1n.dll (DTW minimizing the average distancee).n');
- file1 = 'singer1.wav';
- file2 = 'singer2.wav';
- y1 = wavread(file1);
- y2 = wavread(file2);
- mfcc1 = wave2mfccmex(y1);
- mfcc2 = wave2mfccmex(y2);
- frameNum1 = size(mfcc1, 2);
- frameNum2 = size(mfcc2, 2);
- figure
- % Vertical yellow grid line
- for i = 1:frameNum1,
- line([i, i], [1, frameNum2], 'color', 'y');
- end
- % Horizontal yellow grid line
- for j = 1:frameNum2,
- line([1, frameNum1], [j, j], 'color', 'y');
- end
- % ====== Solution obtained by DTW
- [minDist, DTWpath] = dtwmex1(mfcc1, mfcc2);
- fprintf('dtwmex1(): distance = %g, path length = %gn', minDist, size(DTWpath,2));
- for i = 1:size(DTWpath,2)-1,
- line([DTWpath(1,i), DTWpath(1,i+1)], [DTWpath(2,i), DTWpath(2,i+1)], ...
- 'color', 'r', 'marker', '.');
- end
- [minDist, DTWpath] = dtwmex1n(mfcc1, mfcc2);
- fprintf('dtwmex1n(): distance = %g, path length = %gn', minDist, size(DTWpath,2));
- for i = 1:size(DTWpath,2)-1,
- line([DTWpath(1,i), DTWpath(1,i+1)], [DTWpath(2,i), DTWpath(2,i+1)], ...
- 'color', 'g', 'marker', '.');
- end
- title('DTW paths (red: min. total distance, green: min. average distance');
- xlabel(file1);
- ylabel(file2);
- axis image
- box on