Uses 3874K of libraries. Click here for Pure Java version (9232L/62K/216K).
1 | !7 |
2 | |
3 | sS botName = "Dictation."; |
4 | static JTextArea ta; |
5 | static IVar<S> text; |
6 | static Splitter1<S> commandOrText; |
7 | static JTextArea whatYouSay; |
8 | |
9 | p-subst { |
10 | if (nempty(sendOpt(botName, "activate"))) { cleanKill(); ret; } |
11 | |
12 | commandOrText = persistentObject("Command or text splitter", Splitter1); |
13 | text = persistentVar("Text"); |
14 | swing { |
15 | moveFrameTo(10, 10, showFrame("What you say", whatYouSay = jTextArea())); |
16 | showFrame(ta = jtextArea(text!)); |
17 | onUpdate(ta, r { text.set(getText(ta)) }); |
18 | exitProgramOnFrameClose(ta); |
19 | } |
20 | bot(botName); |
21 | prioMe(); |
22 | hideConsole(); |
23 | } |
24 | |
25 | svoid prioMe { |
26 | sendOpt("Voice Actions", "prio bot *", botName); |
27 | } |
28 | |
29 | svoid cleanMeUp { |
30 | sendOpt("Voice Actions", "prio bot done *", botName); |
31 | } |
32 | |
33 | answer { |
34 | if "activate" { |
35 | prioMe(); |
36 | activateFrame(ta); |
37 | ret "OK"; |
38 | } |
39 | |
40 | if "user said *" { |
41 | onUtterance($1); |
42 | ret "OK"; |
43 | } |
44 | } |
45 | |
46 | svoid onUtterance(S s) { |
47 | setText(whatYouSay, s); |
48 | Either<S> e = commandOrText(s); |
49 | if (e.isA()) |
50 | interpretCommand(e.a()); |
51 | else { |
52 | appendToTextArea(ta, e.b() + "\n"); |
53 | requestFocus(ta); |
54 | } |
55 | } |
56 | |
57 | static Either<S> commandOrText(S s) { |
58 | if (eq(s, "dictation done")) ret eitherA(s); |
59 | int i = commandOrText.get(s); |
60 | if (i != 0) ret either(s, i); |
61 | ret eitherB(s); |
62 | } |
63 | |
64 | svoid interpretCommand(S s) { |
65 | if "dictation done" { |
66 | sendOpt("Voice Actions", "prio bot done *", botName); |
67 | cleanKill(); |
68 | } |
69 | } |
Began life as a copy of #1009657
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: | #1009702 |
Snippet name: | Dictation Bot with Splitter [dev.] |
Eternal ID of this version: | #1009702/6 |
Text MD5: | 6cc23f769d89f9fb803f29ec51115ab7 |
Transpilation MD5: | fb532283240b793739dead8cb4123e70 |
Author: | stefan |
Category: | javax / assistants |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-08-14 16:55:45 |
Source code size: | 1457 bytes / 69 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 456 / 528 |
Version history: | 5 change(s) |
Referenced in: | [show references] |