Skip to main content

Events

All SDK events are available in two formats: via the addEventListener() method or using the on properties of the IaraSpeechRecognition object. In each case, the function will receive an event as parameter whose property detail will contain data on Iara Health.

IMPORTANTE:: data related with the Iara Health are always property detail of any event, example: event.detail.

For example, given the dummy event result, it can be accessed through addEventListener():

var recognition = new IaraSpeechRecognition();

recognition.addEventListener('result', function(event) {
// Iara Health related data are available
// through the `detail` property of any event.
console.log(event.detail);
});

Or by means of the property onresult:

recognition.onresult = function(event) {
// Iara Health related data will be available
// via the `detail` property of any event.
console.log(event.detail);
}

To facilitate event discovery (and the IDEs code autocomplete), all the events released by the IaraSpeechRecognition class are available as static properties of the IaraEvent class.

Tip: IaraEvent class contains all ready-to-use events. Type IaraEvent in your IDE in order to list the properties of that class (which are the available events).

The following sections describe, by subject, each of the available events and the content of their property detail. All the examples shown underneath assume that a recognizer named recognition has been instantiated:

var recognition = new IaraSpeechRecognition();

List of available events

The table below shows all the existing events, all accessible through IaraEvent.*.

EventInformation
SPEECH_RECOGNITION_RESULT-
SPEECH_RECOGNITION_START-
SPEECH_RECOGNITION_STARTING-
SPEECH_RECOGNITION_STOP-
SPEECH_RECOGNITION_READY-
INIT_DONE-
INIT_FAIL-
INIT_VOICE_MODEL_DOWNLOAD_STARTED-
INIT_VOICE_MODEL_DOWNLOAD_COMPLETED-
INIT_VOICE_MODEL_DOWNLOAD_PROGRESS-
INIT_API_AUTH-
INIT_API_CONFIG-
INIT_ALS_CHECK-
INIT_INSTALL_ALS-
INIT_PROGRESS-
ALS_OFFLINE-
ALS_ONLINE-
AUDIO_LEVEL_UPDATE-
AUDIO_DEVICE_ADD-
AUDIO_DEVICE_REMOVE-
AUDIO_DEVICE_CHANGE-
SHORTCUT-
INTERNAL-
ERROR-
ERROR_NO_INPUT_DEVICE-
ERROR_UNSUPPORTED_SAMPLE_RATE-
ERROR_RECORD_INTERRUPTION-
NEWER_VOICE_MODEL_AVAILABLE-
NEWER_ALS_AVAILABLE-

The following sections explain and exemplify in more details each of the events listed above.

Voice recognition

Iara Health voice recognition related events. All those events are emitted after a successful boot has taken place.

Ready - IaraEvent.SPEECH_RECOGNITION_READY and onready

Emitted when the recognizer is ready for receive input audio to make new inferences.

recognition.addEventListener(IaraEvent.SPEECH_RECOGNITION_READY, function(event) {
console.log(event.detail);
});

recognition.onready = function(event) {
console.log(event.detail);
}

Result - IaraEvent.SPEECH_RECOGNITION_RESULT and onresult

Emitted when the recognizer finishes an inference.

recognition.addEventListener(IaraEvent.SPEECH_RECOGNITION_RESULT, function(event) {
console.log(event.detail);
});

recognition.onresult = function(event) {
console.log(event.detail);
}

See the section Voice recognition to learn more about the voice recognition, including obtaining intermediate results.

Start - IaraEvent.SPEECH_RECOGNITION_START and onstart

Emitted when the recognizer starts the recognition process, i.e. shortly after start() has been called.

recognition.addEventListener(IaraEvent.SPEECH_RECOGNITION_START, function(event) {
console.log(event.detail);
});

