@ishant89/vosk-speech-kit
v0.1.2
Published
Offline Vosk speech-to-text for React Native (iOS) — wraps VoskSpeechKit.
Maintainers
Readme
@ishant89/vosk-speech-kit (React Native)
Offline Vosk speech-to-text for React Native (iOS). Thin bridge over the native VoskSpeechKit Swift core.
Install
npm install @ishant89/vosk-speech-kit
cd ios && pod installThe native core (VoskSpeechKit, which vendors libvosk) resolves automatically
from CocoaPods — it's a dependency of this package's podspec, so no extra Podfile
entry is needed.
Add the model (required)
The model is not shipped. Bundle it with your iOS app:
- Get a model (https://alphacephei.com/vosk/models), unzip so it has
am/ conf/ graph/. - Drag the
atc-lgraph-v10/folder into your Xcode project as a folder reference (blue folder), e.g. under aModels/group. - At runtime, resolve its on-device path and load it.
Usage
import VoskSpeech from '@ishant89/vosk-speech-kit';
import { MainBundlePath } from 'react-native-fs';
const info = await VoskSpeech.loadLatestModel(`${MainBundlePath}/Models`); // or loadModel(exactPath)
VoskSpeech.onPartialResult(t => console.log('partial', t));
const sub = VoskSpeech.onResult(t => console.log('result', t));
await VoskSpeech.start(); // optional grammar: string[]
// …
VoskSpeech.stop();
sub.remove();API: loadModel, loadLatestModel, availableModels, engineVersion, start,
stop, unload, onPartialResult, onResult, onError. iOS only for now.
