I'm new here and if you wondering why my english is so bad, I'm from Germany.
So yesterday I start working with droidscript and tried to make an digital assistant.
function OnStart()
{
lay = app.CreateLayout( "Linear", "VCenter,FillXY" );
img = app.CreateImage( "Img/tech.jpg", 1.0, 1.2);
lay.AddChild( img );
app.AddLayout( lay );
var s = "<u>Commands</u><br><br>"
+ "\"Computer?\"<br>"
+ "\"What time is it?\"<br>"
+ "\"What day is it?\"<br>"
+ "\"How are you?\"<br>"
+ "\"Exit\"<br>";
txt = app.CreateText( s, 0.9, 0.8, "Multiline,Html" );
txt.SetTextSize( 18 );
lay.AddChild( txt );
speech = app.CreateSpeechRec("Parxtial");
speech.SetOnResult( spracherfassung );
speech.SetOnError( speech_OnError );
app.TextToSpeech( "Hello!", 0.8, 1.3, Listen, "music" );
app.ShowProgress();
}
function Listen()
{
//app.HideProgress();
speech.Recognize();
}
function spracherfassung( results )
{
var cmd = results[0].toLowerCase();
if( cmd.indexOf("computer") > -1.1)
{
app.TextToSpeech( "What can I do for you?", 0.6, 1.3, Listen, "music" );
speech.SetOnError();
}
else speech.Recognize();
}
function speech_OnError( error )
{
console.log( "Error" + error );
if( !speech.IsListening() ) speech.Recognize();
}
it does not answer. But thats not the problem. If I do it with the 1.1 it repeats the answer the whole time, until I end the app.
It would be nice, if you could help me. Thanks!