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).

!7

sclass FakeFake > DynModule {
  transient JTextArea ta;
  S text;
  LS log = synchroList();
  
  transient WaitForStableValue<S> wait = new(2.0);
  transient S preloading;
  
  start {
    onSpeechRecognized(voidfunc(fS s) {
      if (ai_isStandardCommand(s)) ret;
      log("Heard: " + s);
      trigger();
    });
    doEvery(1000, r {
      wait.set(trim(firstLine(text)));
      S s = wait.get();
      if (nempty(s))
        dm_callOpt(dm_voiceOutputModule(), 'preload, s);
    });
  }
  
  void trigger {
    swing {
      if (!dm_visible() || ta == null) ret;
      fS line = trim(firstLine(text));
      if (empty(line)) ret;
      log("Said: " + line);
      setText(ta, dropFirstLine(text)); // TODO: move cursor
      thread { dm_say(line); }
    }
  }
  
  void log(S s) {
    log.add(print(s));
    persistMe();
  }
  
  visualize {
    ta = jLiveValueWordWrapTypeWriterTextArea_bothWays(dm_fieldLiveValue('text));
    onCtrlEnter(ta, r trigger);
    ret ta;
  }
}

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: 343 / 1525
Version history: 7 change(s)
Referenced in: