Home > asr > cmWordBgPlot.m

cmWordBgPlot

PURPOSE ^

cmWordBgPlot: Plot background yellow patches for words obtained from a given CM (confidence measure) file

SYNOPSIS ^

function word=cmWordBgPlot(cmObj, minY, maxY)

DESCRIPTION ^

 cmWordBgPlot: Plot background yellow patches for words obtained from a given CM (confidence measure) file
    Usage:  cmWordBgPlot(cmObj, minY, maxY)
        This function is primarily used in waveCmPlot.m

        Type cmWordBgPlot for a quick demo.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function word=cmWordBgPlot(cmObj, minY, maxY)
0002 % cmWordBgPlot: Plot background yellow patches for words obtained from a given CM (confidence measure) file
0003 %    Usage:  cmWordBgPlot(cmObj, minY, maxY)
0004 %        This function is primarily used in waveCmPlot.m
0005 %
0006 %        Type cmWordBgPlot for a quick demo.
0007 
0008 %    Roger Jang, 20050103, 20100412
0009 
0010 if nargin<1; selfdemo; return; end
0011 
0012 if isstr(cmObj)    %     "cmObj" is a xml file instead
0013     deleteSil=0;
0014     output=asraOutputXmlRead(cmObj);
0015     cmObj=output.confidenceMeasure;
0016 end
0017 
0018 word=cmObj.word;
0019 cla;
0020 for i=1:length(word);
0021     % Print each word
0022     time=word(i).interval;
0023     if length(word(i).phone(1).name)>=4
0024         if strcmp(word(i).phone(1).name(1:4), 'sil+') & length(word(i).phone)>1        % 處理 taihua.dic 的 leading sil+*
0025             time(1)=word(i).phone(2).interval(1);
0026         end
0027     end
0028     xPos=mean(time); yPos=maxY;
0029     temp=strrep(word(i).name, '_', '\_');        % 將 '_' 代換成 '\_',以免誤被顯示成下標
0030     word(i).textH=text(xPos, yPos, {[word(i).text, '(', temp, ')'], int2str(word(i).timberScore)}, 'horizontal', 'center');
0031     set(word(i).textH, 'horizontal', 'center', 'vertical', 'bottom');
0032     % Print background patches
0033     if strcmp(word(i).name, 'sil')|strcmp(word(i).name, 'sp')
0034         color='w';
0035     else
0036         color=getColorLight(i);
0037     end
0038     word(i).patchH=patch(time([1 2 2 1]), [minY minY maxY maxY], color);
0039     set(word(i).patchH, 'edgeColor', 'k');
0040     % Print each word
0041     phoneNum=length(word(i).phone);
0042     for j=1:phoneNum
0043         % Print phoneme boundaries
0044         time=word(i).phone(j).interval;
0045         line(time(1)*[1 1], [minY maxY], 'color', 'k');
0046         line(time(2)*[1 1], [minY maxY], 'color', 'k');
0047         % Print each phoneme
0048         xPos=mean(time); yPos=minY;
0049         phoneName=word(i).phone(j).name;
0050         phoneScore=word(i).phone(j).timberScore;
0051         plusPos=findstr(phoneName, '+');    % Take the first out of a bi-phone, such as uw+t
0052         phoneName=phoneName(1:plusPos-1);
0053         word(i).phone(j).textH=text(xPos, yPos, {phoneName, int2str(phoneScore)}, 'horizontal', 'center');
0054         set(word(i).phone(j).textH, 'horizontal', 'center', 'vertical', 'bottom');
0055     end
0056 end
0057 temp=[cmObj.discountFactor];
0058 discountFactor=[temp.occurrence];
0059 ylabel({sprintf('Score=%.2f\n', cmObj.score), sprintf('df=%s', mat2str(discountFactor))});
0060 
0061 % ====== Self demo
0062 function selfdemo
0063 wavFile='what_would_you_like_to_know.wav';
0064 xmlFile='what_would_you_like_to_know.xml';;
0065 feval(mfilename, xmlFile, -1, 1);
0066 [y, fs, nbits]=wavread(wavFile);
0067 time=(1:length(y))/fs;
0068 waveH=line(time, y);
0069 axis([min(time), max(time), -1, 1]); 
0070 box on

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