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

1  
!7
2  
3  
static long attnTimeout = 60000;
4  
5  
sS reKatze = "Katze|Katze|Katja|Qatar|Cookson|Captain|Cat|Kettle|Cut|Kurt";
6  
7  
static JTextArea ta;
8  
static IVar<S> text;
9  
static Class recognizer;
10  
static long attention;
11  
12  
p-subst {
13  
  recognizer = hotwire(#1009816);
14  
  
15  
  text = persistentVar("Text");
16  
  ta = bindTextAreaToVar(text, jwordwraptextarea());
17  
  showFrame(fontSize(20, ta));
18  
  moveCaretToEnd(ta);
19  
20  
  set(recognizer, onUtterance := voidfunc(S utterance) {
21  
    if (match("turn off", utterance))
22  
      call(recognizer, 'stopRecognition);
23  
    appendToTextAreaAndMoveCaret(ta, utterance + "\n");
24  
    callAnswerMethodVerbose(utterance);
25  
  });
26  
  
27  
  //set(recognizer, startRecognition := true);
28  
  callMain(recognizer);
29  
}
30  
31  
sS answer(fS s) {
32  
  if (sysNow() >= attention+attnTimeout) attention = 0;
33  
  
34  
  if (attention != 0) {
35  
    if "nichts|nix|vergiss es|nothing|forget it" {
36  
      playWAVSnippet(#1013870);
37  
    }
38  
    
39  
    thread { playRandomSoundFromFreesoundOrg(s); }
40  
    
41  
    attention = 0;
42  
    print("attn off");
43  
  }
44  
  
45  
  if (regexpICFind(reKatze, s)) {
46  
    if (isShit(s))
47  
      playMP3Snippet(#1013884);
48  
    else
49  
      playWAVSnippet(#1013870);
50  
    attention = sysNow();
51  
    print("attn");
52  
    ret "Yo";
53  
  }
54  
  
55  
  L<S> g = regexpGetGroups("(-?\\d+) x (-?\\d+)$", s);
56  
  if (g != null)
57  
    ret gudrun(str(parseLong(first(g))*parseLong(second(g))));
58  
  
59  
  null;
60  
}
61  
62  
sbool isShit(S s) {
63  
  ret regexpICFind("scheiß", s);
64  
}

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: 479 / 1030
Version history: 29 change(s)
Referenced in: [show references]