Download Jar. Uses 3874K of libraries. Click here for Pure Java version (9541L/65K).
!7 sS botName = "Dictation."; static JTextArea ta; static IVar<S> text; static Splitter2<S, S> commandOrText; static JTextArea whatYouSay; static JButton btnText, btnCommand, btnNothing; static new L<JButton> typeButtons; static new L<S> types; static S currentType; p-subst { if (nempty(sendOpt(botName, "activate"))) { cleanKill(); ret; } commandOrText = persistentObject("Command or text splitter", Splitter2); text = persistentVar("Text"); swing { moveFrameTo(10, 10, 500, 300, showFrame("What you say", whatYouSay = jTextArea())); addToFrame(whatYouSay, withCenteredTitle("What is this?", jcenteredline( btnText = jbutton("It's text", r { setType('text) }), btnCommand = jbutton("It's a command", r { setType('command) }), btnNothing = jbutton("It's nothing", r { setType('nothing) }) ))); typeButtons = ll(btnText, btnCommand, btnNothing); types = ll('text, 'command, 'nothing); updateButtons(); showFrame(ta = jtextArea(text!)); onUpdate(ta, r { text.set(getText(ta)) }); exitProgramOnFrameClose(ta); } bot(botName); prioMe(); hideConsole(); } svoid prioMe { sendOpt("Voice Actions", "prio bot *", botName); } svoid cleanMeUp { sendOpt("Voice Actions", "prio bot done *", botName); } answer { if "activate" { prioMe(); activateFrame(ta); ret "OK"; } if "user said *" { onUtterance($1); ret "OK"; } } svoid onUtterance(fS s) { fS type = commandOrText.get(s); onUtterance(s, type); } svoid onUtterance(fS s, fS type) { swing { currentType = type; setText(whatYouSay, s); updateButtons(); } if (eq(type, 'command)) interpretCommand(s); else if (eq(type, 'text)) { appendToTextArea(ta, s + "\n"); requestFocus(ta); } } svoid interpretCommand(S s) { if "dictation done" { sendOpt("Voice Actions", "prio bot done *", botName); cleanKill(); } } svoid setType(S type) { S text = getText(whatYouSay); if (currentType != null) commandOrText.unlearn(text, type); commandOrText.learn(text, type); onUtterance(text, type); } svoid updateButtons { for i over typeButtons: typeButtons.get(i).setEnabled(neq(currentType, types.get(i))); }
Began life as a copy of #1009702
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: | #1009705 |
Snippet name: | Dictation Bot with Splitter 2 [dev.] |
Eternal ID of this version: | #1009705/7 |
Text MD5: | 4701f93b2d6b5aff60681b1272e5902b |
Transpilation MD5: | 9fb4a0e92db82d64b51fcb7ef1eb1ec4 |
Author: | stefan |
Category: | javax / assistants |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-08-14 17:32:50 |
Source code size: | 2315 bytes / 96 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 647 / 1440 |
Version history: | 6 change(s) |
Referenced in: | [show references] |