The SpeechRec object can be used to listen for and recognize speech.
spr = app.CreateSpeechRec(
→ app object:
Use the Recognize method of the SpeechRec object to tell it to start listening:
When the SpeechRec object has started listening, the OnReady callback function will be called. Use the SetOnReady method to set the name of your OnReady callback function.
If the SpeechRec object recognizes speech, the OnResult callback function will be called. The results are passed to the OnResult callback function as an array, with the most probable result at the front. Use the SetOnResult method to set the name of your OnResult callback function.
If the SpeechRec object does not recognize anything, the OnError callback function will be called. Use the SetOnError method to set the name of your OnError callback function.
Example - Example
lay = app.CreateLayout( "linear", "VCenter,FillXY" );
btn = app.CreateButton( "Talk To Me", 0.3, 0.1 );
btn.SetOnTouch( btn_OnTouch );
lay.AddChild( btn );
app.AddLayout( lay );
speech = app.CreateSpeechRec();
speech.SetOnReady( speech_OnReady );
speech.SetOnResult( speech_OnResult );
speech.SetOnError( speech_OnError );
app.ShowPopup( "Listening...", "Short" );
function speech_OnResult( results )
app.ShowPopup( results );
app.ShowPopup( "Please speak more clearly!" );
The following methods are available on the SpeechRec object:
string: comma “,” separated: “NoBeep”, “Partial”
Stop recognizing speech and break other processes.
Returns the RMS value (Root Mean Square) from the audio recorder.
Returns the control class name.
Check whether SpeechRec is currently listening.
Allows access to other functions defined on the object in Java via reflection.
Note: This function is a premium feature. Please consider subscribing to Premium to use this feature and support DroidScript in its further development.
Start recognizing speech.
Define a callback function which is called when an error occured.
Define a callback function which is called when the SpeechRec object is ready for use.
Define a callback function which is called when a text was successfully recognized
Stop speech recording and start recognizing.