Utterance lets you use Speech to Text in your Android Titanium projects. This uses android.speech.RecognizerIntent on Android.
var utterance = require('bencoding.utterance');
The Speech to Text proxy uses Android's underlying speech recognizer to convert speech into text. A new instance of this is created when you call createSpeechToText.
Example
var speech = utterance.createSpeechToText();
The startSpeechToText method will begin to listen to the user and recognize speech..
Parameters
The startSpeechToText method, takes a dictionary as a parameter with the following fields:
promptText : String :Required
The text of the message displayed on the Android recording screen.
maxResults : Int :Optional
The max number of matching results returned by the speech recognizer.
languageModel : Property :Optional
The language model used by the speech recognizer. The parameter uses properties on the speechToText proxy.
The value options are:
This method sets the speech pitch for the SpeechToText engine.
Example
if(!speechToText.isSupport()){
Ti.API.info("Your device does not support Speech to Text");
return;
}
speechToText.startSpeechToText({
promptText:"Say something interesting",
maxResults: 10,
languageModel : speechToText.LANGUAGE_MODEL_WEB_SEARCH
});
This method provides a boolean return if Speech to Text is support by the device.
Parameters
None
Example
if(speech.isSupport() === false){
Ti.API.info("Your device does not support Speech to Text");
}
started
This event is fired once the speech recognizer has started listening
Example
var utterance = require('bencoding.utterance'),
speech2Text = utterance.createSpeechToText();
speech2Text.addEventListener('started',function(d){
Ti.API.info(JSON.stringify(d));
});
completed
This event is fired once the speech recognizer has finished listening and has created text from the user's speech
Example
var utterance = require('bencoding.utterance'),
speech2Text = utterance.createSpeechToText();
speech2Text.addEventListener('completed',function(d){
Ti.API.info(JSON.stringify(d));
});
LANGUAGE_MODEL_WEB_SEARCH
This property can be used when setting the languageModel value for the startSpeechToText method. Use a language model based on web search terms.
LANGUAGE_MODEL_FREE_FORM
This property can be used when setting the languageModel value for the startSpeechToText method. Use a language model based on free-form speech recognition.
Utterance is available under the Apache 2.0 license.
Copyright 2014 Benjamin Bahrenburg
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.