capacitor-plugin-speech-recognition
Capacitor plugin for speech recognition.
Install
npm install capacitor-plugin-speech-recognition
npx cap sync
iOS Platform: No further action required.
Android Platform: Register the plugin in your main activity:
import com.getcapacitor.community.speechrecognition.SpeechRecognition;
public class MainActivity extends BridgeActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
registerPlugin(SpeechRecognitionPlugin.class);
}
}
Configuration
No configuration required for this plugin
Supported methods
Name | Android | iOS | Web |
---|
available | ✅ | ✅ | ✅ |
start | ✅ | ✅ | ✅ |
stop | ✅ | ✅ | ✅ |
getSupportedLanguages | ✅ | ✅ | ✅ |
hasPermission | ✅ | ✅ | ✅ |
requestPermission | ✅ | ✅ | ✅ |
API
available()
available() => Promise<{ available: boolean; }>
Returns: Promise<{ available: boolean; }>
start(...)
start(options?: UtteranceOptions | undefined) => Promise<{ matches: string[]; }>
Returns: Promise<{ matches: string[]; }>
stop()
stop() => Promise<void>
getSupportedLanguages()
getSupportedLanguages() => Promise<{ languages: any[]; }>
Returns: Promise<{ languages: any[]; }>
hasPermission()
hasPermission() => Promise<{ permission: boolean; }>
Returns: Promise<{ permission: boolean; }>
requestPermission()
requestPermission() => Promise<void>
addListener('partialResults', ...)
addListener(eventName: 'partialResults', listenerFunc: (data: { matches: string[]; }) => void) => Promise<PluginListenerHandle> & PluginListenerHandle
Called when partialResults set to true and result received
Provides partial result.
Param | Type |
---|
eventName | 'partialResults' |
listenerFunc | (data: { matches: string[]; }) => void |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
Since: 2.0.2
Interfaces
UtteranceOptions
Prop | Type | Description |
---|
language | string | |
maxResults | number | |
prompt | string | |
popup | boolean | |
partialResults | boolean | |
noSpeechTimeout | number | for iOS only |
speechSilenceTimeout | number | |
PluginListenerHandle
Prop | Type |
---|
remove | () => Promise<void> |