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

!7

cmodule RunCheetah > DynPrintLogAndEnabled {
  transient Process process;

  start-thread {
    dm_registerAs_direct runCheetah();
    dm_reloadOnFieldChange enabled();
    _startIt();
  }
  
  void _startIt q {
    cleanMeUp_process();
    if (!enabled) ret;
    File script = userDir("dev/cheetah/speech-loop");
    assertFileExists(script);

    print("Calling " + script);
    process = Runtime.getRuntime().exec(platformQuoteOpt(bashExecutable()) + " " + platformQuoteOpt(script));
    print("Cheetah process started");
    print("PID: " + getOpt(process, "pid"));
  
    drainErrorStreamToConsole(process, line -> enabled, lambda0 enter);
    //out = new PrintStream(process.getOutputStream());
    
    dm_startThread("Cheetah Recognition", r {
      drainStreamToPrint_charByChar_onChar_onLine(process.getInputStream(),
        () -> enabled,
        c -> vmBus_send cheetahCharRecognized(module(), c),
        line -> {
          if (!contains(line, "[WARN]"))
            vmBus_send cheetahLineRecognized(module(), line);
        });
    });
  }

  void cleanMeUp_process {
    if (process != null) {
      print("Stopping Cheetah process");
      process.destroy/*Forcibly*/();
      process = null;
      print("Stopped Cheetah process, hopefully");
    }
  }
}

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: 231 / 772
Version history: 18 change(s)
Referenced in: [show references]