20-4 Use ASRA within ASR Toolbox

In fact, we have integrate the functionality of SA into a MATLAB function waveAssess.m in the ASR toolbox. Please try the following example:

Example 1: waveAssess01.mwaveFile='what_would_you_like_to_know.wav'; text='what would you like to know'; language='english'; plotOpt=1; [cmObj, dosCmd]=waveAssess(waveFile, text, language, plotOpt) [Warning: The P-code file xml_parse.p was generated prior to MATLAB version 7.5 (R2007b) and will not be supported in a future release. Use <a href="matlab:doc pcode">pcode</a> to regenerate xml_parse.p using MATLAB R2007b or later.] [> In <a href="matlab:matlab.internal.language.introspective.errorDocCallback('asraOutputXmlRead', 'd:\users\jang\matlab\toolbox\asr\asraOutputXmlRead.m', 9)" style="font-weight:bold">asraOutputXmlRead</a> (<a href="matlab: opentoline('d:\users\jang\matlab\toolbox\asr\asraOutputXmlRead.m',9,0)">line 9</a>) In <a href="matlab:matlab.internal.language.introspective.errorDocCallback('asraCore', 'd:\users\jang\matlab\toolbox\asr\asraCore.m', 102)" style="font-weight:bold">asraCore</a> (<a href="matlab: opentoline('d:\users\jang\matlab\toolbox\asr\asraCore.m',102,0)">line 102</a>) In <a href="matlab:matlab.internal.language.introspective.errorDocCallback('waveAssess', 'd:\users\jang\matlab\toolbox\asr\waveAssess.m', 68)" style="font-weight:bold">waveAssess</a> (<a href="matlab: opentoline('d:\users\jang\matlab\toolbox\asr\waveAssess.m',68,0)">line 68</a>) In <a href="matlab:matlab.internal.language.introspective.errorDocCallback('waveAssess01', 'D:\users\jang\books\audioSignalProcessing\example\waveAssess01.m', 5)" style="font-weight:bold">waveAssess01</a> (<a href="matlab: opentoline('D:\users\jang\books\audioSignalProcessing\example\waveAssess01.m',5,0)">line 5</a>) In <a href="matlab:matlab.internal.language.introspective.errorDocCallback('goWriteOutputFile>dummyFunction', 'D:\users\jang\books\goWriteOutputFile.m', 85)" style="font-weight:bold">goWriteOutputFile>dummyFunction</a> (<a href="matlab: opentoline('D:\users\jang\books\goWriteOutputFile.m',85,0)">line 85</a>) In <a href="matlab:matlab.internal.language.introspective.errorDocCallback('goWriteOutputFile', 'D:\users\jang\books\goWriteOutputFile.m', 55)" style="font-weight:bold">goWriteOutputFile</a> (<a href="matlab: opentoline('D:\users\jang\books\goWriteOutputFile.m',55,0)">line 55</a>)] [Warning: The P-code file unblank.p was generated prior to MATLAB version 7.5 (R2007b) and will not be supported in a future release. Use <a href="matlab:doc pcode">pcode</a> to regenerate unblank.p using MATLAB R2007b or later.] [> In xml_parse (line 155) In <a href="matlab:matlab.internal.language.introspective.errorDocCallback('asraOutputXmlRead', 'd:\users\jang\matlab\toolbox\asr\asraOutputXmlRead.m', 9)" style="font-weight:bold">asraOutputXmlRead</a> (<a href="matlab: opentoline('d:\users\jang\matlab\toolbox\asr\asraOutputXmlRead.m',9,0)">line 9</a>) In <a href="matlab:matlab.internal.language.introspective.errorDocCallback('asraCore', 'd:\users\jang\matlab\toolbox\asr\asraCore.m', 102)" style="font-weight:bold">asraCore</a> (<a href="matlab: opentoline('d:\users\jang\matlab\toolbox\asr\asraCore.m',102,0)">line 102</a>) In <a href="matlab:matlab.internal.language.introspective.errorDocCallback('waveAssess', 'd:\users\jang\matlab\toolbox\asr\waveAssess.m', 68)" style="font-weight:bold">waveAssess</a> (<a href="matlab: opentoline('d:\users\jang\matlab\toolbox\asr\waveAssess.m',68,0)">line 68</a>) In <a href="matlab:matlab.internal.language.introspective.errorDocCallback('waveAssess01', 'D:\users\jang\books\audioSignalProcessing\example\waveAssess01.m', 5)" style="font-weight:bold">waveAssess01</a> (<a href="matlab: opentoline('D:\users\jang\books\audioSignalProcessing\example\waveAssess01.m',5,0)">line 5</a>) In <a href="matlab:matlab.internal.language.introspective.errorDocCallback('goWriteOutputFile>dummyFunction', 'D:\users\jang\books\goWriteOutputFile.m', 85)" style="font-weight:bold">goWriteOutputFile>dummyFunction</a> (<a href="matlab: opentoline('D:\users\jang\books\goWriteOutputFile.m',85,0)">line 85</a>) In <a href="matlab:matlab.internal.language.introspective.errorDocCallback('goWriteOutputFile', 'D:\users\jang\books\goWriteOutputFile.m', 55)" style="font-weight:bold">goWriteOutputFile</a> (<a href="matlab: opentoline('D:\users\jang\books\goWriteOutputFile.m',55,0)">line 55</a>)] [Warning: The P-code file xml_toolbox_version.p was generated prior to MATLAB version 7.5 (R2007b) and will not be supported in a future release. Use <a href="matlab:doc pcode">pcode</a> to regenerate xml_toolbox_version.p using MATLAB R2007b or later.] [> In xml_parse (line 202) In <a href="matlab:matlab.internal.language.introspective.errorDocCallback('asraOutputXmlRead', 'd:\users\jang\matlab\toolbox\asr\asraOutputXmlRead.m', 9)" style="font-weight:bold">asraOutputXmlRead</a> (<a href="matlab: opentoline('d:\users\jang\matlab\toolbox\asr\asraOutputXmlRead.m',9,0)">line 9</a>) In <a href="matlab:matlab.internal.language.introspective.errorDocCallback('asraCore', 'd:\users\jang\matlab\toolbox\asr\asraCore.m', 102)" style="font-weight:bold">asraCore</a> (<a href="matlab: opentoline('d:\users\jang\matlab\toolbox\asr\asraCore.m',102,0)">line 102</a>) In <a href="matlab:matlab.internal.language.introspective.errorDocCallback('waveAssess', 'd:\users\jang\matlab\toolbox\asr\waveAssess.m', 68)" style="font-weight:bold">waveAssess</a> (<a href="matlab: opentoline('d:\users\jang\matlab\toolbox\asr\waveAssess.m',68,0)">line 68</a>) In <a href="matlab:matlab.internal.language.introspective.errorDocCallback('waveAssess01', 'D:\users\jang\books\audioSignalProcessing\example\waveAssess01.m', 5)" style="font-weight:bold">waveAssess01</a> (<a href="matlab: opentoline('D:\users\jang\books\audioSignalProcessing\example\waveAssess01.m',5,0)">line 5</a>) In <a href="matlab:matlab.internal.language.introspective.errorDocCallback('goWriteOutputFile>dummyFunction', 'D:\users\jang\books\goWriteOutputFile.m', 85)" style="font-weight:bold">goWriteOutputFile>dummyFunction</a> (<a href="matlab: opentoline('D:\users\jang\books\goWriteOutputFile.m',85,0)">line 85</a>) In <a href="matlab:matlab.internal.language.introspective.errorDocCallback('goWriteOutputFile', 'D:\users\jang\books\goWriteOutputFile.m', 55)" style="font-weight:bold">goWriteOutputFile</a> (<a href="matlab: opentoline('D:\users\jang\books\goWriteOutputFile.m',55,0)">line 55</a>)] [Warning: The EraseMode property is no longer supported and will error in a future release. Use the ANIMATEDLINE function for animating lines and points instead of EraseMode 'none'. Removing instances of EraseMode set to 'normal', 'xor', and 'background' has minimal impact.] [> In <a href="matlab:matlab.internal.language.introspective.errorDocCallback('waveCmPlot', 'd:\users\jang\matlab\toolbox\asr\waveCmPlot.m', 44)" style="font-weight:bold">waveCmPlot</a> (<a href="matlab: opentoline('d:\users\jang\matlab\toolbox\asr\waveCmPlot.m',44,0)">line 44</a>) In <a href="matlab:matlab.internal.language.introspective.errorDocCallback('asraCore', 'd:\users\jang\matlab\toolbox\asr\asraCore.m', 135)" style="font-weight:bold">asraCore</a> (<a href="matlab: opentoline('d:\users\jang\matlab\toolbox\asr\asraCore.m',135,0)">line 135</a>) In <a href="matlab:matlab.internal.language.introspective.errorDocCallback('waveAssess', 'd:\users\jang\matlab\toolbox\asr\waveAssess.m', 68)" style="font-weight:bold">waveAssess</a> (<a href="matlab: opentoline('d:\users\jang\matlab\toolbox\asr\waveAssess.m',68,0)">line 68</a>) In <a href="matlab:matlab.internal.language.introspective.errorDocCallback('waveAssess01', 'D:\users\jang\books\audioSignalProcessing\example\waveAssess01.m', 5)" style="font-weight:bold">waveAssess01</a> (<a href="matlab: opentoline('D:\users\jang\books\audioSignalProcessing\example\waveAssess01.m',5,0)">line 5</a>) In <a href="matlab:matlab.internal.language.introspective.errorDocCallback('goWriteOutputFile>dummyFunction', 'D:\users\jang\books\goWriteOutputFile.m', 85)" style="font-weight:bold">goWriteOutputFile>dummyFunction</a> (<a href="matlab: opentoline('D:\users\jang\books\goWriteOutputFile.m',85,0)">line 85</a>) In <a href="matlab:matlab.internal.language.introspective.errorDocCallback('goWriteOutputFile', 'D:\users\jang\books\goWriteOutputFile.m', 55)" style="font-weight:bold">goWriteOutputFile</a> (<a href="matlab: opentoline('D:\users\jang\books\goWriteOutputFile.m',55,0)">line 55</a>)] cmObj = version: 'version 1.4 (2010/06/24)' text: {'what would you like to know'} syl: {} warningMessage: {} cm: [1x1 struct] dosCmd = "assess.exe" "d:\users\jang\matlab\toolbox\asr\exe/english.sa.prm" "d:\users\jang\matlab\toolbox\sap\what_would_you_like_to_know.wav" "C:\Users\ROGERJ~1\AppData\Local\Temp\tpca251e0c_adc1_46f6_a62c_fe824ed4f92f.txt" 0 "output" "" "" "" 0

