0001 function out=pa2phone(in, pamList)
0002
0003
0004
0005
0006
0007
0008
0009
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
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));