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

46
LINES

< > BotCompany Repo | #1026959 // deepspeech_recognize16KWav

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (5420L/35K).

sS deepspeech_recognize16KWav(File wav, O... _) {
  optPar bool useKnownPlaces;
  optPar S envVars;
  
  assertFileExists(wav);
  File dir = assertNotNull("DeepSpeech dir not set", deepspeech_dir());
  File model1 = newFile(dir, "deepspeech-0.6.1-models/output_graph" + (isRaspberryPi() ? ".tflite" : ".pbmm"));
  assertFileExists(model1);
  LS args = ll(
    "--model",
    platformQuote(model1),
    "--lm",
    platformQuote(newFile(dir, "deepspeech-0.6.1-models/lm.binary")),
    "--trie",
    platformQuote(newFile(dir, "deepspeech-0.6.1-models/trie")),
    "--audio"
  );
  File virtualEnv = userDir("tmp/deepspeech-venv");
  File virtualEnvActivate = newFile(virtualEnv, "bin/activate");
  assertFileExists(virtualEnvActivate);
  
  File scriptFile, outFile, errFile;
  if (useKnownPlaces) {
    scriptFile = javaxCachesDir("deepspeech.sh");
    outFile = javaxCachesDir("deepspeech.out");
    errFile = javaxCachesDir("deepspeech.err");
  } else {
    scriptFile = createTempFile();
    outFile = createTempFile();
    errFile = createTempFile();
  }
  saveTextFile(scriptFile, "source " + platformQuote(virtualEnvActivate) + " && "
    + unnullPlusSpace(envVars) + "deepspeech" + " " // deepspeech is in the path at that point
    + joinWithSpace(args) + " " + platformQuote(wav)
    + " > " + platformQuote(outFile)
    + " 2> " + platformQuote(errFile));
  makeExecutable(scriptFile);
  time "DeepSpeech" {
    backtick_verbose(platformQuote(scriptFile));
  }
  ret trim(loadTextFile(outFile));
}

sS deepspeech_recognize16KWav(S wav) {
  ret deepspeech_recognize16KWav(newFile(wav));
}

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: #1026959
Snippet name: deepspeech_recognize16KWav
Eternal ID of this version: #1026959/24
Text MD5: be6037ce67f71f3f527669673bc9777c
Transpilation MD5: 295ae74401ad1967eadbf270f85c1c92
Author: stefan
Category: javax / speech recognition
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-02-04 02:56:47
Source code size: 1642 bytes / 46 lines
Pitched / IR pitched: No / No
Views / Downloads: 215 / 374
Version history: 23 change(s)
Referenced in: [show references]