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

1  
sS deepspeech_recognize16KWav(File wav, O... _) {
2  
  optPar bool useKnownPlaces;
3  
  optPar S envVars;
4  
  
5  
  assertFileExists(wav);
6  
  File dir = assertNotNull("DeepSpeech dir not set", deepspeech_dir());
7  
  File model1 = newFile(dir, "deepspeech-0.6.1-models/output_graph" + (isRaspberryPi() ? ".tflite" : ".pbmm"));
8  
  assertFileExists(model1);
9  
  LS args = ll(
10  
    "--model",
11  
    platformQuote(model1),
12  
    "--lm",
13  
    platformQuote(newFile(dir, "deepspeech-0.6.1-models/lm.binary")),
14  
    "--trie",
15  
    platformQuote(newFile(dir, "deepspeech-0.6.1-models/trie")),
16  
    "--audio"
17  
  );
18  
  File virtualEnv = userDir("tmp/deepspeech-venv");
19  
  File virtualEnvActivate = newFile(virtualEnv, "bin/activate");
20  
  assertFileExists(virtualEnvActivate);
21  
  
22  
  File scriptFile, outFile, errFile;
23  
  if (useKnownPlaces) {
24  
    scriptFile = javaxCachesDir("deepspeech.sh");
25  
    outFile = javaxCachesDir("deepspeech.out");
26  
    errFile = javaxCachesDir("deepspeech.err");
27  
  } else {
28  
    scriptFile = createTempFile();
29  
    outFile = createTempFile();
30  
    errFile = createTempFile();
31  
  }
32  
  saveTextFile(scriptFile, "source " + platformQuote(virtualEnvActivate) + " && "
33  
    + unnullPlusSpace(envVars) + "deepspeech" + " " // deepspeech is in the path at that point
34  
    + joinWithSpace(args) + " " + platformQuote(wav)
35  
    + " > " + platformQuote(outFile)
36  
    + " 2> " + platformQuote(errFile));
37  
  makeExecutable(scriptFile);
38  
  time "DeepSpeech" {
39  
    backtick_verbose(platformQuote(scriptFile));
40  
  }
41  
  ret trim(loadTextFile(outFile));
42  
}
43  
44  
sS deepspeech_recognize16KWav(S wav) {
45  
  ret deepspeech_recognize16KWav(newFile(wav));
46  
}

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: 298 / 471
Version history: 23 change(s)
Referenced in: [show references]