recognition.onstart = function(event) {
console.log(event.detail);
}
IMPORTANT: there may be a few milliseconds pause (or seconds, depending on user's computer) from the moment that start() is called and the moment which the recognition actually begins. It happens because the ALS is setting the system audio channels. The IaraEvent.SPEECH_RECOGNITION_START and onstart events indicate when the recognition properly started.

Stop - IaraEvent.SPEECH_RECOGNITION_STOP and onstop

Emitted when the recognizer has been instructed to stop the current recognition, i.e. shortly after stop() has been called.

recognition.addEventListener(IaraEvent.SPEECH_RECOGNITION_STOP, function(event) {
console.log(event.detail);
});

recognition.onstop = function(event) {
console.log(event.detail);
}

VAD Voice Start - IaraEvent.SPEECH_RECOGNITION_VAD_VOICE_START

Emitted when the useVAD option is true in the initialization and the VAD (voice activity detection) starts voice detection.

recognition.addEventListener(IaraEvent.SPEECH_RECOGNITION_VAD_VOICE_START, function(event) {
console.log(event.detail);
});

VAD Voice Stop - IaraEvent.SPEECH_RECOGNITION_VAD_VOICE_STOP

Emitted when the useVAD option is true in the initialization and the VAD (voice activity detection) stops voice detection.

recognition.addEventListener(IaraEvent.SPEECH_RECOGNITION_VAD_VOICE_STOP, function(event) {
console.log(event.detail);
});

Initialization

Emitted events during the Iara's recognizer initialization process.

Init done - IaraEvent.INIT_DONE and oninitdone

Emitted when the recognizer has finished its initialization and is ready to work.

recognition.addEventListener(IaraEvent.INIT_DONE, function(event) {
console.log(event.detail);
});

recognition.oninitdone = function(event) {
console.log(event.detail);
}
Tip: the done() callback chained with the recognizer method init() is a shortcut to IaraEvent.INIT_DONE and oninitdone.

The IaraEvent.INIT_DONE and oninitdone events are also available through the done() callback chained with method init() from the recognizer:

var recognition = new IaraSpeechRecognition();

recognition.init({
userId: 'meu@email.com',
apiToken: '197765800edb8affcb44a7ae7b4ff0a3'

}).done(function(e) {
// Initialization completed successfully

});

Init fail - IaraEvent.INIT_FAIL and oninitfail

Emitted when the recognizer don't complete the initialization successfully. If this event is emitted, the recognizer won't be ready to do any voice recognition.

recognition.addEventListener(IaraEvent.INIT_FAIL, function(event) {
console.log(event.detail);
});

recognition.oninitfail = function(event) {
console.log(event.detail);
}
Tip: the fail() callback chained with the recognizer method init() is a shortcut to IaraEvent.INIT_FAIL and oninitfail.

The IaraEvent.INIT_DONE and oninitdone events are also available through the done() callback chained with method init() from the recognizer:

var recognition = new IaraSpeechRecognition();

recognition.init({
userId: 'meu@email.com',
apiToken: '197765800edb8affcb44a7ae7b4ff0a3'

}).fail(function(e) {
// Initialization has failed.
});

Init progress - IaraEvent.INIT_PROGRESSS and oninitprogress

Emitted when the recognizer is initializing. During the initialization process, the recognizer goes through several steps, as authentication with the Iara API voice template download, etc.

For each of these steps, the events IaraEvent.INIT_PROGRESSS and oninitprogress will be called:

recognition.addEventListener(IaraEvent.INIT_PROGRESSS, function(event) {
console.log(event.detail);
});

recognition.oninitprogress = function(event) {
console.log(event.detail);
}

Every time that IaraEvent.INIT_PROGRESSS and oninitprogress are emitted, you could know the initialization steps/status through the type propriety of the object detail of the event passed as parameter, i.e. event.detail.type.

The possible values to event.detail.type are:

  • IaraEvent.INIT_VOICE_MODEL_DOWNLOAD_STARTED: emitted when the recognizer started the download of user voice model identified by the propriety userId used during the call to init().

  • IaraEvent.INIT_VOICE_MODEL_DOWNLOAD_PROGRESS: several times emitted while the recognizer downloads the user voice model identified by the propriety userId used during the call to init(). You can see the download progress by the propriety data of the object detail of the event passed as paremeter, i.e. event.detail.data.

  • IaraEvent.INIT_VOICE_MODEL_DOWNLOAD_COMPLETED: emitted when the recognizer completed download of the user voice model identified by the propriety userId used during the init() call.

Tip: the progress() callback chained with the recognizer method init() is a shortcut to IaraEvent.INIT_PROGRESSS and oninitdone.

All the initialization progress events, ex: IaraEvent.INIT_*, are avaiable through the progress() callback chained with the recognizer's init() method:

var recognition = new IaraSpeechRecognition();

recognition.init({
userId: 'meu@email.com',
apiToken: '197765800edb8affcb44a7ae7b4ff0a3'

}).progress(function(e) {
// Initialization is taking place.
console.log(e.detail.type, e.detail.data);
});

Audio

Events linked to the control of audio input and output devices. See the audio's device section to learn more about configuring and choosing audio input and output.

Audio level update - IaraEvent.AUDIO_LEVEL_UPDATE and onaudiolevelupdate

Emitted by the recognizer when audio is detected on the input device, after start() has been called.

recognition.addEventListener(IaraEvent.AUDIO_LEVEL_UPDATE, function(event) {
console.log(event.detail);
});

recognition.onaudiolevelupdate = function(event) {
console.log(event.detail);
}
Tip: use the `IaraEvent.AUDIO_LEVEL_UPDATE` and `onaudiolevelupdate` events to improve the UX of your application. For example, after `start()` is called, you will see small vertical (sound) bars moving to indicate that audio is being captured by mic.

Errors

In order to facilitate error handling, the SDK triggers events related to the error in question. The relevant information can be accessed in event.detail. Each error has:

  • A single errorCode, that's represented below by the 'code' column;
  • A developerMessage, in order to explain the error cause to developer;
  • A userMessage, that's represent a message suggestion to be shown to the user.

Errors List

The table below show all existent errors and its descriptions.

CodeEvent triggeredMessage to the developerDescription
1ERROR_RECORD_INTERRUPTIONAdding or removing audio devices when recording is not allowed.Recording problem: a mic was added or removed while the recognition was active. (Code #1)
2ERRORUnknown error, please contact our team.Unknown error: please, contact support. (Code #2)
3ERRORUnknown error, please contact our team.Unknown audio error: please, contact support. (Code #3)
4ERROR_RECORD_INTERRUPTIONSomething affected the recording: + reason.Recording problem: an unknown error has interrupted the recording. Please, contact support. (Code #4)
5ERROR_NO_INPUT_DEVICENo input device is available.Unavailable mic: please, check if you have a mic connected. (Code #5)
6ERRORALS seems to be permanently offline.Iara's local service problem: please, restart "ALS". If the problem persists, please contact support. (Code #6)
7ERRORmediaDevices not supported by browser or insecure access (HTTP instead of HTTPS).Unavailable mic: browser doesn't have secure access to the mic or it isn't supported. Please, contact support. (Code #7)
8ERRORUnable to create browser stream.Audio error: please, contact support. (Code #8)
9ERRORUnable to enumerate input devices.Unavailable microphone: wasn't possible verify if it has a mic connected. Please, restart "ALS". If the problem persists, please contact support. (Code #9)
10UNSUPPORTED_SAMPLE_RATEBrowser mic has an unsupported sample rate for recording.Unavailable microphone: wasn't possible to start the microphone. Please, contact support. (Code #10)
11ERRORUnable to record.Record problem: unable recording. Please, contact support. (Code #11)
12ERRORRecording is disabled: + reason.Record problem: previous recording is being processed. Ann error occurred, please, wait a minute or two and try again. If the problem persists, please contact support. (Code #12)
13INIT_FAILUnauthorized access to Iara API.Initialization has failed: invalid password or username. Please check your credentials. (Code #13)
14INIT_FAILIncompatible OS or browser version.Initialization is failed: browser or operational system incompatible with Iara. (Code #14)
15INIT_FAILProblem reading Iara API SDK version info.Initialization is failed: don't possible verify "Javascript SDK" version. Please, contact support. (Code #15)
18INIT_FAILNo suitable input method is available. Check your audio input devices.Initialization failed: Could not detect an Iara compatible mic. (Code #18)
19INIT_FAILNo audio input device is available. Check if you have a valid mic or SpeechMike.Initialization failed: Could not detect one mic. (Code #19)
20INIT_FAILRequested input is invalid. Valid inputs are "auto" or "speechmike", for instance.Initialization failed: an incompatible mic was select. (Code #20)
21INIT_FAILALS not installed.Initialization failed: Iara's local service "ALS" don't be seems installed. (Code #21)
22ERRORThe Iara speech recognition engine is busy. Please try again in a moment.Iara's voice recognition engine is currently busy. Please try again in a few moments. (Code #22)
23ERRORError dealing with the Iara API.Communication failed with Iara's API. Please try again in a few moments. If the problem persists, please contact support. (Code #23)
24ERRORUnable to initialize.Initialization has failed: unable initialize the voice recognizer engine. Please, contact support. (Code #24)
25ERRORRecorder already in use.Iara is open in one more place. At this moment has not posible use voice recognize same time on several browser tabs. (Code #25)
26ERRORRecorder being forcefully disconnected.Iara is open in one more place. At this moment has not posible use voice recognize same time on several browser tabs. (Code #26)
27ERRORUnable to generate audio log.There was a problem with the audio file for registration purposes. You can continue using Iara normally. If the problem persists, please contact support. (Code #27)
28ERRORUnable to open audio line.Audio error: unknow error don't has allowed record beging. Please, contact support. (Code #28)
29ERRORUnable to open and/or start playback line.Audio error: unknow error don't has allowed audio's play. Please, contact support. (Code #29)
30ERRORUnable to open and/or start capture line.Record problem: unable started recording. Check the mic connect. If the problem persists, please contact support. (Code #30)
31ERRORRecorder is busy.Record problem: ALS recording local data is busy. Please try again in a few moments. If the problem persists, please, contact support. (Code #31)
32ERRORUnable to generate .ogg file.There was a problem with the audio file for registration purposes. You can continue using Iara normally. If the problem persists, please, contact support. (Code #32)
33ERRORInvalid command.Communication problem with my local service "ALS": Invalid message. (Code #33)
34ERRORError selecting audio line.Mic's unavailable: please, check if selected mic are still connect. (Code #34)
35INIT_FAILThe Iara speech recognition engine is busy. Please try again in a moment.Iara's voice recognition engine is currently busy. Please try again in a few moments. (Code #35)
36INIT_FAILError dealing with the Iara API.Initialization has failed: communication failed with Iara's API. Please try again in a few moments. If the problem persists, please contact support. (Code #36)
37INIT_FAILUnable to initialize.Initialization has failed: unable initialize the voice recognizer engine. Please, contact support. (Code #37)
38INIT_FAILRecorder already in use.Initialization has failed: Iara is open in one more place. At this moment has not posible use voice recognize same time on several browser tabs. (Code #38)
39INIT_FAILRecorder being forcefully disconnected.Initialization has failed: Iara is open in one more place. At this moment has not posible use voice recognize same time on several browser tabs. (Code #39)
40INIT_FAILUnable to generate audio log.Initialization has failed: There was a problem with the audio file for registration purposes. You can continue using Iara normally. If the problem persists, please contact support. (Code #40)
41INIT_FAILUnable to open audio line.Initialization failed: Audio error: unknown error don't have allowed recording start. Please, contact support. (Code #41)
42INIT_FAILUnable to open and/or start playback line.Initialization failed: Audio error: unknown error don't have allowed audio's play. Please, contact support. (Code #42)
43INIT_FAILUnable to open and/or start capture line.Initialization failed: Record problem: unable started recording. Check the mic is connect. If the problem persists, please contact support. (Code #43)
44INIT_FAILRecorder is busy.Initialization failed: record problem: "ALS" recording local service is busy. Please try again in a few moments. If the problem persists, please, contact support. (Code #44)
45INIT_FAILUnable to generate .ogg file.Initialization has failed: There was a problem with the audio file for registration purposes. You can continue using Iara normally. If the problem persists, please, contact support. (Code #45)
46INIT_FAILInvalid command.Initialization has failed: Communication problem with my local service "ALS": Invalid message. (Code #46)
47INIT_FAILError selecting audio line.Initialization has failed: mic's unavailable: please, check if selected mic are still connect. (Code #47)
48INIT_FAILThe installed ALS version is outdated and incompatible with this SDK version.Initialization has failed: The version installed ALS local service is incompatible or is outdated. (Code #48)
49INIT_FAILALS closed all currently active connections due to forceConnect (probably multiple tabs are open).Initialization failed: Iara's local service "ALS" seems to have closed all connections. It may be that Iara is started in more than one tab of your browser. (Code #49)
50INIT_FAILInvalid response from Iara API.Initialization has failed: communication failed with Iara's API. Please try again in a few moments. If the problem persists, please contact support. (Code #50)
51ERRORFailed to submit the feedback to the Iara API. Reason: + reason.Error: failed to submit feedback. (Code #51)
53ERRORUnable to properly initialize ALS protocols that use the UserAgent. You can try to restart the ALS and refresh the page to fix the problem and, if that doesn't work, try reinstalling the ALS.Local service problem: unable to initialize ALS protocols correctly disabling the functionality of shortcuts for recording, copy report and the external editor. Please, can try to restart the ALS and refresh the page to fix the problem and, if that doesn't work, try reinstalling the ALS. (Code #53)
54ERRORUnable to run the recognition engine for the given audio file. Please, check that the file is in proper wav 44100Hz format.Problem running voice recognition engine with given audio file. Please, check that the file is in proper wav 44100Hz format. (Code #54)
55ERRORFailed to update or create a report.Failed to update or create a report. (Code #55)
56INIT_FAILUser license has expired.User license has expired. Please, check that there aren't outstanding payments. (Code #56)
57ERRORFailed to fetch user parser rules.Failed to fetch user parser rules. (Code #57)
58INIT_FAILUser denied mic usage permission.Initialization has failed: recognition needs permission for browser mic access. (Code #58)
59INIT_FAILFailed to update the user parser rules in the speech engine.Failed to fetch user parser rules. (Code #59)