Constructor
new AudioClip(options)
- Source:
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
Extends
- PsychObject
Members
(static, readonly) Engine :Symbol
- Source:
Properties:
Name | Type | Description |
---|---|---|
GOOGLE |
Symbol | Google Cloud Speech-to-Text. |
Recognition engines.
Type:
- Symbol
(static, readonly) Status :Symbol
- Source:
Properties:
Name | Type | Description |
---|---|---|
CREATED |
Symbol | |
DECODING |
Symbol | |
READY |
Symbol |
AudioClip status.
Type:
- Symbol
Methods
(protected) _base64ArrayBuffer(arrayBuffer) → {string}
- Source:
Convert an array buffer to a base64 string.
Parameters:
Name | Type | Description |
---|---|---|
arrayBuffer |
the input buffer |
Returns:
the base64 encoded input buffer
- Type
- string
(protected) _decodeAudio()
- Source:
Decode the formatted audio data (e.g. webm) into a 32bit float PCM audio buffer.
(protected) _GoogleTranscribe(transcriptionKey, languageCode) → {Promise}
- Source:
Transcribe the audio clip using the Google Cloud Speech-To-Text Engine.
ref: https://cloud.google.com/speech-to-text/docs/reference/rest/v1/speech/recognize
Parameters:
Name | Type | Description |
---|---|---|
transcriptionKey |
String | the secret key to the Google service |
languageCode |
String | the BCP-47 language code for the recognition, e.g. 'en-GB' |
Returns:
a promise resolving to the transcript and associated transcription confidence
- Type
- Promise
download()
- Source:
Offer the audio clip to the participant as a sound file to download.
(async) getDuration() → {Promise.<number>}
- Source:
Get the duration of the audio clip, in seconds.
Returns:
the duration of the audio clip
- Type
- Promise.<number>
setVolume(volume)
- Source:
Set the volume of the playback.
Parameters:
Name | Type | Description |
---|---|---|
volume |
number | the volume of the playback (must be between 0.0 and 1.0) |
(async) startPlayback()
- Source:
Start playing the audio clip.
(async) stopPlayback(fadeDurationopt)
- Source:
Stop playing the audio clip.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
fadeDuration |
number |
<optional> |
17
|
how long the fading out should last, in ms |
(async) transcribe(options) → {Promise}
- Source:
Transcribe the audio clip.
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
Returns:
a promise resolving to the transcript and associated transcription confidence
- Type
- Promise
upload()
- Source:
Upload the audio clip to the pavlovia server.