!7 module SpeechRecogConfirmation > DynPrintLogAndButtons { start { onSpeechRecognized_withoutMyUtterancesAndTyped(voidfunc(fS s) { print("\nI heard: " + quote(s)); if (eq(s, "?")) { fS q = "Did you say anything?"; showButtons(q, "Yes", r { log(s, q, 'yes); whatDidYouSay(s); }, "No", r { log(s, q, 'no); print("Thanks"); }); } else { fS q = "Did you say that?"; showButtons(q, "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)); logStructure(programLogFile(), litorderedmap(+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)))); logStructure(programLogFile(), litorderedmap(+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 showButtons(fS q, O... params) { print(q); super.showButtons(params); dm_setTrayIcon_left(jPreferredSizeToFixedSize(buttonsAsfillerlessHStack_noSpacing(singlePlusArrayPlus(jlabel(q), params, "X", r hideButtons)))); } void showButtons2(S q, JComponent buttonsForTray, JComponent buttonsForMyWindow) { print(q); super.showButtons(buttonsForMyWindow); dm_setTrayIcon_left(jPreferredSizeToFixedSize(buttonsForTray)); } }