Home > asr > goDemoVc.m

goDemoVc

PURPOSE ^

Demo of ASR of ASRA (automatic speech recognition & assessment)

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

 Demo of ASR of ASRA (automatic speech recognition & assessment)
 Roger Jang, 20091014

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % Demo of ASR of ASRA (automatic speech recognition & assessment)
0002 % Roger Jang, 20091014
0003 
0004 clear all; warning off
0005 addMyPath;
0006 
0007 % ====== Parameters
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 % ====== Display recognizable texts
0020 asrRoot=fileparts(which('waveAssess'));
0021 switch(language)    % File path is based on "exe" folder
0022     case 'chinese'
0023         txtFile=[asrRoot, '\testInput\tangPoem0208.txt'];
0024         sylFile='';
0025         netFile='';
0026         wpaFile='';
0027 
0028     %    txtFile=[asrRoot, '\testInput\songTitle.txt'];
0029     %    sylFile=[asrRoot, '\testInput\songTitle.syl'];
0030     %    netFile=[asrRoot, '\testInput\songTitle.netb'];
0031     %    wpaFile='';
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 %dos(sprintf('start %s', txtFile));
0046 open(txtFile);
0047 % ====== Loop the test
0048 while 1
0049     % ====== Recording
0050     if recordViaMatlab
0051         % ====== Recording using MATLAB
0052         wavrecord(0.1*fs, fs, 'uint8');        % Initialize wavrecord
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         % ====== Recording using MIR C program
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     % ====== Recognition
0075     cmd=sprintf('recog chinese.vc.prm "%s" "%s" 0 output "%s" "%s" "%s" 0', waveFile, txtFile, sylFile, netFile, wpaFile);
0076 %    fprintf('cmd=%s\n', cmd);
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     % ====== Show result
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

Generated on Tue 01-Jun-2010 09:50:19 by m2html © 2003