Code Monkey home page Code Monkey logo

speechrecognizer's Introduction

Android SpeechRecognizer plugin for Cordova/Phonegap

This plugin provides access to the speech recognition feature. This plugin will recognize commands, phrases, etc as spoken by the user.

Screenshot speak now

If you find this plugin useful, please donate via BitCoin to support it:
17JK27E4vbzPrJbBAtvjUVN3LrFcATtRA1

Requirements

Android 2.2 (API level 8) is required
Compatible with Cordova 3.0.

android:launchMode CANNOT be "singleInstance"

It can be eventually "singleTask" (or "standard", "singleTop")

Support

For free community support, please use the issue tracker.
To get professional non-free support for the plugin, please contact me at gcharhon(at)smartmobilesoftware.com.

Installation for cordova>=3.0.0 (tested 3.1.0, 3.4.0, 6.0.0)

cordova create buz
cd buz
cordova platform add android
cordova plugin add https://github.com/poiuytrez/SpeechRecognizer

Usage

Start recognition

Show the recognition dialog and get the recognized sentences

SpeechRecognizer.startRecognize(success, error, maxMatches, promptString, language);

parameters

  • success : The success callback. It provides a json array with all possible matches. Example: "[hello world,low world,hello walls]".
  • error : The error callback.
  • maxMaches : Maximum of returned possibles sentences matches.
  • promptString : String shown below the Google logo and the microphone icon. Instruct the user of what to. Example: "Speak now"
  • language : Language used by the speech recognition engine. Example: "en-US".

Supported languages

Get the list of supported languages codes

SpeechRecognizer.getSupportedLanguages(success, error);

parameters

  • success : The success callback. It provides a json array of all the recognized language codes. Example: "[en-US,fr-FR,de-DE]".
  • error : The error callback.

Full example

<!DOCTYPE html>
<html>
    <head>
        <title>Speech Recognition plugin demo</title>
        <script type="text/javascript" src="cordova.js"></script>
    </head>
    <body>

        <script type="text/javascript">

            function onDeviceReady(){
                console.log("Device is ready");
            }

            function recognizeSpeech() {
                var maxMatches = 5;
                var promptString = "Speak now";	// optional
                var language = "en-US";						// optional
                window.plugins.speechrecognizer.startRecognize(function(result){
                    alert(result);
                }, function(errorMessage){
                    console.log("Error message: " + errorMessage);
                }, maxMatches, promptString, language);
            }

            // Show the list of the supported languages
            function getSupportedLanguages() {
                window.plugins.speechrecognizer.getSupportedLanguages(function(languages){
                    // display the json array
                    alert(languages);
                }, function(error){
                    alert("Could not retrieve the supported languages : " + error);
                });
            }

            // Check to see if a recognition activity is present
            function checkSpeechRecognition() {
                window.plugins.speechrecognizer.checkSpeechRecognition(function(){
                    alert('Speech Recogition is present! :D');
                }, function(){
                    alert('Speech Recogition not found! :(');
                });
            }

            document.addEventListener("deviceready", onDeviceReady, true);
        </script>

        <button onclick="recognizeSpeech();">Start recognition</button>
        <button onclick="getSupportedLanguages();">Get Supported Languages</button>
        <button onclick="checkSpeechRecognition();">Check Speech Recognition</button>
    </body>
</html>

License

The MIT License

Copyright (c) 2011-2013
Colin Turner (github.com/koolspin)
Guillaume Charhon (github.com/poiuytrez)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

speechrecognizer's People

Contributors

poiuytrez avatar avgp avatar tashemi avatar pwqw avatar luigi37 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.