Android Text to Speech and Speech to Text

The latest version of Ti.Utterance adds Android support for both Text to Speech and Speech to Text.  The Ti.Utterance native module surfaces the native platform APIs for Text to Speech, and on Android now Speech to Text.

Text to Speech

The Speech proxy provides your Titanium apps Text to Speech capabilities on both iOS and Android.  Ti.Utterance uses AVSpeechUtterance on iOS and android.speech.tts.TextToSpeech on Android.  This enables you to provide the Ti.Utterance module with a string, such as “hello world” for the module to speak.

To learn more about Text to Speech please read the documentation:

Sample

Full example available here.


var utterance = require('bencoding.utterance'),
	textToSpeech = utterance.createSpeech();

textToSpeech.startSpeaking({
	text:"Hello World"
});	

Speech to Text

The SpeechToText proxy is available on Android and provides Speech to Text capabilities using your device’s native platform speech recognizer.  When the startSpeechToText method is called, a microphone dialog will appear and listen for input from the user.  When the user stops speaking, Android’s speech recognizer will convert what was said into one or more text phrases.  If Android is not fully able to match was is said, the speech recognizer will provide a list of options in the order it feels is the best match.

To learn more about Speech to Text  please read the documentation:

Sample

Full example available here.


var utterance = require('bencoding.utterance'),
	speechToText = utterance.createSpeechToText();

speechToText.startSpeechToText({
	promptText:"Say something interesting",
	maxResults: 10
});

speechToText.addEventListener('completed',function(e){

	if(e.success && (e.wordCount > 0)){
		alert("Speech Recognized "
				+ e.wordCount
				+ " matches found: "
				+ JSON.stringify(e.words));
	}else{
		alert("Unable to recognize your speech");
	}

});

The Demo