Giter VIP home page Giter VIP logo

cordova-plugin-speech's Introduction

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.

defaultLanguage

Speech.supportedLanguages

String - Returns systems default Speech to Text language model.

speakOut()

let options = {
  Number pitchRate,
  Number speechRate
}

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 language 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 language 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.

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.

cordova-plugin-speech's People

Contributors

pravinkumarputta avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.