Home > asr > grammarGen4ks.m

grammarGen4ks

PURPOSE ^

grammarGen4ks: Generate grammar and net files for keyword spotting with FSD as the filler model

SYNOPSIS ^

function grammarGen4ks(sylFile, dicFile, grammarFile);

DESCRIPTION ^

 grammarGen4ks: Generate grammar and net files for keyword spotting with FSD as the filler model
    sylFile: the file containing syllables of keywords
    dicFile: pronunciation dictionary
    grammarFile: output grammar file (You can use this grammar file to generate net file using hparse.exe in HTK.)

    For example:
        sylFile='tangPoem.hanyu.syl';
        dicFile='hanyu.dic';        % FSD (free syllable decoding) for filler
        grammarFile='tangPoem.hanyu.grammar';
        grammarGen4ks(sylFile, dicFile, grammarFile);

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function grammarGen4ks(sylFile, dicFile, grammarFile);
0002 % grammarGen4ks: Generate grammar and net files for keyword spotting with FSD as the filler model
0003 %    sylFile: the file containing syllables of keywords
0004 %    dicFile: pronunciation dictionary
0005 %    grammarFile: output grammar file (You can use this grammar file to generate net file using hparse.exe in HTK.)
0006 %
0007 %    For example:
0008 %        sylFile='tangPoem.hanyu.syl';
0009 %        dicFile='hanyu.dic';        % FSD (free syllable decoding) for filler
0010 %        grammarFile='tangPoem.hanyu.grammar';
0011 %        grammarGen4ks(sylFile, dicFile, grammarFile);
0012 
0013 sylList=sylRead(sylFile);    % Read syl file
0014 dict=dictRead(dicFile);        % Read dict file
0015 
0016 % Construct FSD-based filler
0017 fid=fopen(grammarFile, 'w');
0018 fprintf(fid, '$filter=%s', dict(1).word);
0019 for i=2:length(dict)
0020     fprintf(fid, '|%s', dict(i).word);
0021 end
0022 fprintf(fid, ';\n');
0023 % Construct keywords
0024 fprintf(fid, '$keyword=%s', sylList(1).sentenceSyl);
0025 for i=2:length(sylList)
0026     fprintf(fid, '|%s', sylList(i).sentenceSyl);
0027 end
0028 fprintf(fid, ';\n');
0029 
0030 fprintf(fid, '({$filter} $keyword {$filter})');
0031 fclose(fid);
0032 fprintf('Saved %s\n', grammarFile);

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