Back

CreateSpeechRec

SpeechRec creates a SpeechRec object to listen for and recognise speeches.

app.CreateSpeechRec( options ) -> app object - SpeechRec

Example - Example



function OnStart()
{
    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 );
}

function btn_OnTouch()
{
    speech.Recognize();
}

function speech_OnReady()
{
    app.ShowPopup( "Listening...", "Short" );
}

function speech_OnResult( results )
{
    app.ShowPopup( results[0] );
}

function speech_OnError()
{
    app.ShowPopup( "Please speak more clearly!" );
}
    Copy     Copy All       Run      

The following methods are avaiable on the SpeechRec object:

  Cancel()
  Destroy()
  GetRMS() -> number - float
  GetType() -> string - "SpeechRec"
  IsListening() -> boolean
  Recognize()
  Release()
  Stop()
  id -> string - "#id"

string - "NoBeep"
stop recognision
destroys object
?
returns wether speechRec is listening
start speech recognizion
?
function( error )
function()
function( result )
Stop speech recognizion
object id