vosk-offline-speech-recognition
v1.0.5
Published
Offline speech recognition
Downloads
297
Readme
vosk-offline-speech-recognition
Capacitor Plugin for Ionic - Offline Speech Recognition with Vosk Android
This project uses the Vosk Android library, which is licensed under the Apache License 2.0.
Requirements
You will need to download the Vosk models from the following link:
- Download the smallest Portuguese model:
vosk-model-small-pt-0.3
- Rename the model to
vosk-model-small-pt
. - Place the model in the following directory:
yourIonicApp\android\app\src\main\assets
Install
npm i vosk-offline-speech-recognition
npx cap sync
API
startListening()
stopListening()
pauseListening()
resumeListening()
isListening()
available()
requestPermissions()
addListener('partialResult', ...)
addListener('onResult', ...)
removeAllListeners()
- Interfaces
- Type Aliases
startListening()
startListening() => Promise<void>
stopListening()
stopListening() => Promise<void>
pauseListening()
pauseListening() => Promise<void>
resumeListening()
resumeListening() => Promise<void>
isListening()
isListening() => Promise<{ isListening: boolean; }>
Returns: Promise<{ isListening: boolean; }>
available()
available() => Promise<{ available: boolean; }>
Returns: Promise<{ available: boolean; }>
requestPermissions()
requestPermissions() => Promise<PermissionStatus>
Returns: Promise<PermissionStatus>
addListener('partialResult', ...)
addListener(eventName: 'partialResult', listener: (data: { matches: string; }) => void) => Promise<PluginListenerHandle>
| Param | Type |
| --------------- | ---------------------------------------------------- |
| eventName
| 'partialResult' |
| listener
| (data: { matches: string; }) => void |
Returns: Promise<PluginListenerHandle>
addListener('onResult', ...)
addListener(eventName: 'onResult', listener: (data: { result: string; }) => void) => Promise<PluginListenerHandle>
| Param | Type |
| --------------- | --------------------------------------------------- |
| eventName
| 'onResult' |
| listener
| (data: { result: string; }) => void |
Returns: Promise<PluginListenerHandle>
removeAllListeners()
removeAllListeners() => Promise<void>
Interfaces
PermissionStatus
| Prop | Type | Description |
| ----------------------- | ----------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| speechRecognition
| PermissionState | Permission state for speechRecognition alias. On Android it requests/checks RECORD_AUDIO permission On iOS it requests/checks the speech recognition and microphone permissions. |
PluginListenerHandle
| Prop | Type |
| ------------ | ----------------------------------------- |
| remove
| () => Promise<void> |
Type Aliases
PermissionState
'prompt' | 'prompt-with-rationale' | 'granted' | 'denied'