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

41
LINES

< > BotCompany Repo | #1016982 // Proposed Voice Output

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

Uses 911K of libraries. Click here for Pure Java version (3430L/18K).

!7

sclass Prop {
  S text, module;
  long date = now();
  
  [stdEq]
}

cmodule ProposedVoiceOutput > DynObjectTable<Prop> {
  transient int expiryTime = 10000;
  transient long timer; // When we began thinking
  transient int thinkTime = 2000;
  
  start {
    // now default:
    // itemToMap = func(Prop p) -> Map { humanizeKeys(objectToMap(p)) };
    doEvery(1000, r cleanList);
  }
  
  void addProposition(S text, S module) {
    syncRemoveWhereFields(data, +text, +module);
    add(nu(Prop, +text, +module));
  }
  
  void cleanList {
    setField(data := objectsWhereFieldGreaterThan(cloneList(data), date := now()-expiryTime));
    if (syncNempty(data)) {
      if (timer == 0) timer = now();
      if (now() >= timer+thinkTime) {
        S out = getString(random(data), 'text);
        clear();
        timer = 0;
        if (ai_shouldAnswerAtLeastSometimes())
          dm_say(out);
        else
          print("Would say: " + out);
      }
    }
  }
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1016982
Snippet name: Proposed Voice Output
Eternal ID of this version: #1016982/20
Text MD5: 2e7180ece0e5ad38e7a3a4e441d9c531
Transpilation MD5: f8d0a4e109c2af0962f6b4a7d2e9bcc2
Author: stefan
Category: javax / dynamic modules
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-02-17 17:46:12
Source code size: 1005 bytes / 41 lines
Pitched / IR pitched: No / No
Views / Downloads: 450 / 8036
Version history: 19 change(s)
Referenced in: [show references]