Configurable stand-in for a real STT. Knobs mirror Python's FakeSTT: inject exceptions, scripted transcripts, connection timeouts, or a full sequence of FakeUserSpeech turns.

Observability: every call to recognize() posts to recognizeCh and every call to stream() posts the new stream to streamCh, so tests can assert on attempt counts directly instead of inferring them.

Example

const primary = new FakeSTT({ fakeException: new APIConnectionError('down') });
const fallback = new FakeSTT({ fakeTranscript: 'hello world' });
const adapter = new FallbackAdapter({ sttInstances: [primary, fallback] });
const ev = await adapter.recognize(frame);
assert(ev.alternatives[0].text === 'hello world');
assert((await primary.recognizeCh.next()).value instanceof RecognizeSentinel);

Hierarchy (view full)

Constructors

Properties

label: string

Accessors

  • get model(): string
  • Get the model name/identifier for this STT instance.

    Returns string

    The model name if available, "unknown" otherwise.

    Remarks

    Plugins should override this property to provide their model information.

  • get provider(): string
  • Get the provider name for this STT instance.

    Returns string

    The provider name if available, "unknown" otherwise.

    Remarks

    Plugins should override this property to provide their provider information.

Methods

  • Replace one or more fake knobs mid-test (e.g. flip from error to success).

    Parameters

    • opts: Partial<Pick<FakeSTTOptions, "fakeException" | "fakeTranscript" | "fakeTimeoutMs">>

    Returns void