Home > asr > lab2pitchedIndex.m

lab2pitchedIndex

PURPOSE ^

lab2pitchedIndex: Get pitched index from lab and qiYinFile

SYNOPSIS ^

function pitchedIndex=lab2pitchedIndex(labFile, qiYinFile)

DESCRIPTION ^

 lab2pitchedIndex: Get pitched index from lab and qiYinFile
    Usage: pitchedIndex=pitchedIndex=lab2pitchedIndex(labFile, qiYinFile)
        labFile: 由辨識程式所產生的 lab 檔案
        qiYinFile: 氣音列表,可以是 qiYinChinese.txt 或 qiYinEnglish.txt

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function pitchedIndex=lab2pitchedIndex(labFile, qiYinFile)
0002 % lab2pitchedIndex: Get pitched index from lab and qiYinFile
0003 %    Usage: pitchedIndex=pitchedIndex=lab2pitchedIndex(labFile, qiYinFile)
0004 %        labFile: 由辨識程式所產生的 lab 檔案
0005 %        qiYinFile: 氣音列表,可以是 qiYinChinese.txt 或 qiYinEnglish.txt
0006 
0007 %    Roger Jang, 20060210
0008 
0009 if nargin<1, selfdemo; return; end
0010 if nargin<2
0011     [parentDir, junk, junk, junk]=fileparts(which(mfilename));
0012     qiYinFile='d:\users\jang\matlab\toolbox\asr\exe\dict\hanyu.qiYin';
0013 end
0014 
0015 word = labRead(labFile);
0016 qiYin = textread(qiYinFile,'%s','delimiter','\n','whitespace','');
0017 pitchedIndex=[];
0018 for i=1:length(word)
0019     wordName=word(i).name;
0020     for j=1:length(word(i).phone)
0021         startIndex=word(i).phone(j).time(1)/100000+1;
0022         endIndex=word(i).phone(j).time(2)/100000;
0023         phoneName=word(i).phone(j).name;
0024         plusIndex=findstr(phoneName, '+');
0025         monoPhoneName=phoneName;
0026         if length(plusIndex)==1
0027             monoPhoneName=phoneName(1:plusIndex-1);
0028         end
0029     %    index=findCellStr(qiYin, monoPhoneName);
0030         index=find(strcmp(qiYin, monoPhoneName));
0031         if isempty(index)
0032             pitchedIndex=[pitchedIndex, startIndex:endIndex];
0033         end
0034 %        fprintf('word(%d)=%s, phone(%d)=%s, monoPhoneName=%s, voiced=%d, index=%s\n', i, wordName, j, phoneName, monoPhoneName, isempty(index), mat2str(startIndex:endIndex));
0035     end
0036 end
0037 
0038 % ====== Self demo
0039 function selfdemo
0040 labFile='但使龍城飛將在.lab';
0041 qiYinFile='d:\users\jang\matlab\toolbox\asr\exe\dict\hanyu.qiYin';
0042 pitchedIndex=feval(mfilename, labFile, qiYinFile)

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