window.require=function(path){
return eval("(function(){"+app.ReadFile(path).replace(/\n|\s\s|\t/gm,'')+";return this;})();");
}
window.AI=function(){
app.SetVolume("music",0);
app.SetVolume("system",1);
this.speechRec=app.CreateSpeechRec("Parxtial");
this.speechRec.SetOnError(function(){
if(!AI.speechRec.IsListening()) AI.listen();
});
this.speechRec.SetOnResult(AI.speechCallback);
this.listen=function(callback){
if(callback) AI.speechCallback=callback;
AI.speechRec.Recognize("BN");
}
this.speak=function(speech,callback){
if(callback==undefined) callback=AI.listen;
app.TextToSpeech(speech,1,1,callback,"system","bn_BD");
}
}
var $time=require("lib/plugins/time.js");
AI.speechCallback=function(speech){
var speech=speech.toString().toLowerCase();
var match=function(voice){return speech.indexOf(voice)>-1;}
var matchAny=function(voices){let exist=false;for(voice in voices){if(speech.indexOf(voice)>-1) exist=true;};return exist;}
var matchAll=function(voices){let exist=true;voices.forEach(voice=>{if(!speech.indexOf(voice)>-1) exist=false;});return exist;}
console.log(speech);
switch(true){
case match("hello"):
AI.speak("hello");
break;
//Time
case (matchAny(["kotha","koita","kot","koi ta"]) && matchAny(["baje","baji"])):
AI.speak($time.getTime());
break;
case (match("aj") && matchAny(["bar","baat","baar"])):
AI.speak($time.getDay());
break;
case (match("kon") && matchAny(["mass","mash"])):
AI.speak($time.getMonth());
break;
case (match("aj") && match("tarik")):
AI.speak($time.getDate());
break;
default:
AI.listen();
break;
}}