const colours = "red, blue, green, black, white, gray, cyan, magenta, yellow,\n aqua, fuchsia, lime, maroon, navy, olive, purple, silver, teal"
function OnStart() {
app.SetVolume("System",0) ;
lay = app.CreateLayout( "linear", "VCenter,FillXY" );
txt = app.AddText( lay , "Night Light - say one of these colours\n"+colours, -1, -1 , "Multiline");
txt.SetBackColor("#666666") ;
txt.SetTextColor("#cccccc") ;
app.AddLayout( lay );
speech = app.CreateSpeechRec("NoBeep,Partial");
speech.SetOnReady( speech_OnReady );
speech.SetOnResult( speech_OnResult );
speech.SetOnError( speech_OnError );
speech.Recognize();
}
function speech_OnReady() {
}
function speech_OnError() {
speech.Recognize();
}
function speech_OnResult( results ) {
var r = results[0].toLowerCase() ;
if (colours.indexOf(r) != -1) { lay.SetBackColor(r); }
speech.Recognize();
}