Uses 1319K of libraries. Click here for Pure Java version (9670L/49K).
!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<S> 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<AutoCloseable> 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)); } }
Began life as a copy of #1019363
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, hpgrupgrauku, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1019400 |
Snippet name: | Speech Recognition Confirmation v2 [Did computer understand correctly?, with tray icon] |
Eternal ID of this version: | #1019400/46 |
Text MD5: | 4e8139729e09795b68e239ab46ef9e83 |
Transpilation MD5: | 06d4744e8e63e59f160f0b9da516f6d6 |
Author: | stefan |
Category: | javax / stefan's os |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-12-11 03:04:00 |
Source code size: | 2456 bytes / 69 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 509 / 34326 |
Version history: | 45 change(s) |
Referenced in: | [show references] |