!7 static JLabel l; static Map consequentsMap = synchroCIMap(), precedentsMap = synchroCIMap(); static Set ignoreSet = asCISet(splitAtVerticalBar("english|englisch|german|deutsch")); sS answer; static L> receivers; static JButton btnSay; p-noconsole-autoupdate { startBotInSeparateVM("Katze.", #1013936); final JFrame frame = frameIcon(#1101166, showMaximizedFrame(jscroll_verticalExtend_trackWidth( //jTiledBackground(#1007195, setForeground(Color.white, jCenteredBackgroundImage(#1101166, setBackground(awtColor("e4e4e4"), setForeground(Color.black, setFontSize(60, l = jcenteredlabel_noToolTip()))))))); addToWindowWithMargin(frame, jcenteredline(btnSay = jbutton("Say", f sayIt))); receivers = ll( consequentsMap_receiver(consequentsMap), precedentsMap_receiver(precedentsMap)); time "Loading" { loading { mapVoidMulti(receivers, notNulls(map prepLine(dropLast(linesOfFile(speechRecognitionLog()))))); } } tailFileLinewisePlusLastLine(speechRecognitionLog(), 100, vf1(f onUtteranceFromLog)); } sS prepLine(S s) { ret nullIfInSet(ignoreSet, unquoteAndDropAngleBracketStuff(s)); } svoid onUtteranceFromLog(S utterance) { if (empty(utterance = prepLine(trimLastLine(utterance)))) ret; print(">> " + utterance); onUtterance(utterance); } svoid onUtterance(S utterance) { mapVoidMulti(receivers, ll(utterance)); answer = consequentsMap.get(utterance); if (empty(answer)) answer = precedentsMap.get(utterance); S both = utterance; setTextAndEnabled(btnSay, empty(answer) ? pair("Say", false) : pair("Say " + quote(answer), true)); if (nempty(answer)) { both += "\n\n" + answer; logQuotedWithTime("guessLog", both); } setFrameTitle(l, both.replaceAll("\n+", " > "); setText(l, jlabel_textAsHTML_center(both)); printIndentUnlessEmpty(">> ", pcallAnswerMethod(utterance)); } answer { if "font size *" ret "OK" with revalidate(setFontSize(parseInt($1), l)); if "foreground|vordergrund" ret "OK" with activateFrame(l); if "backround|hintergrund" ret "OK" with minimizeFrame(l); } svoid sayIt { fS a = answer; if (empty(a)) ret; print("Saying: " + a); thread { speakInRecognizerLanguage(a); } onUtterance(a); }