cordova-plugin-speech-edited-wai
v0.1.7
Published
Cordova Plugin for Speech Recognition ios, Speech Recognition Extension
Downloads
1
Maintainers
Readme
cordova-plugin-speech
This is cordova plugin for Speech Recognition and Text to Speech.
Installation
cordova plugin add cordova-plugin-speech
Supported Platforms
- Android
- iOS
Usage
This plugin works with internet connection and without internet if language package available on device.
supportedLanguages
Speech.supportedLanguages
[]String
- Returns list of supported Speech to Text language models.
getSupportedVoices()
Speech.getSupportedVoices(Function successCallback, Function errorCallback)
Result of success callback is an Array of supported voices.
defaultLanguage
Speech.supportedLanguages
String
- Returns systems default Speech to Text language model.
speakOut()
let options = {
Number pitchRate,
Number speechRate,
String language
}
Speech.speakOut(String message, Function successCallback, Function errorCallback, Object options)
message
- {String} message for speaking.
Result of success callback is an String
of TTS states as below:
tts-start
States that TTS started.tts-end
States that TTS ended.
This method has an options parameter with the following optional values:
pitchRate
{Number} used for TTS pitch rate.
iOS
- The default pitch is 1.0. Allowed values are in the range from 0.5 (for lower pitch) to 2.0 (for higher pitch).Android
- The default pitch is 1.0, lower values lower the tone of the synthesized voice, greater values increase it.
speechRate
{Number} used for TTS speech rate.
iOS
- The default speech rate is 0.5. Lower values correspond to slower speech, and vice versa.Android
- The default speech rate is 1.0. Lower values correspond to slower speech, and vice versa.
language
{String} used for TTS speech voice.
iOS
- UseSpeech.getSupportedVoices()
to get voices and useselectedVoice.language
as input.Android
- UseSpeech.getSupportedVoices()
to get voices and useselectedVoice.name
as input.
initRecognition()
let options = {
String language
}
Speech.initRecognition(
Function successCallback, Function errorCallback, Object options)
Result of success callback is an Object
of recognition features as below:
offlineRecognitionAvailable
{Boolean} states that offline speech recognition is available or not. For Android it's values is always true.
This method has an options parameter with the following optional values:
language
{String} used language for recognition (default is systems default lanuguage model).
startRecognition()
let options = {
Boolean partialResultRequired,
Boolean offlineRecognitionRequired
}
Speech.startRecognition(
Function successCallback, Function errorCallback, Object options)
Result of success callback is an Object
of recognized terms:
isFinal
{Boolean} In case of partial result it isfalse
otherwise it'strue
.text
{String} Recognized text.
This method has an options parameter with the following optional values:
partialResultRequired
{Boolean} Allow partial results to be returned (defaultfalse
)offlineRecognitionRequired
{Boolean} Enables offline speech recognition if language model available (defaultfalse
)
There is a difference between Android and iOS platforms. On Android speech recognition stops when the speaker finishes speaking (at end of sentence). On iOS the user has to stop manually the recognition process by calling stopRecognition() method.
stopRecognition()
Speech.stopRecognition(
Function successCallback, Function errorCallback)
Stop the recognition process. Returns true
.
Android Quirks
Requirements
- cordova-android v5.0.0
- Android API level 14
- RECORD_AUDIO permission
Further readings
- https://developer.android.com/reference/android/speech/package-summary.html
- https://developer.android.com/reference/android/speech/SpeechRecognizer.html
iOS Quirks
Requirements
- XCode 8.0 (requires 10.12+ macOS Sierra or 10.11.5+ OS X El Capitan)
- iOS 10
- NSMicrophoneUsageDescription permission
- NSSpeechRecognitionUsageDescription permission
Further readings
- https://developer.apple.com/reference/speech?language=swift
- https://developer.apple.com/reference/speech/sfspeechrecognizer?language=swift
Author
Pravinkumar Putta
- https://github.com/pravinkumarputta
LICENSE
cordova-plugin-speech is licensed under the MIT Open Source license. For more information, see the LICENSE file in this repository.