u:p:
« prevnext »

N-Best workaround for Nortel MPS

Symptoms

The count_nortel.js javascript is not able to extract the shadow data from the lastresult object on MPS because the grammar-specific slot name is required and consequently any VO expressions with LASTRESULT() functions do not return (correct) data.

Resolution

Return the N-best results as individual variables back to VoiceObjects.

The workaround for this problem is to provide Javascript expressions for the Result Handling variables on the Input object that directly access the MPS lastresult object.

For example, this application has an Input object that asks "Please say the name of the fund you're interested in." and uses a large external Funds Grammar file with many similar sounding Mutual Fund names. The "Input - Max N-best" parameter for this Input object is set to 5.

The result handling for this input object is defined as follows:

Variable: NbestCount Slot: #application.lastresult$.length#
Variable: NbestFund0 Slot: #application.lastresult$[0].interpretation.fundslot#
Variable: NbestFund1 Slot: #application.lastresult$[Math.min(1,lastresult$.length)-1].interpretation.fundslot#
Variable: NbestFund2 Slot: #application.lastresult$[Math.min(2,lastresult$.length)-1].interpretation.fundslot#
Variable: NbestFund3 Slot: #application.lastresult$[Math.min(3,lastresult$.length)-1].interpretation.fundslot#
Variable: NbestFund4 Slot: #application.lastresult$[Math.min(4,lastresult$.length)-1].interpretation.fundslot#
Variable: Confidence Slot: #application.lastresult$.confidence#

Instead of actual grammar slotnames, the result handling is using the special #...# notation (as documented in the VoiceObjects Online Help -> Object Reference) to access media platform variables through JavaScript expressions. Because you can not reference non-existing objects in the lastresult$ array on MPS, if there are < 5 results, the JavaScript expressions simply returns the same (final) lastresult interpretation value in the "remaining" variables. The application subsequently uses the NbestCount to figure out how many results were returned (which N-Best Fund variables were set).

Now if the N-Best count is >1 and/or there was "low" confidence this application uses a script object to generate an inline GRXML grammar with a "top-level" rule which refers to the individual Fund rules in the same external Funds Grammar file. This script also generates the matching "wav files string".

// This script will build the inline N-best XML grammar and WavFiles string 
grammar = "<grammar mode='voice' root='NbestFunds' type='application/srgs+xml' version='1.0' xml:lang='en-US'>"; 
grammar += "<rule id='NbestFunds' scope='public'><one-of>"; 
grammar += "<item><tag>fundslot='" + fund0 +"'</tag> <ruleref uri='" + file + "#" + fund0.replace(/#/, "-") +"'/></item>"; 
fundwavfiles = fund0 + "_Name.wav&nbsp; "; // Need the space 
if ((fund1 !== "") && (fundcount > 1)) { 
	grammar += "<item><tag>fundslot='" + fund1 +"'</tag> <ruleref uri='" + file + "#" + fund1.replace(/#/, "-") +"'/></item>"; 		
	fundwavfiles += " " + fund1 + "_Name.wav&nbsp; "; // Need the space 
} 
if ((fund2 !== "") && (fundcount > 2)) { 
	grammar += "<item><tag>fundslot='" + fund2 +"'</tag> <ruleref uri='" + file + "#" + fund2.replace(/#/, "-") +"'/></item>"; 
	fundwavfiles += " " + fund2 + "_Name.wav&nbsp; "; // Need the space 
} 
if ((fund3 !== "") && (fundcount > 3)) { 
	grammar += "<item><tag>fundslot='" + fund3 +"'</tag> <ruleref uri='" + file + "#" + fund3.replace(/#/, "-") +"'/></item>"; 
	fundwavfiles += " " + fund3 + "_Name.wav&nbsp; "; // Need the space 
} 
if ((fund4 !== "") && (fundcount > 4)) { 
	grammar += "<item><tag>fundslot='" + fund4 +"'</tag> <ruleref uri='" + file + "#" + fund4.replace(/#/, "-") +"'/></item>"; 
	fundwavfiles += " " + fund4 + "_Name.wav&nbsp; "; // Need the space 
}
grammar += "</one-of></rule></grammar>";

The parameter set for this script is:

Parameter: FundWavFiles Alias: fundwavfiles
Parameter: NbestFundsGrammar Alias: grammar
Parameter: GrammarLocator Alias: file
Parameter: NbestCount Alias: fundcount
Parameter NbestFund0 Alias fund0
Parameter NbestFund1 Alias fund1
Parameter NbestFund2 Alias fund2
Parameter: NbestFund3 Alias: fund3
Parameter NbestFund4 Alias fund4

Then the application has another input that asks: "We have several fund names that are similar. Please repeat the one you want, or say none of them " [V: FundWavFiles]

The grammmar for this Input uses the NbestFundsGrammar variable from the script in the TTG box (uncheck TTG)

The FundWavFiles variable contains the (space separated) list of WAV files. (Format: "TTA Files" and needs a provided Audio ResourceLocator)

Was this page helpful?  
Last edited by:kschmitte on: 9/18/2009 8:04 AM (EDT)

Tags:
Edit  | Tags | Files | Info | Options | Subscribe |


©2002-2012 Voxeo Corporation  -  VoiceXML Hosting  -  VoiceXML Servers  -  Site Map  -  Terms of Use  -  Privacy Policy  -  Covered by U.S. Patent No. 6,922,411