Reference v0.1.2
voxxy/testing
Fake recorder and player, for tests.
import { … } from "voxxy/testing"
Functions
wavToMono16k function
function wavToMono16k(bytes: Uint8Array): Float32ArrayDecodes a 16-bit PCM WAV (any channel count and rate) to mono 16 kHz Float32, for tests and fixtures.
clipRecorder function
function clipRecorder(
clip: Float32Array<ArrayBufferLike> | () => Promise<Float32Array<ArrayBufferLike>>
): RecorderA recorder that "hears" a prepared clip instead of a microphone: stop() returns the clip (mono 16 kHz). Lets the stand and tests run the whole listen() path, speech recogniser included, on known speech.
fakeRecorder function
function fakeRecorder(): Recorder"Records" 16 samples per millisecond held, at least 100 ms worth, so a transcript reflects how long the button was down.
fakePlayer function
function fakePlayer(__namedParameters?: FakePlayerOptions): PlayerQueues like the real player: a buffer handed over while another plays waits for its turn.
Interfaces
FakePlayerOptions interface
interface FakePlayerOptionsOptions for fakePlayer().
speed?: numberHow much faster than real time it "plays". Default 10, so tests do not wait for whole sentences.
onPlay?: (info: { samples: number; sampleRate: number }) => voidCalled when a buffer starts playing.