getdist.m
上传用户:ay_070428
上传日期:2014-12-04
资源大小:11427k
文件大小:1k
源码类别:

语音合成与识别

开发平台:

Matlab

  1. load waveData.mat
  2. allSpeakers = {waveData.speaker};
  3. index1 = findcell(allSpeakers, '1Roger');
  4. index2 = findcell(allSpeakers, '1Gavins');
  5. index3 = findcell(allSpeakers, '1Gao');
  6. index4 = findcell(allSpeakers, '1Jtchen');
  7. index = [index1, index2, index3, index4];
  8. waveData = waveData(index);
  9. % ====== Compute distance matrix based on original features
  10. waveNum = length(waveData);
  11. distmat = zeros(waveNum);
  12. for i=1:waveNum;
  13. fprintf('i = %dn', i);
  14. for j=(i+1):waveNum;
  15. featureI = waveData(i).feature;
  16. featureJ = waveData(j).feature;
  17. distmat(i,j) = dtwmex0(featureI, featureJ, 2, 1);
  18. end
  19. end
  20. distmat = distmat+distmat';
  21. save dist0 distmat
  22. % ====== Feature transformation
  23. feature = cat(2, waveData.feature);
  24. mu = mean(feature, 2);
  25. sigma = sqrt(diag(cov(feature')));
  26. feature = (feature-mu*ones(1, size(feature,2)))./(sigma*ones(1,size(feature,2)));
  27. % ====== Compute distance matrix based on normalized features
  28. waveNum = length(waveData);
  29. distmat = zeros(waveNum);
  30. for i=1:waveNum;
  31. fprintf('i = %dn', i);
  32. for j=(i+1):waveNum;
  33. featureI = waveData(i).feature;
  34. dataNumI = size(featureI, 2);
  35. featureI = (featureI-mu*ones(1, dataNumI))./(sigma*ones(1,dataNumI));
  36. featureJ = waveData(j).feature;
  37. dataNumJ = size(featureJ, 2);
  38. featureJ = (featureJ-mu*ones(1, dataNumJ))./(sigma*ones(1,dataNumJ));
  39. distmat(i,j) = dtwmex0(featureI, featureJ, 2, 1);
  40. end
  41. end
  42. distmat = distmat+distmat';
  43. save dist1 distmat