In the above example, waveAssess.m does invoke ASRA to do speech assessment, and then read the output file output.xml to get the word/phoneme boundaries and scores to draw the plot. To be specific,

Hint
You can click and drag on the plot within MATLAB to play the segmented utterance.

If you need to get the pitch of the utterance, try the following example:

Example 2: waveAssess02.mwaveFile='what_would_you_like_to_know.wav'; text='what would you like to know'; language='english'; plotOpt=1; pitchFile='test.pitch'; [cmObj, dosCmd]=waveAssess(waveFile, text, language, plotOpt, pitchFile); [Warning: The EraseMode property is no longer supported and will error in a future release. Use the ANIMATEDLINE function for animating lines and points instead of EraseMode 'none'. Removing instances of EraseMode set to 'normal', 'xor', and 'background' has minimal impact.] [> In <a href="matlab:matlab.internal.language.introspective.errorDocCallback('waveCmPlot', 'd:\users\jang\matlab\toolbox\asr\waveCmPlot.m', 44)" style="font-weight:bold">waveCmPlot</a> (<a href="matlab: opentoline('d:\users\jang\matlab\toolbox\asr\waveCmPlot.m',44,0)">line 44</a>) In <a href="matlab:matlab.internal.language.introspective.errorDocCallback('waveCmPitchPlot', 'd:\users\jang\matlab\toolbox\asr\waveCmPitchPlot.m', 14)" style="font-weight:bold">waveCmPitchPlot</a> (<a href="matlab: opentoline('d:\users\jang\matlab\toolbox\asr\waveCmPitchPlot.m',14,0)">line 14</a>) In <a href="matlab:matlab.internal.language.introspective.errorDocCallback('asraCore', 'd:\users\jang\matlab\toolbox\asr\asraCore.m', 138)" style="font-weight:bold">asraCore</a> (<a href="matlab: opentoline('d:\users\jang\matlab\toolbox\asr\asraCore.m',138,0)">line 138</a>) In <a href="matlab:matlab.internal.language.introspective.errorDocCallback('waveAssess', 'd:\users\jang\matlab\toolbox\asr\waveAssess.m', 68)" style="font-weight:bold">waveAssess</a> (<a href="matlab: opentoline('d:\users\jang\matlab\toolbox\asr\waveAssess.m',68,0)">line 68</a>) In <a href="matlab:matlab.internal.language.introspective.errorDocCallback('waveAssess02', 'D:\users\jang\books\audioSignalProcessing\example\waveAssess02.m', 6)" style="font-weight:bold">waveAssess02</a> (<a href="matlab: opentoline('D:\users\jang\books\audioSignalProcessing\example\waveAssess02.m',6,0)">line 6</a>) In <a href="matlab:matlab.internal.language.introspective.errorDocCallback('goWriteOutputFile>dummyFunction', 'D:\users\jang\books\goWriteOutputFile.m', 85)" style="font-weight:bold">goWriteOutputFile>dummyFunction</a> (<a href="matlab: opentoline('D:\users\jang\books\goWriteOutputFile.m',85,0)">line 85</a>) In <a href="matlab:matlab.internal.language.introspective.errorDocCallback('goWriteOutputFile', 'D:\users\jang\books\goWriteOutputFile.m', 55)" style="font-weight:bold">goWriteOutputFile</a> (<a href="matlab: opentoline('D:\users\jang\books\goWriteOutputFile.m',55,0)">line 55</a>)]

