Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

46
LINES

< > BotCompany Repo | #1018549 // Fake Fake [Dyn Module]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Libraryless. Click here for Pure Java version (9212L/65K).

1  
!7
2  
3  
sclass FakeFake > DynModule {
4  
  transient JTextArea ta;
5  
  S text;
6  
  LS log = synchroList();
7  
  
8  
  transient WaitForStableValue<S> wait = new(2.0);
9  
  transient S preloading;
10  
  
11  
  start {
12  
    onSpeechRecognized(voidfunc(fS s) {
13  
      if (ai_isStandardCommand(s)) ret;
14  
      log("Heard: " + s);
15  
      trigger();
16  
    });
17  
    doEvery(1000, r {
18  
      wait.set(trim(firstLine(text)));
19  
      S s = wait.get();
20  
      if (nempty(s))
21  
        dm_callOpt(dm_voiceOutputModule(), 'preload, s);
22  
    });
23  
  }
24  
  
25  
  void trigger {
26  
    swing {
27  
      if (!dm_visible() || ta == null) ret;
28  
      fS line = trim(firstLine(text));
29  
      if (empty(line)) ret;
30  
      log("Said: " + line);
31  
      setText(ta, dropFirstLine(text)); // TODO: move cursor
32  
      thread { dm_say(line); }
33  
    }
34  
  }
35  
  
36  
  void log(S s) {
37  
    log.add(print(s));
38  
    persistMe();
39  
  }
40  
  
41  
  visualize {
42  
    ta = jLiveValueWordWrapTypeWriterTextArea_bothWays(dm_fieldLiveValue('text));
43  
    onCtrlEnter(ta, r trigger);
44  
    ret ta;
45  
  }
46  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1018549
Snippet name: Fake Fake [Dyn Module]
Eternal ID of this version: #1018549/8
Text MD5: 995612d05d6518b1e7f54761d2ed9a6f
Transpilation MD5: ecf3f0bf497fb0e9a59f2c856f1c42c0
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: 2019-01-03 02:14:30
Source code size: 1026 bytes / 46 lines
Pitched / IR pitched: No / No
Views / Downloads: 344 / 1526
Version history: 7 change(s)
Referenced in: [show references]