0001
0002
0003
0004 clear all; warning off
0005 addMyPath;
0006
0007
0008 language=input('Please select language (english, chinese, japanese): ', 's');
0009 if isempty(language), language='chinese'; end
0010 if ~any(strcmp(language, {'english', 'chinese', 'japanese'}))
0011 error(sprintf('Unknown language "%s"!', language));
0012 end
0013 duration=3;
0014 fs=16000;
0015 nbits=16;
0016 recordViaMatlab=1;
0017 warning off
0018
0019
0020 asrRoot=fileparts(which('waveAssess'));
0021 switch(language)
0022 case 'chinese'
0023 txtFile=[asrRoot, '\testInput\tangPoem0208.txt'];
0024 sylFile='';
0025 netFile='';
0026 wpaFile='';
0027
0028
0029
0030
0031
0032 case 'english'
0033 txtFile=[asrRoot, '\testInput\english0200.txt'];
0034 sylFile=[asrRoot, '\testInput\english0200.syl'];
0035 netFile=[asrRoot, '\testInput\english0200.net'];
0036 wpaFile=[asrRoot, '\testInput\english0200.wpa'];
0037 case 'japanese'
0038 txtFile=[asrRoot, '\testInput\japanese0100.txt'];
0039 sylFile=[asrRoot, '\testInput\japanese0100.syl'];
0040 netFile='';
0041 wpaFile='';
0042 otherwise
0043 error('Unknown language!');
0044 end
0045
0046 open(txtFile);
0047
0048 while 1
0049
0050 if recordViaMatlab
0051
0052 wavrecord(0.1*fs, fs, 'uint8');
0053 fprintf('Press any key to start %d-second recording: ', duration);
0054 pause;
0055 fprintf('Recording...');
0056 y=wavrecord(fs*duration,fs,1);
0057 y=y-mean(y);
0058 waveFile=[tempname, '.wav'];
0059 wavwrite(y, fs, nbits, waveFile);
0060 fprintf('Finish recording (%s).\n\tOutput: ', waveFile);
0061 sound(y, fs);
0062 plot((1:length(y))/fs, y); axis([-inf inf -1 1]);
0063 else
0064
0065 fprintf('Press any key to start %d-second recording:', duration);
0066 [status, result]=dos('recording01.exe recording.prm');
0067 if status
0068 disp(result);
0069 fprintf('Something went wrong during recording!\n');
0070 end
0071 waveFile='test.wav';
0072 fprintf('Finish recording (%s).\n\tRecognition result ===> ', waveFile);
0073 end
0074
0075 cmd=sprintf('recog chinese.vc.prm "%s" "%s" 0 output "%s" "%s" "%s" 0', waveFile, txtFile, sylFile, netFile, wpaFile);
0076
0077 currDir=pwd; cd([asrRoot, '\exe']); [status, result]=dos(cmd); cd(currDir);
0078 if status
0079 disp(result);
0080 fprintf('cmd=%s\n', cmd);
0081 error('Something went wrong during recognition!');
0082 end
0083
0084 xmlFile=[asrRoot, '\exe\output\output.xml'];
0085 output=asraOutputXmlRead(xmlFile);
0086 fprintf('%s\n\n', output.text{1});
0087 cm=output.confidenceMeasure;
0088 waveCmPlot(waveFile, cm);
0089 end