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

45
LINES

< > BotCompany Repo | #1027352 // Run Cheetah Realtime [voice recognition]

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

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

1  
!7
2  
3  
cmodule RunCheetah > DynPrintLogAndEnabled {
4  
  transient Process process;
5  
6  
  start-thread {
7  
    dm_registerAs_direct runCheetah();
8  
    dm_reloadOnFieldChange enabled();
9  
    _startIt();
10  
  }
11  
  
12  
  void _startIt q {
13  
    cleanMeUp_process();
14  
    if (!enabled) ret;
15  
    File script = userDir("dev/cheetah/speech-loop");
16  
    assertFileExists(script);
17  
18  
    print("Calling " + script);
19  
    process = Runtime.getRuntime().exec(platformQuoteOpt(bashExecutable()) + " " + platformQuoteOpt(script));
20  
    print("Cheetah process started");
21  
    print("PID: " + getOpt(process, "pid"));
22  
  
23  
    drainErrorStreamToConsole(process, line -> enabled, lambda0 enter);
24  
    //out = new PrintStream(process.getOutputStream());
25  
    
26  
    dm_startThread("Cheetah Recognition", r {
27  
      drainStreamToPrint_charByChar_onChar_onLine(process.getInputStream(),
28  
        () -> enabled,
29  
        c -> vmBus_send cheetahCharRecognized(module(), c),
30  
        line -> {
31  
          if (!contains(line, "[WARN]"))
32  
            vmBus_send cheetahLineRecognized(module(), line);
33  
        });
34  
    });
35  
  }
36  
37  
  void cleanMeUp_process {
38  
    if (process != null) {
39  
      print("Stopping Cheetah process");
40  
      process.destroy/*Forcibly*/();
41  
      process = null;
42  
      print("Stopped Cheetah process, hopefully");
43  
    }
44  
  }
45  
}

Author comment

Began life as a copy of #1027266

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1027352
Snippet name: Run Cheetah Realtime [voice recognition]
Eternal ID of this version: #1027352/19
Text MD5: 1d56c34eefc3143bd1b327ab0539a064
Transpilation MD5: b7c39ca7e34498e64ab3fe50f3608ea7
Author: stefan
Category: javax / anki vector
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-03-11 16:42:11
Source code size: 1321 bytes / 45 lines
Pitched / IR pitched: No / No
Views / Downloads: 233 / 774
Version history: 18 change(s)
Referenced in: [show references]