// Note: This program continuously requires bandwidth while running. // It will also keep running in the background, even with the display // off. Press "STOP" or swipe the JavaX app away in the task switcher // to terminate. !7 import android.graphics.Color; static TextView tv, tvStatus; static ScrollView tvScroll; static ContinuousEnglishRecognition rec; please include function aContinuousEnglishRecognition. p { makeBot("Recognizer."); makeMyselfAware(); androidUI(r { tvStatus = aTextView("Preparing..."); tvStatus.setTextSize(20); tvStatus.setGravity(Gravity.CENTER); tvStatus.setTextColor(Color.RED); tv = aTextView(); tv.setTextSize(40); tv.setGravity(Gravity.CENTER); tv.setTextColor(Color.BLACK); androidShow(aNorthCenterAndSouth( tvStatus, tvScroll = ascroll(tv), aButton("STOP", f stop))); }); rec = new ContinuousEnglishRecognition; rec.onSpeech = f onSpeech; rec.onReady = r { aSetText(tvStatus, "Listening.") }; rec.onUnready = r { aSetText(tvStatus, "Hold on...") }; rec.start(); } sS last = ""; static long time; static void onSpeech(L l) { S s = first(l); //S ss = dropPrefixTrim(last, s); S ss = joinLines(takeLast(12, javaTokC(s))); last = s; time = now(); print("> " + ss); if (nempty(ss)) { aSetText(tv, ss); tvScroll.post(r { tvScroll.fullScroll(ScrollView.FOCUS_DOWN) }); } } svoid stop { rec.stop(); rec = null; } answer { if "text" ret now() + ": " + last; }