Download Jar. Uses 4487K of libraries. Click here for Pure Java version (14503L/113K).
!7 static JLabel l; static Map<S> consequentsMap = synchroCIMap(), precedentsMap = synchroCIMap(); static Set<S> ignoreSet = asCISet(splitAtVerticalBar("english|englisch|german|deutsch|foreground|fairground|background|Vordergrund|Hintergrund")); sS answer; static L<VF1<S>> receivers; static JTextField tfInput, tfSay, tfNote; static JButton btnSay; static TailFile logTail; p-noconsole-autoupdate { startBotInSeparateVM("Katze.", #1013936); hideVMRunningBot("Katze."); 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))); // bottom to top addToWindowNorth(frame, withMargin(10, 1, withLabel("Add a note:", tfNote = jcenteredtextfield()))); addToWindowNorth(frame, withMargin(10, 1, withLabel("Make me say something:", tfSay = jcenteredtextfield()))); addToWindowNorth(frame, withMargin(10, 1, withLabel("Type here instead of speaking:", tfInput = jcenteredtextfield()))); onEnter(tfInput, r-thread { send("Chrome Speech.", "User typed *", getTextTrim(tfInput)) }); onEnter(tfSay, r-thread { speakInRecognizerLanguage(getTextTrim(tfSay)) }); onEnter(tfNote, r { mechAppendQueue().add(r { appendToMechList_noUniq("Today's Notes", "[" + localDateWithMilliseconds() + "] " + getTextTrim(tfNote)) }) }); focusOnFrameActivationAndNow(frame, btnSay); receivers = ll( consequentsMap_receiver(consequentsMap), precedentsMap_receiver(precedentsMap)); time "Loading" { loading { mapVoidMulti(receivers, notNulls(map prepLine(dropLast(linesOfFile(speechRecognitionLog()))))); } } logTail = tailFileLinewisePlusLastLine(speechRecognitionLog(), 100, vf1(f onUtteranceFromLog)); //makeAndCall_warmUp("mL_anInstanceOfA"); } sS prepLine(S s) { s = unquoteAndDropAngleBracketStuff(s); // don't react on older messages if (logTail != null && logTail.started()) printIndentUnlessEmpty(">> ", pcallAnswerMethod(s)); ret nullIfInSet(ignoreSet, 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 = guessAnswer(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)); } answer { s = lookupOrKeep(mechMapCI("Mishearing corrections"), s); if "higher" infoBox("Get higher?"); if "font size *" ret "OK" with revalidate(setFontSize(parseInt($1), l)); if "foreground|fairground|vordergrund" ret "OK" with activateFrame(l); if "background|hintergrund" ret "OK" with minimizeFrame(l); if "standard function|standard functions|steroid function|standard fashion" // Google keeps misunderstanding ret "OK" with sfBot_doIt(); if "move mouse away" ret "OK" with moveMouseToTopRightCorner(); if "mouse to center|mouse to centre|most two centre" ret "OK" with moveMouseToScreenCenter(); } svoid sayIt { fS a = answer; if (empty(a)) ret; print("Saying: " + a); thread { speakInRecognizerLanguage(a); } onUtterance(a); } sS guessAnswer(S s) { new Matches m; if (find3plusRestsOneOf(s, m, "Ich heiße", "Ich bin", "Mein Name ist", "Man nennt mich", "Ich werde * genannt", "nennen mich", "nennt mich", "nenne mich")) if (eqic($2, "Stefan")) ret gudrun_later("Stefan ist ein Programmierer"); else ret gudrun_later("Hallo " + $2); try answer mL_answerWithCodeFragments("Witty Answers", s); try answer mL_answerWithCodeFragments(s); try answer consequentsMap.get(s); try answer precedentsMap.get(s); null; }
Began life as a copy of #1014135
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1014703 |
Snippet name: | VisualKatze 4 [Association Machine, Forward+Backward, ignoring stuff, OK, run with #1013936] |
Eternal ID of this version: | #1014703/1 |
Text MD5: | 5626d28c717b37889880315518e5af23 |
Transpilation MD5: | ea7a62d2bf39797fba3dabc22ba13d2d |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-04-30 17:40:52 |
Source code size: | 4284 bytes / 115 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 592 / 1351 |
Referenced in: | [show references] |