For spoken Chinese assessment, try this one:

Example 3: waveAssess03.mwaveFile='yi_cuen_xiang_s_yi_cuen_huei.wav'; text='一寸想思一寸灰'; language='chinese'; plotOpt=1; pitchFile='test.pitch'; [cmObj, dosCmd]=waveAssess(waveFile, text, language, plotOpt, pitchFile);[Warning: The EraseMode property is no longer supported and will error in a future release. Use the ANIMATEDLINE function for animating lines and points instead of EraseMode 'none'. Removing instances of EraseMode set to 'normal', 'xor', and 'background' has minimal impact.] [> In <a href="matlab:matlab.internal.language.introspective.errorDocCallback('waveCmPlot', 'd:\users\jang\matlab\toolbox\asr\waveCmPlot.m', 44)" style="font-weight:bold">waveCmPlot</a> (<a href="matlab: opentoline('d:\users\jang\matlab\toolbox\asr\waveCmPlot.m',44,0)">line 44</a>) In <a href="matlab:matlab.internal.language.introspective.errorDocCallback('waveCmPitchPlot', 'd:\users\jang\matlab\toolbox\asr\waveCmPitchPlot.m', 14)" style="font-weight:bold">waveCmPitchPlot</a> (<a href="matlab: opentoline('d:\users\jang\matlab\toolbox\asr\waveCmPitchPlot.m',14,0)">line 14</a>) In <a href="matlab:matlab.internal.language.introspective.errorDocCallback('asraCore', 'd:\users\jang\matlab\toolbox\asr\asraCore.m', 138)" style="font-weight:bold">asraCore</a> (<a href="matlab: opentoline('d:\users\jang\matlab\toolbox\asr\asraCore.m',138,0)">line 138</a>) In <a href="matlab:matlab.internal.language.introspective.errorDocCallback('waveAssess', 'd:\users\jang\matlab\toolbox\asr\waveAssess.m', 68)" style="font-weight:bold">waveAssess</a> (<a href="matlab: opentoline('d:\users\jang\matlab\toolbox\asr\waveAssess.m',68,0)">line 68</a>) In <a href="matlab:matlab.internal.language.introspective.errorDocCallback('waveAssess03', 'D:\users\jang\books\audioSignalProcessing\example\waveAssess03.m', 6)" style="font-weight:bold">waveAssess03</a> (<a href="matlab: opentoline('D:\users\jang\books\audioSignalProcessing\example\waveAssess03.m',6,0)">line 6</a>) In <a href="matlab:matlab.internal.language.introspective.errorDocCallback('goWriteOutputFile>dummyFunction', 'D:\users\jang\books\goWriteOutputFile.m', 85)" style="font-weight:bold">goWriteOutputFile>dummyFunction</a> (<a href="matlab: opentoline('D:\users\jang\books\goWriteOutputFile.m',85,0)">line 85</a>) In <a href="matlab:matlab.internal.language.introspective.errorDocCallback('goWriteOutputFile', 'D:\users\jang\books\goWriteOutputFile.m', 55)" style="font-weight:bold">goWriteOutputFile</a> (<a href="matlab: opentoline('D:\users\jang\books\goWriteOutputFile.m',55,0)">line 55</a>)]

