voxxy

Speech to text
and back.

voxxy is a TypeScript library that runs speech recognition and synthesis on the device using web APIs.

See code examples

Try voice chat

Suggested question

Enable voice to download the English models.

Speech engines

Choose your speech providers

Pick one provider for recognition and another for synthesis. Your app asks for download consent and decides how to show progress and playback controls.

  1. Audio in

    Speech to text

    Pass microphone audio to the recognition provider and get a transcript.

  2. Text in and out

    Your application

    Use the transcript in a form, run a command or send it to an LLM.

  3. Audio out

    Text to speech

    Speak a finished response or play sentences as text streams in.

Quickstart

Run either example here, or copy it as index.html in a Vite project.

npm install voxxy v0.1.2

GitHub releases
Run locally
  1. For a new project, run npm init -y and npm install -D vite@8.
  2. Run npm install voxxy.
  3. Save the copied snippet as index.html, run npx vite, and open the localhost URL.

For a preview build, download voxxy.tgz and run npm install ./voxxy.tgz.

Write a speech adapter

Implement SttAdapter or TtsAdapter from voxxy to run your own speech engine in a worker.

Host the adapter with serveStt or serveTts from voxxy/serve. In your app, create a provider with workerStt or workerTts and pass it to voice.select().

For an engine that handles recording or playback itself, implement SttProvider or TtsProvider from voxxy and select it directly.

Worker adapter interfaces
import type { AdapterLoadContext } from "voxxy";

interface SttAdapter {
  readonly id: string;
  load(context?: AdapterLoadContext): Promise<void>;
  transcribe(
    pcm16k: Float32Array,
    signal?: AbortSignal,
  ): Promise<string>;
  dispose(): Promise<void>;
}

interface TtsAdapter {
  readonly id: string;
  load(context?: AdapterLoadContext): Promise<void>;
  synthesize(
    text: string,
    signal?: AbortSignal,
  ): Promise<{ pcm: Float32Array; sampleRate: number }>;
  dispose(): Promise<void>;
}

Recognition receives mono 16 kHz PCM. Synthesis returns PCM and its sample rate. Use the supplied abort signal to cancel work.