Skip to content

Getting started

Requirements

  • Node.js 20 or newer
  • For a real offline setup: whisper.cpp, Ollama and Piper — see setup.md. You can develop and test with the mock engines without installing anything.

Install

npm install whispa

The loop

VoicePipeline runs audio → text → LLM → text → audio and keeps conversation history so a whole spoken turn is one call:

import { VoicePipeline, WhisperCppStt, OllamaLlm, PiperTts } from 'whispa';

const pipeline = new VoicePipeline({
  stt: new WhisperCppStt({ model: 'models/ggml-base.en.bin' }),
  llm: new OllamaLlm({ model: 'llama3.2' }),
  tts: new PiperTts({ model: 'voices/en_US-amy-medium.onnx' }),
  systemPrompt: 'You are a concise voice assistant.',
  maxHistory: 20,
});

const { transcript, reply, audio } = await pipeline.turn('recording.wav');

Individual steps

const text = await pipeline.listen('recording.wav'); // STT
const reply = await pipeline.respond(text);          // LLM (updates history)
const wav = await pipeline.speak(reply);             // TTS

Develop without native tools

import { VoicePipeline, MockStt, EchoLlm, MockTts } from 'whispa';
const p = new VoicePipeline({ stt: new MockStt('hi'), llm: new EchoLlm(), tts: new MockTts() });

Run from source

git clone https://github.com/marcelogdomingues/whispa
cd whispa
npm install
npm run demo
npm test