!7 sclass SpeechRecognizer > DynSingleFunction { transient new Flag flag; start { setFunctionName("Start listening"); } void startListening { doIt(false); } void justOnce { doIt(true); } void doIt { doIt(false); } void doIt(bool justOnce) { temp enter(); if (sendOpt("Chrome Speech.", justOnce ? "just once" : "start recognition") == null) { print("Starting recognizer"); fO recognizer = hotwireDependent(#1009816); set(recognizer, doLog := false); set(recognizer, onUtterance := voidfunc(S utterance) { flatInfoBox(utterance); dm_setAIBarTextAndFireWithInfo(utterance, "Chrome Speech"); /*if (ai_isStopListeningCommand(utterance)) { call(recognizer, 'stopRecognition); playBlip(); }*/ }); set(recognizer, +justOnce); if (flag.raise()) dm_putRecognizedSpeechInAIBar(); runMain(recognizer); } } }