This file contains the readily available functions which interact with the ITSLanguage choice recognition API.
Speech recognitions can be stored and retrieved for user submitted audio using the ITSLanguage Speech API. The actual recognitions are performed by the ITSLanguage websocket server.
For streaming, note that this is one of the "nested" or "composite" APIs; You can only obtain the data if you provide a reference to the challenge for which you want a recording.
- Source:
Methods
(static) create(challengeId, audio, recognised, recognitionIdopt) → {Promise}
- Source:
- See:
Submit an audio fragment for recognition. The recognition is created for the current authenticated user.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
challengeId |
string | The ID of the challenge to relate the recognition to. |
||
audio |
Blob | The actual audio. |
||
recognised |
string | The recognised string. |
||
recognitionId |
string |
<optional> |
null
|
Unique identifier for the recognition. If none is given, one is generated. |
Returns:
- The created recognition with an url to download the audio if needed.
- Type
- Promise
(static) getAll(challengeId) → {Promise}
- Source:
- See:
Get all Choice Recognitions for a specific Choice Challenge.
Parameters:
| Name | Type | Description |
|---|---|---|
challengeId |
string | ID of the Choice Challenge to get all the recognitions for. |
Returns:
- Promise with the Choice Recognitions as result if successful.
- Type
- Promise
(static) getById(challengeId, id) → {Promise}
- Source:
- See:
Get a single ChoiceRecognition by its ID.
Parameters:
| Name | Type | Description |
|---|---|---|
challengeId |
string | ID of the Choice Challenge to get all the recognitions for. |
id |
string | ID of the choice recognition to get. |
Returns:
- Promise with the Choice Recognition as result if successful.
- Type
- Promise
(static) prepare() → {Promise}
- Source:
- See:
This is the starting point for a choice recognition. A unique recognition id is generated, which serves a leading role in the recognition. Each other call requires the recognition id as a parameter.
If other RPCs are called without this RPC being called first, the error
nl.itslanguage.session_not_initialised will be returned.
Returns:
- Returns a promise. When successfully the ID of the recognition is returned.
- Type
- Promise
(static) prepareChallenge(recognitionId, challengeId) → {Promise}
- Source:
- See:
Before performing the recognition, a WFST needs to be prepared for the challenge. When the RPC is called, the challenge is initialised asynchronously. When the challenge is to be used, the server automatically waits for the challenge initialisation to finish. If the initialisation results in an error, the error is relayed to the client.
Parameters:
| Name | Type | Description |
|---|---|---|
recognitionId |
string | The ID of the recognition to prepare the challenge for. |
challengeId |
string | The ID of the challenge to prepare. |
Returns:
- If succesful the promise returns nothing. On error, there will be an error.
- Type
- Promise
(static) recognise(challengeId, recorder) → {Promise.<*>}
- Source:
Easy function to do a recognition in one go. This is the "dance of the RPC's" that needs to be done in order to get correct feedback from the backend.
Parameters:
| Name | Type | Description |
|---|---|---|
challengeId |
string | The ID of the challenge to take the recognition for. |
recorder |
MediaRecorder | Audio recorder instance. |
Returns:
- If all good it returns the actual recognition. If not, any error can be expected to be returned.
- Type
- Promise.<*>
(static) recogniseAudioStream(recognitionId, recorder) → {Promise}
- Source:
Based on a recognitionId and a recorder register a RPC call that will be used to send the audio across the line. The actual registration will not be done here, but we send the RPC that the backend needs to call to the 'nl.itslanguage.choice.recognise' function.
Parameters:
| Name | Type | Description |
|---|---|---|
recognitionId |
string | The ID of the recognition to send audio for. |
recorder |
MediaRecorder | Audio recorder instance. |
Returns:
- When all good, the result will have the actual recognition.
- Type
- Promise
(static) recogniseNonStreaming(challengeId, recorder) → {Promise.<*>}
- Source:
- Deprecated:
- Yes
Easy function to do a recognition in one go. This is the "dance of the RPC's" that needs to be done in order to get correct feedback from the backend.
This function is here to support possible old backend servers where we did not use the streaming for choice challenges yet. It is deprecated and will be removed in the first minor update of the api sdk.
Parameters:
| Name | Type | Description |
|---|---|---|
challengeId |
string | The ID of the challenge to take the recognition for. |
recorder |
MediaRecorder | Audio recorder instance. |
Returns:
- If all good it returns the actual recognition. If not, any error can be expected to be returned.
- Type
- Promise.<*>
(inner) url(challengeId) → {string}
- Source:
The URL for the choice recognition challenge handler(s).
Parameters:
| Name | Type | Description |
|---|---|---|
challengeId |
Returns:
- Type
- string