voxxy

Reference v0.1.2

voxxy/testing

Fake recorder and player, for tests.

import { … } from "voxxy/testing"

Functions

wavToMono16k function

function wavToMono16k(bytes: Uint8Array): Float32Array

Decodes 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>>
): Recorder

A 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): Player

Queues like the real player: a buffer handed over while another plays waits for its turn.

Interfaces

FakePlayerOptions interface

interface FakePlayerOptions

Options for fakePlayer().

speed?: number

How much faster than real time it "plays". Default 10, so tests do not wait for whole sentences.

onPlay?: (info: { samples: number; sampleRate: number }) => void

Called when a buffer starts playing.