Skip to content

@ariontalk/engine-local

@ariontalk/engine-local is the on-device engine. It uses Chrome’s built-in Prompt API (Gemini Nano) for answers and the Web Speech API for recognition and synthesis, so it needs no server or API key. The widget uses it when engine="local", which is the default.

Installation

Terminal window
pnpm add @ariontalk/core @ariontalk/engine-local

@ariontalk/core is a peer dependency.

VoiceEngine

import { VoiceEngine } from '@ariontalk/engine-local';
const engine = new VoiceEngine({ interactiveHighlights: true });
await engine.startSession('en');

Implements VoiceEngineInterface from @ariontalk/core.

Constructor options

interface VoiceEngineOptions {
/** Detects when the visitor starts talking over the agent. Without one, interruptions are off. */
bargeInDetector?: BargeInDetector;
/** Replaces the browser's speech synthesis, for example with kokoroTtsPlugin(). */
synthesizer?: SpeechSynthesizer;
/** Scroll to and highlight the section or image being discussed. */
interactiveHighlights?: boolean;
/** On-device speech recognition policy: 'prefer' (default), 'require' or 'off'. */
speechLocal?: SpeechLocalMode;
/** Share page images with the model when the browser supports it. Requires interactiveHighlights. Default: true. */
imageContext?: boolean;
}

Capabilities

CapabilityValue
supportedLanguages['auto', 'en', 'es']
supportsVoiceSelectiontrue
supportsRatePitchVolumetrue
supportsBargeInPluginstrue
supportsTtsPluginstrue
supportsOfflinetrue
maxSessionDurationSecnull (unlimited)
requiresTokenServerfalse

Services

Lower-level building blocks, exported for advanced use.

ServiceDescription
AISessionServiceWraps Chrome’s Prompt API (LanguageModel): availability, model download progress and streaming responses.
SpeechRecognitionServiceWraps the Web Speech API’s SpeechRecognition for continuous voice input, with on-device recognition when available.
SpeechSynthesisServiceWraps the Speech Synthesis API with language-aware voice selection. Prefers local voices.
InputLevelMeterSamples the microphone input level with the Web Audio API, for voice-reactive visuals.

Types

type SpeechLocalMode = 'prefer' | 'require' | 'off';
type SpeechLocalStatus = 'on-device' | 'cloud' | 'downloading' | 'unavailable';

See Local Engine for browser requirements and how the pipeline works.