Speech Recognition
This plugin does speech recognition using cloud services
Repo: https://github.com/pbakondy/cordova-plugin-speechrecognition
Installation
- Install the Cordova and Ionic Native plugins:
$ ionic cordova plugin add cordova-plugin-speechrecognition $ npm install --save @ionic-native/speech-recognition@4
- Add this plugin to your app's module
Supported platforms
- Android
- iOS
Usage
import { SpeechRecognition } from '@ionic-native/speech-recognition';
constructor(private speechRecognition: SpeechRecognition) { }
...
// Check feature available
this.speechRecognition.isRecognitionAvailable()
.then((available: boolean) => console.log(available))
// Start the recognition process
this.speechRecognition.startListening(options)
.subscribe(
(matches: Array<string>) => console.log(matches),
(onerror) => console.log('error:', onerror)
)
// Stop the recognition process (iOS only)
this.speechRecognition.stopListening()
// Get the list of supported languages
this.speechRecognition.getSupportedLanguages()
.then(
(languages: Array<string>) => console.log(languages),
(error) => console.log(error)
)
// Check permission
this.speechRecognition.hasPermission()
.then((hasPermission: boolean) => console.log(hasPermission))
// Request permissions
this.speechRecognition.requestPermission()
.then(
() => console.log('Granted'),
() => console.log('Denied')
)
Instance Members
isRecognitionAvailable()
Check feature available
Returns: Promise<boolean>
startListening()
Start the recognition process
Returns: Promise< Array<string> >
list of recognized terms
stopListening()
Stop the recognition process
getSupportedLanguages()
Get the list of supported languages
Returns: Promise< Array<string> >
list of languages
hasPermission()
Check permission
Returns: Promise<boolean>
has permission
requestPermission()
Request permissions
Returns: Promise<void>