speechrecognizer Module allows you to use full features of Android SpeechRecognizer API.
You can
-
use three actions of Free Form, Web search and Hands free.
-
select the language from many languages which SpeechRecognizer service supports.
-
receive all events from SpeechRecognizer service (error, changeRms etc.)
-
check the supported features of Android device that SpeechRecognizer module is running on.
-
do safely everything because of SpeechRecognizer module handles the differrce of API Lavels (currently support API Level 8-16)
-
make your own custom UI design for SpeechRecognize. SpeechRecognizer module uses direct mode of SpeechRecognizer API.
Android min-sdk: Android 2.2 (API Level 8) Titanium 2.1.0.GA
To access this module from JavaScript, you would do the following:
var speechrecognizerModule = require("jp.isisredirect.speechrecognizer");
The speechrecognizerModule variable is a reference to the Module object.
To create speechrecognizer object from JavaScript, you would do the following:
var speechrecognizer = speechrecognizerModule.createSpeechRecognizer();
The speechrecognizer variable is a reference to the SpeechRecognizer object.
speechrecognizerModule object is coresponding to the static methods on SpeechRecognizer API.
On the other hand, SpeechRecognizer object is coresponding to the non static methods.
Whether Android device supports SpeechRecognizer.
- void
- Boolean
true if Android device supports SpeechRecognizer.
Whether Android device supports Voice Search Hands Free feature.
- void
- Boolean
true if Android device supports Voice Search Hands Free feature.
Requests the language informations supported by SpeechRecognizer.
This method's result is priovided by languagedetails event.
- void
- void
More technical details is here:
create SpeechRecognizer object.
- parameters: Dictionary<SpeechRecognizer> (optional)
Properties to set on a new object, including any defined by SpeechRecognizer
- SpeechRecognizer object
Fired when the results of speechrecognizerModule.getLanguageDetails() are ready after required by speechrecognizerModule.getLanguageDetails().
- source : Object
Source object that fired the event.
- type : String
Name of the event fired.
- language_preference : String
represents the current language preference this user has specified - a locale string like "en-US".
- supported_languages : Array of Strings
represents the languages supported by this implementation of voice recognition - a Array of strings like "en-US", "cmn-Hans-CN", etc.
specifies the action of SpeechRecognizer.
there are three actions
1: Speech
2: Web search
3: Voice Search Hands Free
More technical details is here:
http://developer.android.com/reference/android/speech/RecognizerIntent.html#ACTION_RECOGNIZE_SPEECH
http://developer.android.com/reference/android/speech/RecognizerIntent.html#ACTION_WEB_SEARCH
informs the recognizer to perform speech recognition in a language.
You can use one of supported_languanges property of languagedetails event.
Android device setting
Informs the recognizer which speech model to prefer when performing action.
available values are :
-
"freeform" (speechrecognizerModule.FREEFORM predefined)
-
"websearch" (speechrecognizerModule.WEBSEARCH predefined)
"freeform"
specifies limit on the maximum number of results to return when performing action.
1
indicate whether partial results should be returned by the recognizer as the user speaks.
false
be used with action web search, to indicate whether to only fire web searches in response to a user's speech.
(note : this property may have no effect in this time. Because of direct mode recognition used in module, or the implementation of the recognizer service on current Android device.
false
can be used with action web search to indicate the referer url of a page in which speech was requested.
(note : this property may have no effect in this time. Because of direct mode recognition used in module, or the implementation of the recognizer service on current Android device.
""
indicates that a "hands free" voice search was performed while the device was in a secure mode
Starts listening for speech.
- void
- void
Cancels the speech recognition.
- void
- void
Stops listening for speech.
- void
- void
release recognizer resources.
- void
- void
gets error message from error code which is provided in error event.
- error:Number
error code received in error event.
- String
error string that is correcponding to error code.
- source : Object
Source object that fired the event.
- type : String
Name of the event fired.
The user has started to speak.
- source : Object
Source object that fired the event.
- type : String
Name of the event fired.
More sound has been received.
The purpose of this function is to allow giving feedback to the user regarding the captured audio.
There is no guarantee that this method will be called (depend on implementation of the recognizer service).
- source : Object
Source object that fired the event.
- type : String
Name of the event fired.
The sound level in the audio stream has changed. There is no guarantee that this method will be called. There is no guarantee that this method will be called (depend on implementation of the recognizer service).
- source : Object
Source object that fired the event.
- type : String
Name of the event fired.
- rmsdb : float
the new RMS dB value
Called after the user stops speaking.
- source : Object
Source object that fired the event.
- type : String
Name of the event fired.
A network or recognition error occurred.
- source : Object
Source object that fired the event.
- type : String
Name of the event fired.
- error: Number
error code
Reserved for adding future events.
- source : Object
Source object that fired the event.
- type : String
Name of the event fired.
Called when partial recognition results are available.
- source : Object
Source object that fired the event.
- type : String
Name of the event fired.
- results: Array of Strings
the possible recognition results, where the first element is the most likely candidate.
- confidence_scores : Array of floats
same size array as results, includes the confidence score of each result.
This value is optional and might not be provided.
The confidence score is ranging from 0.0 to 1.0, or -1 to represent an unavailable confidence score.
More technicall details :
http://developer.android.com/reference/android/speech/SpeechRecognizer.html#CONFIDENCE_SCORES
Called when recognition results are ready.
- source : Object
Source object that fired the event.
- type : String
Name of the event fired.
- results: Array of Strings
the possible recognition results, where the first element is the most likely candidate.
- confidence_scores : Array of floats
same size array as results, includes the confidence score of each result.
This value is optional and might not be provided.
The confidence score is ranging from 0.0 to 1.0, or -1 to represent an unavailable confidence score.
More technicall details :
http://developer.android.com/reference/android/speech/SpeechRecognizer.html#CONFIDENCE_SCORES
The most simply example of usage of SpeechRecoginither module is below:
var speechrecognizerModule = require('jp.isisredirect.speechrecognizer');
Ti.API.info("module is => " + speechrecognizerModule);
var speechrecognizer = speechrecognizerModule.createSpeechRecognizer();
Ti.API.info("proxy is => " + speechrecognizer);
speechrecognizer.addEventListener(speechrecognizerModule.READYFORSPEECH, function(e) {
// notify to user that Recognize is ready
});
speechrecognizer.addEventListener(speechrecognizerModule.BEGINNINGOFSPEECH, function(e) {
// notify to user that Recognizer detected user's voice
});
speechrecognizer.addEventListener(speechrecognizerModule.RESULTS, function(e) {
// recognized results in e.results
});
speechrecognizer.start();
For more deep usage, you see /example/app.js
Kastumi ISHIDA (isis re-direct) in k.i.office.
Copyright (c) 2013 Katsumi ISHIDA. All rights reserved.
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.