Home > asr > wave2mlfViaHtk.m

wave2mlfViaHtk

PURPOSE ^

wave2mlf: Generate an MLF file from a given wav file and corresponding text (by HTK)

SYNOPSIS ^

function [status, result]=wave2mlf2(waveFile, text, mlfFile, plotOpt)

DESCRIPTION ^

 wave2mlf: Generate an MLF file from a given wav file and corresponding text (by HTK) 
    Usage: [status, result]=wave2mlf(waveFile, text, mlfFile)
        (The current version is for English only!)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function [status, result]=wave2mlf2(waveFile, text, mlfFile, plotOpt)
0002 % wave2mlf: Generate an MLF file from a given wav file and corresponding text (by HTK)
0003 %    Usage: [status, result]=wave2mlf(waveFile, text, mlfFile)
0004 %        (The current version is for English only!)
0005 
0006 %    Roger Jang, 20050614
0007 
0008 if nargin<1, selfdemo; return; end
0009 if nargin<4, plotOpt=0; end
0010 
0011 tempWavFile=[tempname, '.wav'];
0012 wave2wave(waveFile, tempWavFile, 16000, 16);    % 轉換成 16KHz, 16Bits
0013 
0014 % 準備 HTK 要的檔案
0015 tempFile=tempname;
0016 fid=fopen(tempFile, 'w');
0017 tempWavFile=strrep(tempWavFile, '/', '\');
0018 text=strrep(text, ' ', '_');
0019 text=strrep(text, '?', '');
0020 text=strrep(text, '.', '');
0021 text=lower(text);
0022 fprintf(fid, '%s %s\n', tempWavFile, text);
0023 fclose(fid);
0024 
0025 [parentDir, junk, junk, junk]=fileparts(which(mfilename));
0026 alignDir=[parentDir, '\align.eng.obj'];
0027 cmd=[alignDir, '\alignment.bat ', tempFile, ' ', mlfFile];
0028 disp(cmd);
0029 [status, result]=dos(cmd);
0030 
0031 if plotOpt
0032     waveMlfPlot(waveFile, mlfFile);
0033 end
0034 
0035 % ====== selfdemo
0036 function selfdemo
0037 waveFile='what_movies_have_you_seen_recently.wav';
0038 waveFile='how_many_people_do_you_talk_to_every_day.wav';
0039 mlfFile=[waveFile(1:end-3), 'mlf'];
0040 text=waveFile(1:end-4); text=strrep(text, '_', ' ');
0041 plotOpt=1;
0042 feval(mfilename, waveFile, text, mlfFile, plotOpt);

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