Description

May be returned when enableSystemCommands() API is used. The NlpCommandResponse contains the results of the servers' NLP command model classification on the last sentence and indicates that a predetermined system command was detected. Current supported commands:

“Take a Snap”: takes a snapshot. “Start Recording”: starts a video recording if not already started. "Stop Recording”: stops an ongoing video recording, if applicable.

Example

//@input Asset.VoiceMLModule vmlModule

var parseAdditionalParams = function(additionalParams) {
if (additionalParams.length == 0) return "";
var retParams = "Additional params";
for (var i = 0; i < additionalParams.length; i++) {
retParams += " Key: " + additionalParams[i].key + " Value: " + additionalParams[i].value;
}
return retParams;
}

var parseStatusCode = function(status) {
var code = "";
switch(status.code) {
case VoiceMLModule.NlpResponsesStatusCodes.OK:
code = "OK";
break;
case VoiceMLModule.NlpResponsesStatusCodes.ERROR:
code = "ERROR";
break;
}
return "\nStatus Code: " + code + " Description: " + status.description;
}

var onUpdateListeningEventHandler = function(eventArgs) {
var commandResponses = eventArgs.getCommandResponses();
var nlpResponseText = "";

for (var iIterator = 0; iIterator < commandResponses.length; iIterator++) {
var commandResponse = commandResponses[iIterator];
nlpResponseText += "Command Response: " + commandResponse.modelName + "\n command: " + commandResponse.command;
nlpResponseText += parseAdditionalParams(commandResponse.additionalParams);
nlpResponseText += parseStatusCode(commandResponse.status);
nlpResponseText += "\n\n";
}
}

script.vmlModule.enableSystemCommands();
script.vmlModule.onListeningUpdate.add(onUpdateListeningEventHandler);
interface NlpCommandResponse {
    additionalParams: AdditionalParam[];
    command: string;
    modelName: string;
    status: NlpResponseStatus;
    getTypeName(): string;
    isOfType(type): boolean;
    isSame(other): boolean;
}

Hierarchy (view full)

Properties

additionalParams: AdditionalParam[]

Description

Additional params to send in the response.

command: string

Description

The classification result of the NLP command model for the sentence. For example, for the sentence "Take a snap!" with the enableSystemCommands() API enabled, the result will be a NlpCommandResponse holding a take a snap Command. In addition, the following values could be returned:

#SNAP_ERROR_INCONCLUSIVE: two or more commands detected. #SNAP_ERROR_INDECISIVE: no command detected. #SNAP_ERROR_NONVERBAL: no transcribable human voice was detected. #SNAP_ERROR_SILENCE: silence was detected.

Anything starting with #SNAP_ERROR_: Errors that are not currently defined in this documentation and should be ignored.

modelName: string

Description

Name of the model that sent the response. In current studio release, you can expect the result to contain either VOICE_ENABLED_UI like described in NlpModel. If using enableSystemCommands(), SYSTEM_COMMANDS will be returned as well.

Description

The status of the NLP response. in case of successful result, the value should be VoiceMLModule.NlpResponsesStatusCodes.OK, in case of failure, the value should be VoiceMLModule.NlpResponsesStatusCodes.ERROR.

Methods

  • Parameters

    • type: string

    Returns boolean

    Description

    Returns true if the object matches or derives from the passed in type.

  • Parameters

    Returns boolean

    Description

    Returns true if this object is the same as other. Useful for checking if two references point to the same thing.

Generated using TypeDoc