For spoken Japanese assessment, try this one:

Example 4: waveAssess04.mwaveFile='ka_ko_no_o_mo_i_de_o_hu_ri_ka_e_tte_mi_ru.wav'; waveFile=[asrtRoot, '/testInput/ka_ko_no_o_mo_i_de_o_hu_ri_ka_e_tte_mi_ru.wav']; text='X'; % This is "don't care" since we don't know how to display Japanese characters plotOpt=1; rp=asraPrmSet('japanese', 'sa'); asrRoot=fileparts(which('waveAssess')); rp.sylFile=[asrRoot, '\japanese0001.syl']; % This is required since we don't have character-to-pinyin conversion for Japanese pitchFile='test.pitch'; [cmObj, dosCmd, time]=waveAssess(waveFile, text, rp, plotOpt, pitchFile);dosCmd="assess.exe" "d:\users\jang\matlab\toolbox\asr\exe/japanese.sa.prm" "d:\users\jang\matlab\toolbox\asr/testInput/ka_ko_no_o_mo_i_de_o_hu_ri_ka_e_tte_mi_ru.wav" "C:\Users\ROGERJ~1\AppData\Local\Temp\tp5610324e_0cad_4808_b769_4f7eac27b85e.txt" 0 "output" "d:\users\jang\matlab\toolbox\asr\japanese0001.syl" "" "" 1 exeStatus=0 exeResult=0.002 sec: Read wave file "d:\users\jang\matlab\toolbox\asr/testInput/ka_ko_no_o_mo_i_de_o_hu_ri_ka_e_tte_mi_ru.wav" 0.003 sec: Read "asraData/japanese/japanese.macb" (modelNum=120) and "" Warning of model substitution: g+u w+a is replaced by g+a Warning of model substitution: w+u is replaced by w+a 0.000 sec: Read pam "asraData/japanese/japanese.dic" (m_pronDict.size()=279) 0.001 sec: Read text normalization mapping file "asraData/japanese/japanese.tnm" (myText.m_textNormSp.size()=0) 0.000 sec: Read text "C:\Users\ROGERJ~1\AppData\Local\Temp\tp5610324e_0cad_4808_b769_4f7eac27b85e.txt" (m_txtVs.size()=1) 0.000 sec: text normalization (m_txtVsNormalized.size()=1) ===> Saved output/output.nt Saved error log at C:\Users\ROGERJ~1\AppData\Local\Temp/error_20150408_082142.log... Cannot open file d:\users\jang\matlab\toolbox\asr\japanese0001.syl (line 100 of \users\jang\c\lib\utility\utility.cpp) Something went wrong! You can copy the dosCmd and run it under DOS window within {asrToolbox}\exe directory to see the results for debugging.

Moreover, you can use the following scripts for demonstration: Try them, it's fun!
Audio Signal Processing and Recognition (音訊處理與辨識)