# SpeechRecognition

## sound SpeechRecognition

This manager handles the live transcription of speech into text.

## Constructor

#### new SpeechRecognition(options)

Source:
  - sound/SpeechRecognition.js, line 53
To Do:
  - deal with alternatives, interim results, and recognition errors

This manager handles the live transcription of speech into text.

##### Parameters:

Name | Type | Description
--- | --- | ---
`options` | Object | ###### Properties
Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`psychoJS` | module:core.PsychoJS |  |  | the PsychoJS instance
`name` | String |  |  | the name used when logging messages
`bufferSize` | number | <optional> | `10000` | the maximum size of the circular transcript buffer
`continuous` | Array.<String> | <optional> | `true` | whether to continuously recognise
`lang` | Array.<String> | <optional> | `'en-US'` | the spoken language
`interimResults` | Array.<String> | <optional> | `false` | whether to make interim results available
`maxAlternatives` | Array.<String> | <optional> | `1` | the maximum number of recognition alternatives
`tokens` | Array.<String> | <optional> | `[]` | the tokens to be recognised. This is experimental technology, not available in all browser.
`clock` | Clock | <optional> |  | an optional clock
`autoLog` | boolean | <optional> | `false` | whether to log

### Extends

- PsychObject

### Methods

#### (protected) _onChange()

Source:
  - sound/SpeechRecognition.js, line 238

Callback for changes to the recognition settings.

Changes to the recognition settings require the speech recognition process to be stopped and be re-started.

#### (protected) _prepareRecognition()

Source:
  - sound/SpeechRecognition.js, line 256

Prepare the speech recognition process.

#### clearTranscripts()

Source:
  - sound/SpeechRecognition.js, line 221

Clear all transcripts and resets the circular buffers.

#### getTranscripts(options) → {Array.<Transcript>}

Source:
  - sound/SpeechRecognition.js, line 178

Get the list of transcripts still in the buffer, i.e. those that have not been previously cleared by calls to getTranscripts with clear = true.

##### Parameters:

Name | Type | Description
--- | --- | ---
`options` | Object | ###### Properties
Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`transcriptList` | Array.<string> | <optional> | `[]` | the list of transcripts texts to consider. If transcriptList is empty, we consider all transcripts.
`clear` | boolean | <optional> | `false` | whether or not to keep in the buffer the transcripts for a subsequent call to getTranscripts. If a keyList has been given and clear = true, we only remove from the buffer those keys in keyList

##### Returns:

the list of transcripts still in the buffer

Type
  Array.<Transcript>

#### start() → {Promise}

Source:
  - sound/SpeechRecognition.js, line 102

Start the speech recognition process.

##### Returns:

promise fulfilled when the process actually starts

Type
  Promise

#### stop() → {Promise}

Source:
  - sound/SpeechRecognition.js, line 150

Stop the speech recognition process.

##### Returns:

promise fulfilled when the process actually stops

Type
  Promise