Browse
 
Tools
Rss Categories

Using the NLU Gateway

Reference Number: AA-02446 Views: 2313 0 Rating/ Voters

Usage of the NLU Gateway is done as an added feature of using the LumenVox Transcription ASR engine.

When activating the transcription engine a simple "dummy" grammar is supplied with a meta tag within the grammar triggering transcription mode (see TRANSCRIPTION_ENGINE with the value V2 below). 

Also when using the NLU gateway,  a further meta tag is supplied to indicate which NLU end-point is to be used to do the NLU processing.

In this example, US English transcription will be done on the audio.  The text results will then be sent to the NLU Gateway, using the end-point set up with the name "TravelBot".
<?xml version='1.0'?>
<!-- 
    This grammar should not be used for regular speech recognition.
    It should only be used to enable transcription mode when used with
    NLU Gateway to perform intent processing using the specified model.
-->
<grammar xml:lang="en-US" version="1.0" root="root" mode="voice"
    xmlns="http://www.w3.org/2001/06/grammar"
    tag-format="semantics/1.0"> 
       
    <meta name="TRANSCRIPTION_ENGINE" content="V2"/>
    <meta name="INTERPRETATION_AS_JSON" content="1"/>
       
    <meta name="lv_nlu_gateway_model_id" content="TravelBot"/>
       
    <rule id="root" scope="public">
        <ruleref special="NULL"/>
    </rule>
</grammar>


The ASR engine will process the audio, internally generate the transcription text, and then send this text to the specified NLU service via the NLU Gateway.

Results from the NLU service will be returned in the Semantic Interpretation portion of the overall results returned by the ASR engine.  This will be in XML format as defined by W3C SISR specification.

There is also a configuration option available, that will return the results as an embedded JSON formatted string, as shown in the following examples, which may simplify the task of parsing the NLU results within the speech application's code. To enable this optional embedded JSON output, include the INTERPRETATION_AS_JSON meta tag entry shown above with a value of 1, or select 0 to disable (and return the Semantic Interpretation as embedded XML)

Please see the attached grammar file (Transcribe-and-NLU.grxml) that is available for download below. Use this as your template and use your own values in here for the end-point selection and the output configuration setting you wish to use.


Sample XML style output.

<?xml version='1.0' encoding='ISO-8859-1'?>
<result>
    <interpretation grammar="Transcribe-and-NLU.grxml" confidence="99">
        <input mode="speech">ONE TWO THREE FOUR</input>
        <instance>
            <GatewayResults>
                <AgentId>LumenVox_Lex_Account</AgentId>
                <Intents length="3">
                    <item index="0">
                        <confidence>0.49</confidence>
                        <type>BookHotel</type>
                    </item>
                    <item index="1">
                        <confidence>0.38</confidence>
                        <type>BookCar</type>
                    </item>
                    <item index="2">
                        <confidence>0</confidence>
                        <type>AMAZON.FallbackIntent</type>
                    </item>
                </Intents>
                <NextMessage>What city will you be staying in?</NextMessage>
                <SessionId>e0f38ced-3ea0-4d1b-8bb5-7702fd5b6cea</SessionId>
                <Slots length="4">
                    <item index="0">
                        <confidence>1</confidence>
                        <type>CheckInDate</type>
                        <value/>
                    </item>
                    <item index="1">
                        <confidence>1</confidence>
                        <type>Location</type>
                        <value/>
                    </item>
                    <item index="2">
                        <confidence>1</confidence>
                        <type>Nights</type>
                        <value>1234</value>
                    </item>
                    <item index="3">
                        <confidence>1</confidence>
                        <type>RoomType</type>
                        <value/>
                    </item>
                </Slots>
            </GatewayResults>
        </instance>
    </interpretation>
</result>


Sample JSON style output.

<?xml version='1.0' encoding='ISO-8859-1'?>
<result>
    <interpretation grammar="Transcribe-and-NLU.grxml" confidence="99">
        <input mode="speech">ONE TWO THREE FOUR</input>
        <instance>
        {
           "GatewayResults" : {
              "AgentId" : "LumenVox_Lex_Account",
              "Intents" : [
                 {
                    "confidence" : 0.49,
                    "type" : "BookHotel"
                 },
                 {
                    "confidence" : 0.38,
                    "type" : "BookCar"
                 },
                 {
                    "confidence" : 0,
                    "type" : "AMAZON.FallbackIntent"
                 }
              ],
              "NextMessage" : "What city will you be staying in?",
              "SessionId" : "b64351b0-290b-405c-a910-92c92223dfed",
              "Slots" : [
                 {
                    "confidence" : 1,
                    "type" : "CheckInDate",
                    "value" : ""
                 },
                 {
                    "confidence" : 1,
                    "type" : "Location",
                    "value" : ""
                 },
                 {
                    "confidence" : 1,
                    "type" : "Nights",
                    "value" : "1234"
                 },
                 {
                    "confidence" : 1,
                    "type" : "RoomType",
                    "value" : ""
                 }
              ]
           }
        }
        </instance>
    </interpretation>


Attachments
Transcribe-and-NLU.grxml 690 b Download File