plotwave.m
资源名称:speech.rar [点击查看]
上传用户:ay_070428
上传日期:2014-12-04
资源大小:11427k
文件大小:2k
源码类别:
语音合成与识别
开发平台:
Matlab
- function plotwave(wavefile)
- % PLTOWAVE Plot the waveform of an audio signal
- % ====== Parameters
- frameSize = 256;
- overlap = 86;
- minEnergy = 0.0115;
- minEnergy = -30;
- if nargin == 0,
- wavefile = 'usersjangmatlabtoolboxasrwavefile1Gaoきるぱ.wav';
- end
- if ischar(wavefile),
- [y, fs, nbits] = wavreadc(wavefile);
- elseif length(wavefile)==1,
- load waveData.mat
- index = wavefile;
- [y, fs, nbits] = wavreadc(waveData(index).wavepath);
- else
- y = wavefile;
- fs = 8000;
- end
- y = y-mean(y);
- wavplay(y, fs, 'sync');
- % ====== Take frames
- framedY = buffer(y, frameSize, overlap);
- frameNum = size(framedY, 2); % Number of frames
- figure;
- subplot(4,1,1);
- plot((1:length(y))/fs, y);
- ylabel('Amplitude');
- if exist('index'),
- title(['Original wave form of ', waveData(index).answer, ' (by ', ...
- waveData(index).speaker, ')']);
- else
- title(wavefile);
- end
- subplot(4,1,2);
- aveEnergy = mean(framedY.^2);
- aveEnergy = 10*log10(mean(framedY.^2));
- time = (1:frameNum)*(frameSize-overlap)/fs;
- plot(time, aveEnergy);
- line([min(time), max(time)], minEnergy*[1 1], 'color', 'g');
- soundIndex = find(aveEnergy>=minEnergy);
- for i=1:length(soundIndex);
- line(soundIndex(i)*(frameSize-overlap)/fs, minEnergy, ...
- 'marker', 'o', 'color', 'red');
- end
- axis tight
- ylabel('Energy');
- title(['Average energy of each frame (legal frames: ', ...
- int2str(length(soundIndex)), ')']);
- subplot(4,1,3);
- zcr = zcrate(framedY);
- time = (1:frameNum)*(frameSize-overlap)/fs;
- plot(time, zcr);
- axis([-inf inf 0 inf]);
- ylabel('ZCR');
- title('Zero crossing rate');
- % ====== Pre-emphasis
- y2 = filter([1, -0.95], 1, y);
- framedY2 = buffer(y2, frameSize, overlap);
- %wavplay(y2, fs, 'sync');
- subplot(4,1,4);
- plot((1:length(y2))/fs, y2);
- axis tight;
- ylabel('Amplitude');
- title('After pre-emphasis');
- return
- feature = wav2ftr(y);
- fprintf('No. of legal frames = %gn', size(feature, 2));
- figure;
- surf(feature);
- xlabel('Frame counts');
- ylabel('Feature counts');
- axis tight;
- box on;
- rotate3d on