This file contains the functions that are needed to interact with the ITSLanguage Speech Feedback API.
It's possible to get feedback while recording. After every sentence feedback is provided indicating whether or not the sentence was read well. This will be done through the ITSLanguage WebSocket Server.
The general approach for getting real-time feedback is:
- Prepare the speech feedback
- Register audio procedure for streaming
- Start listening for audio
To read up on the Speech feedback:
Methods
(static) feedback(challengeId, progressiveResultsCb, recorder, dataEvent) → {Promise}
- Source:
Function for convenience. Using this function calls the corresponding functions so that the required backend flow is backed up.
It will call the following functions (and more important, in the correct order):
prepare.listenAndReply.
Parameters:
| Name | Type | Description |
|---|---|---|
challengeId |
string | The Id of the Challenge to get feedback on. |
progressiveResultsCb |
function | A callback which will be used to receive progress on. |
recorder |
MediaRecorder | Audio recorder instance. |
dataEvent |
string | The event to use to collect data from. |
Returns:
- After each sentence there will be real-time feedback on that sentence. This feedback will be given through the progressiveResultsCb function. When the rpc is done, the promise will return an recording with the appropriate feedback per sentence.
- Type
- Promise
(static) listenAndReply(feedbackId, progressCb, recorder, dataEventopt) → {Promise}
- Source:
In order to receive feedback the server needs to listen for audio on a registered audio rpc. While listening the server will reply using progressive results. The server will stop listening when the audio rpc returns.
If you call this function the SDK will register an RPC method to the realm on which audio will be streamed to the backend.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
feedbackId |
string | The Id of the Feedback Challenge. |
|
progressCb |
function | A callback which will be used to receive progress on. |
|
recorder |
MediaRecorder | Audio recorder instance. |
|
dataEvent |
string |
<optional> |
Optional the event to collect data from. |
Returns:
- After each sentence there will be real-time feedback on that sentence. This feedback will be given through the progressiveResultsCb function. When the rpc is done, the promise will return an recording with the appropriate feedback per sentence.
- Type
- Promise
(static) pause(feedbackId) → {Promise}
- Source:
Feedback can be paused. This will stop the backend from processing the audio stream and returning feedback.
Important note: Pausing the feedback will not stop the feedback. Also make sure to stop sending data from the recorder to the backend.
Parameters:
| Name | Type | Description |
|---|---|---|
feedbackId |
string | The ID of the feedback to pause. |
Returns:
- An error if something went wrong.
- Type
- Promise
(static) prepare(challengeId) → {Promise}
- Source:
Prepare a new Speech Feedback. Should be called upon each new speech feedback. The backend will generate an unique ID for the feedback and prepare a speech challenge.
Parameters:
| Name | Type | Description |
|---|---|---|
challengeId |
string | The ID of the challenge to prepare. |
Returns:
- The ID of the Speech Feedback.
- Type
- Promise
(static) resume(feedbackId, sentenceId) → {Promise}
- Source:
A paused feedback can be resumed at a sentence in the challenge. If not provided, it will resume at the first sentence.
Parameters:
| Name | Type | Description |
|---|---|---|
feedbackId |
string | The ID of the feedback to resume. |
sentenceId |
string | The ID of the sentence to resume feedback from. |
Returns:
- An error if something went wrong.
- Type
- Promise