Home > asr > pa2phone.m

pa2phone

PURPOSE ^

pa2pa: PA (phonetic alphabet) to phone (model) conversion, mainly for Hanyu Pinyin

SYNOPSIS ^

function out=pa2phone(in, pamList)

DESCRIPTION ^

pa2pa: PA (phonetic alphabet) to phone (model) conversion, mainly for Hanyu Pinyin
    Usage: out=pa2phone(in, pamList)

    For example:
        pa2pa('guo')
        pa2pa({'qing', 'hua', 'da', 'xue'})

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function out=pa2phone(in, pamList)
0002 %pa2pa: PA (phonetic alphabet) to phone (model) conversion, mainly for Hanyu Pinyin
0003 %    Usage: out=pa2phone(in, pamList)
0004 %
0005 %    For example:
0006 %        pa2pa('guo')
0007 %        pa2pa({'qing', 'hua', 'da', 'xue'})
0008 
0009 %    Roger Jang, 20081026
0010 
0011 if nargin<1, selfdemo; return; end
0012 if nargin<2
0013     [hanyu, monophone]=textread('hanyu.monophone.pam', '%s\t%s');
0014     count=length(hanyu);
0015     [pamList(1:count).hanyu] = deal(hanyu{:});
0016     [pamList(1:count).monophone] = deal(monophone{:});
0017 end
0018 
0019 if isstr(in)
0020     index=find(strcmp(in, {pamList.hanyu}));
0021     if length(index)==1
0022         out=pamList(index).monophone;
0023         return
0024     end
0025     error(sprintf('Cannot find %s in the dictionary!\n', in));
0026 end
0027 if iscell(in)
0028     for i=1:length(in)
0029         out{i}=pa2phone(in{i}, pamList);
0030     end
0031 end
0032 
0033 % ====== Selfdemo
0034 function selfdemo
0035 input='guo';
0036 output=pa2phone(input);
0037 fprintf('input=%s, output=%s\n', input, output);
0038 input={'qing', 'hua', 'da', 'xue'};
0039 output=pa2phone(input);
0040 fprintf('input=%s, output=%s\n', cell2str(input), cell2str(output));

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