Last reviewed: 12/15/2024 8:55:32 AM
Event Handling
To receive VoiceXML validation and runtime messages, applications receive event notifications.
| Event | Event Arguments | Description |
|---|---|---|
| ApiError | ChantAPIErrorEventArgs | Notifies the application of an API error |
| CompileDone | VxmlCompileDoneEventArgs | Notifies the application that the compile process is done |
| CompileError | VxmlCompileErrorEventArgs | Notifies the application that the compiler detected a grammar error |
| DlgAddChoice | VxmlDlgTextEventArgs | Notifies the application of an add choice event |
| DlgClearChoices | VxmlDlgEventArgs | Notifies the application of a clear choices event |
| DlgClearText | VxmlDlgEventArgs | Notifies the application of a clear text event |
| DlgCreateDialog | VxmlDlgEventArgs | Notifies the application of a create event |
| DlgHideChoices | VxmlDlgEventArgs | Notifies the application of a hide choices event |
| DlgHideText | VxmlDlgEventArgs | Notifies the application of a hide text event |
| DlgSelectChoice | VxmlDlgTextEventArgs | Notifies the application of a select choice event |
| DlgSetPrompt | VxmlDlgTextEventArgs | Notifies the application of a set prompt event |
| DlgSetText | VxmlDlgTextEventArgs | Notifies the application of a set text event |
| DlgShowChoices | VxmlDlgEventArgs | Notifies the application of a show choices event |
| DlgShowDialog | VxmlDlgEventArgs | Notifies the application of a show event |
| DlgShowText | VxmlDlgEventArgs | Notifies the application of a show text event |
| Done | VxmlDoneEventArgs | Notifies the application of a done event |
| Log | VxmlLogEventArgs | Notifies the application of a log event |
Some events provide data values that are returned in argument objects. Argument data availability varies among Speech APIs.
-
ChantAPIErrorEventArgs
- Function - API funtion name
- Message - API error message
- RC - API error return code
-
VxmlCompileDoneEventArgs
- File - File name
-
VxmlCompileErrorEventArgs
- LineNumber - Line number
- LinePosition - Line position
- Error - Compile error
- Description - Compile error description
-
VxmlDlgEventArgs
- SessionID - Session identifier
-
VxmlDlgTextEventArgs
- SessionID - Session identifier
- Text - Text
-
VxmlDoneEventArgs
- LeafDocument - Leaf document name
- Node - Node name
- RootDocument - Root document name
- SessionID - Session identifier
- Variables - Collection of Event/Value pair variables
-
VxmlLogEventArgs
- SessionID - Session identifier
- Text - Text
Event notifications are recieved in callback routines as follows:
_VoiceXML = _VoiceXMLKit.CreateSAPI5VoiceXML();
// Register for the events
if (_VoiceXML != null)
{
_VoiceXML.Done += VoiceXML_Done;
...
}
_VoiceXML = _VoiceXMLKit->CreateSAPI5VoiceXML();
if (_VoiceXML != NULL)
{
_VoiceXML->SetDone(VoiceXMLDone);
...
}
_VoiceXML = _VoiceXMLKit->CreateSAPI5VoiceXML();
if (_VoiceXML != NULL)
{
_VoiceXML->SetDone(VoiceXMLDone);
...
}
_VoiceXML := _VoiceXMLKit.CreateSAPI5VoiceXML();
if (_VoiceXML <> nil) then
begin
_VoiceXML.Done := VoiceXMLDone;
...
end;
_VoiceXMLKit = new JVoiceXMLKit();
if (_VoiceXMLKit != null)
{
// Set the callback
_VoiceXML.setChantVoiceXMLKitEvents(this);
// Register Callbacks
_VoiceXML.registerCallback(ChantVoiceXMLKitCallback.CCXMDone);
...
}
_VoiceXML = _VoiceXMLKit.CreateSAPI5VoiceXML()
// Declaring the event handlers routines with Handles clause in VB automatically registers for the event notifications
Public Sub VoiceXML_Done(ByVal sender As System.Object, ByVal e As VxmlDoneEventArgs) Handles _VoiceXML.Done
The Voice XML object sends all notifications to the event handlers. All event data is contained in a arguments object.
private void VoiceXML_Done(object sender, VxmlDoneEventArgs e)
{
if ((e != null) && (e.Variables != null))
{
...
}
}
void CALLBACK VoiceXMLDone(void* Sender, CVxmlDoneEventArgs* Args)
{
if ((Args != NULL) && (Args->GetVariables()->GetCount() > 0))
{
...
}
}
void CALLBACK VoiceXMLDone(void* Sender, CVxmlDoneEventArgs* Args)
{
if ((Args != NULL) && (Args->GetVariables()->Count > 0))
{
...
}
}
procedure TForm1.VoiceXMLDone(Sender: TObject; Args: TVxmlDoneEventArgs);
begin
if ((Args <> nil) and (Args.Variables <> nil)) then
begin
...
end;
end;
public void done(Object sender, VxmlDoneEventArgs args)
{
if ((args != null) && (args.getVariables() != null))
{
...
}
}
Public Sub VoiceXML_Done(ByVal sender As System.Object, ByVal e As VxmlDoneEventArgs) Handles _VoiceXML.Done
If ((e IsNot Nothing) And (e.Variables IsNot Nothing)) Then
...
End If
End Sub