Voice Processor
Web API
API Reference for the Voice Processor Web SDK (npmjs).
PvEngine
Type that represents an engine that can receive frames of audio by subscribing to WebVoiceProcessor
.
WebVoiceProcessor
Class for capturing audio and delivering audio data to subscribing audio processing engines.
WebVoiceProcessor.audioContext
Gets the current audio context.
WebVoiceProcessor.isRecording
Flag to check if WebVoiceProcessor
is currently recording.
WebVoiceProcessor.audioDump()
Record some sample raw signed 16-bit PCM data for some duration, then pack it as a Blob.
Parameters
durationMs
number : Duration of the recording, in milliseconds.
Returns
- Promise<Blob> : The audio data in
Blob
format, wrapped in aPromise
.
WebVoiceProcessor.subscribe()
Subscribe one or more engines. A subscribed engine will receive audio frames via .postMessage({command: 'process', inputFrame: inputFrame})
. Audio capture will start as soon as there is one or more engine subscribed.
Parameters
WebVoiceProcessor.unsubscribe()
Unsubscribe one or more engines. The unsubscribed engines will no longer receive audio frames. Audio capture will stop as soon as there is no more engines subscribed.
Parameters
WebVoiceProcessor.reset()
Removes all engines and stops recording audio.
WebVoiceProcessor.setOptions()
Set new WebVoiceProcessor options. If forceUpdate
is not set to true, all engines must be unsubscribed and subscribed again in order for the recorder to take the new changes. Using forceUpdate
might cause a small gap where audio frames are not received.
Parameters
options
WebVoiceProcessorOptions : Audio configuration for recording.forceUpdate
boolean : Flag to force update recorder with new options.
WebVoiceProcessorOptions
Type containing the audio recording configuration use by WebVoiceProcessor
.
Parameters
frameLength
number : Number of samples per frame of audio (default: 512).outputSampleRate
number : Target sample rate of recorded audio (default: 16000).deviceId
string | null : Microphone id to use (can be fetched with mediaDevices.enumerateDevices).filterOrder
number : Filter order (default: 50).
WvpError
Class the represents errors produced by WebVoiceProcessor
.
WvpMessageEvent
Class that represents the message an engine receives when a frame of audio is captured by WebVoiceProcessor
.