ts-voice
v0.15.0
Published
Browser-based voice AI: **Whisper** (Transformers.js) for speech-to-text, **Kokoro** and **Supertonic** (ONNX) for text-to-speech, plus **Web Speech API** and **external HTTP** providers. Includes an embeddable **`<voice-chatbot>`** with a queued TTS pipe
Downloads
190
Readme
ts-voice
Browser-based voice AI: Whisper (Transformers.js) for speech-to-text, Kokoro and Supertonic (ONNX) for text-to-speech, plus Web Speech API and external HTTP providers. Includes an embeddable <voice-chatbot> with a queued TTS pipeline.
Installation
npm install ts-voiceProgrammatic usage
import { createSTT, createTTS } from 'ts-voice';
const stt = createSTT({ provider: 'whisper' });
await stt.initialize();
await stt.start();
const text = await stt.stop();
const tts = createTTS({ provider: 'kokoro' });
await tts.initialize();
await tts.speak('Hello, world!');docs/providers.md — all providers, external HTTP contracts, deprecated transformers aliases, and when to call tts.initialize() (Kokoro/Supertonic: early init avoids a long stall on the first speak(); omitting it defers the download until the first utterance).
Web component
import { registerVoiceChatbotElement } from 'ts-voice';
registerVoiceChatbotElement();<voice-chatbot stt-provider="whisper" tts-provider="kokoro"></voice-chatbot>docs/voice-chatbot.md — attributes, responseHandler, initialize(), fallback chains, defaults, and what cannot be set from HTML alone.
docs/README.md — doc index.
Examples: examples/component — <voice-chatbot> Vite demos. examples/direct-api — minimal createSTT / createTTS page (no web component).
ONNX Runtime (WASM)
All ONNX-backed providers share one pinned onnxruntime-web version and load
its WASM from jsDelivr by default, so each browser downloads the binary
once per version. CSP: allow cdn.jsdelivr.net plus your model hosts
(e.g. Hugging Face). See docs/ort.md if you need to
self-host.
Development
npm run build # Compile to dist/
npm test # Unit tests
npm run verify # Lint + unit tests
npm run test:e2e # Playwright (starts example dev server on 4173)npm run verify (from repo root, after npm install) runs TypeScript checking and unit tests. It does not run Playwright e2e; use npm run test:e2e for that.
Examples without cd
From repo root, after npm install, npm run build, and installing example deps once:
Web component:
npm install --prefix examples/component
npm --prefix examples/component run devOptional: npm --prefix examples/component run dev -- --port 5173
Direct API (createSTT / createTTS):
npm install --prefix examples/direct-api
npm --prefix examples/direct-api run devLicense
MIT
