AudioProcessor

AudioProcessor

new AudioProcessor(buffer, sampleRate)

The AudioProcessor class
Contains a collection of audio processing utilities for downsampling and
encoding audio.

Parameters:
Name Type Description
buffer ArrayBuffer

The raw audio data.

sampleRate Number

The current sample rate for the provided audio.

Methods

downsampleAudio()

Downsamples the audio to a target sample rate.

Inspired by the following blog post from the Lex team:
https://aws.amazon.com/blogs/machine-learning/capturing-voice-input-in-a-browser/

encodeWAV()

Converts audio data to WAV.

Inspired by the following blog post from the Lex team:
https://aws.amazon.com/blogs/machine-learning/capturing-voice-input-in-a-browser/

floatTo16BitPCM(view, offset, input)

Encode WAV audio as 16bit PCM

Parameters:
Name Type Description
view DataView

The WAV audio

offset number

The starting offset to use for encoding

input ArrayBuffer

The original audio buffer data.