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

64
LINES

< > BotCompany Repo | #1013871 // Katze v1 [OK]

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Download Jar. Uses 4079K of libraries. Click here for Pure Java version (11848L/83K).

!7

static long attnTimeout = 60000;

sS reKatze = "Katze|Katze|Katja|Qatar|Cookson|Captain|Cat|Kettle|Cut|Kurt";

static JTextArea ta;
static IVar<S> text;
static Class recognizer;
static long attention;

p-subst {
  recognizer = hotwire(#1009816);
  
  text = persistentVar("Text");
  ta = bindTextAreaToVar(text, jwordwraptextarea());
  showFrame(fontSize(20, ta));
  moveCaretToEnd(ta);

  set(recognizer, onUtterance := voidfunc(S utterance) {
    if (match("turn off", utterance))
      call(recognizer, 'stopRecognition);
    appendToTextAreaAndMoveCaret(ta, utterance + "\n");
    callAnswerMethodVerbose(utterance);
  });
  
  //set(recognizer, startRecognition := true);
  callMain(recognizer);
}

sS answer(fS s) {
  if (sysNow() >= attention+attnTimeout) attention = 0;
  
  if (attention != 0) {
    if "nichts|nix|vergiss es|nothing|forget it" {
      playWAVSnippet(#1013870);
    }
    
    thread { playRandomSoundFromFreesoundOrg(s); }
    
    attention = 0;
    print("attn off");
  }
  
  if (regexpICFind(reKatze, s)) {
    if (isShit(s))
      playMP3Snippet(#1013884);
    else
      playWAVSnippet(#1013870);
    attention = sysNow();
    print("attn");
    ret "Yo";
  }
  
  L<S> g = regexpGetGroups("(-?\\d+) x (-?\\d+)$", s);
  if (g != null)
    ret gudrun(str(parseLong(first(g))*parseLong(second(g))));
  
  null;
}

sbool isShit(S s) {
  ret regexpICFind("scheiß", s);
}

Author comment

Began life as a copy of #1010315

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: #1013871
Snippet name: Katze v1 [OK]
Eternal ID of this version: #1013871/30
Text MD5: abb66e64c86f88a63ee699f1a768b9f7
Transpilation MD5: d6c6f49d643b5ecdc1e4ed8e7c103c79
Author: stefan
Category: javax / speech
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-03-16 19:29:29
Source code size: 1467 bytes / 64 lines
Pitched / IR pitched: No / No
Views / Downloads: 595 / 1295
Version history: 29 change(s)
Referenced in: [show references]