!7 cmodule SpeechRecogConfirmation > DynPrintLogAndButtons { start { ownResource(onSpeechRecognized_withoutMyUtterancesAndTyped(voidfunc(fS s) enter { print("\nI heard: " + quote(s)); if (eq(s, "?")) { fS q = "Did you say anything?"; showButtons1(q, "", "Yes", r { log(s, q, 'yes); whatDidYouSay(s); }, "No", r { log(s, q, 'no); print("Thanks"); }); } else { fS q = "Did you say that?"; showButtons1(q, s, "Yes", r { log(s, q, 'yes); print("Thanks"); }, "No", r { log(s, q, 'no); whatDidYouSay(s); }); } })); } void log(S heard, S question, S answer) { print("> " + upper(answer)); logStruct(speechConfirmationLogFile(), litorderedmap(date := now(), +heard, +question, +answer)); hideButtons(); } void whatDidYouSay(fS heard) { S q = print("What did you say?"); VF1 f = voidfunc(S corrected) { corrected = trim(corrected); print("> I said " + (empty(corrected) ? "nothing" : quote(upper(corrected)))); logStruct(speechConfirmationLogFile(), litorderedmap(date := now(), +heard, +corrected)); hideButtons(); print("Thanks"); if (neq(heard, corrected)) dm_setAIBarTextAndFire(corrected); }; showButtons2(q, centerAndEastWithMargin(focusedTextFieldAndButton(heard, "is what I said", f), jbutton("X", r hideButtons)), textFieldAndButton(heard, "is what I said", f)); } void hideButtons { temp enter(); super.hideButtons(); dm_setTrayIcon_left(null); } void showButtons1(fS q, fS heard, O... params) { print(q); showButtons(params); JComponent tray = jPreferredSizeToFixedSize(buttonsAsfillerlessHStack_noSpacing(singlePlusArrayPlus(jlabel(q + " "), params, "X", r hideButtons))); final new Var disposer; bindToComponent(tray, r { temp enter(); disposer.set(vmBus_onMessage('topInputChanged, voidfunc(S s) { temp enter(); //print("Heard=" + heard + ", s=" + s); if (neq(s, heard)) dm_hideTrayIcon_left(); })); }, r { close(disposer!) }); dm_setTrayIcon_left(tray); } void showButtons2(S q, JComponent buttonsForTray, JComponent buttonsForMyWindow) { print(q); showButtons(buttonsForMyWindow); dm_setTrayIcon_left(jPreferredSizeToFixedSize(buttonsForTray)); } }