Skip to content

pravinkumarputta/cordova-plugin-speech

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cordova-plugin-speech

npm Platform

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.
  1. 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).
  2. 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.
  1. iOS - The default speech rate is 0.5. Lower values correspond to slower speech, and vice versa.
  2. Android - The default speech rate is 1.0. Lower values correspond to slower speech, and vice versa.
  • language {String} used for TTS speech voice.
  1. iOS - Use Speech.getSupportedVoices() to get voices and use selectedVoice.language as input.
  2. Android - Use Speech.getSupportedVoices() to get voices and use selectedVoice.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 is false otherwise it's true.
  • text {String} Recognized text.

This method has an options parameter with the following optional values:

  • partialResultRequired {Boolean} Allow partial results to be returned (default false)
  • offlineRecognitionRequired {Boolean} Enables offline speech recognition if language model available (default false)

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

iOS Quirks

Requirements

Further readings

Author

Pravinkumar Putta

LICENSE

cordova-plugin-speech is licensed under the MIT Open Source license. For more information, see the LICENSE file in this repository.

About

cordova-plugin-speech

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published