0.1.4 • Published 3 years ago
@morphood/capacitor-plugin-speech-recognition v0.1.4
capacitor-plugin-speech-recognition
Capacitor plugin for speech recognition.
Install
npm install capacitor-plugin-speech-recognition
npx cap synciOS 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);
// Initializes the Bridge
registerPlugin(SpeechRecognitionPlugin.class);
}
}Configuration
No configuration required for this plugin
Supported methods
| Name | Android | iOS | Web |
|---|---|---|---|
| available | ✅ | ✅ | ✅ |
| start | ✅ | ✅ | ✅ |
| stop | ✅ | ✅ | ✅ |
| getSupportedLanguages | ✅ | ✅ | ✅ |
| hasPermission | ✅ | ✅ | ✅ |
| requestPermission | ✅ | ✅ | ✅ |
API
available()start(...)stop()getSupportedLanguages()hasPermission()requestPermission()addListener('partialResults', ...)- Interfaces
available()
available() => Promise<{ available: boolean; }>Returns: Promise<{ available: boolean; }>
start(...)
start(options?: UtteranceOptions | undefined) => Promise<{ matches: string[]; }>| Param | Type |
|---|---|
options | UtteranceOptions |
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> & PluginListenerHandleCalled 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> |