Uses 36492K of libraries. Click here for Pure Java version (3034L/21K/65K).
1 | !7 |
2 | |
3 | p { |
4 | S text = or2(smartJoin(args), "hello"); |
5 | print("TEXT: " + text); |
6 | |
7 | File mp3 = william_silent(text); |
8 | //try { playMp3(mp3); } catch {} |
9 | |
10 | File wavFile1 = prepareProgramFile("speech-big.wav"); |
11 | File wavFile = prepareProgramFile("speech.wav"); |
12 | |
13 | mp3ToWAV_2(mp3, wavFile1); |
14 | convertWAVForSphinx(wavFile1, wavFile); |
15 | |
16 | // direct conversion leads to robot voice bug |
17 | // convertWAVForSphinx(mp3, wavFile); |
18 | |
19 | |
20 | print("WAV: " + wavFile + " (" + wavFile.length() + ")"); |
21 | pcall { playWAV(wavFile); } |
22 | |
23 | // Try to suppress logging |
24 | // java.util.logging.LogManager.getLogManager().reset(); // no workie |
25 | // java.util.logging.Logger.getLogger("global").setLevel(java.util.logging.Level.SEVERE); |
26 | java.util.logging.Logger.getLogger("").setLevel(java.util.logging.Level.SEVERE); |
27 | |
28 | long loadTime = sysNow(); |
29 | StreamSpeechRecognizer2 recognizer = new StreamSpeechRecognizer2(makeSphinxConfig()); |
30 | loadTime = sysNow()-loadTime; |
31 | |
32 | print("Recognizing " + wavFile); |
33 | |
34 | new L<Long> times; |
35 | new L<S> lines; |
36 | for (int i = 0; i < 10; i++) { |
37 | long time = now(); |
38 | recognizer.startRecognition(new FileInputStream(wavFile)); |
39 | SpeechResult result; |
40 | print("loop"); |
41 | lines = new L; |
42 | while ((result = recognizer.getResult()) != null) { |
43 | S line = result.getHypothesis(); |
44 | lines.add(line); |
45 | print("Hypothesis: " + line); |
46 | } |
47 | print("done"); |
48 | recognizer.stopRecognition(); |
49 | times.add(now()-time); |
50 | } |
51 | |
52 | print("Loading time: " + loadTime + ". Recognition times (ms): " + struct(times)); |
53 | |
54 | S recognized = trim(fromLines(lines)); |
55 | print("recognized: " + recognized); |
56 | if (match(text, recognized)) |
57 | print("perfect match!!!"); |
58 | else { |
59 | print("not quite."); |
60 | print("input was: " + text); |
61 | } |
62 | } |
Began life as a copy of #1004801
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: | #1006994 |
Snippet name: | Test Sphinx4 Speech Recognizer With Synthesized Voice (William) [faster, WORKS] |
Eternal ID of this version: | #1006994/9 |
Text MD5: | 271f526281119d33f5499cb47d036227 |
Transpilation MD5: | 426ed1eb490cfdf8b33eb0248e08559a |
Author: | stefan |
Category: | javax / speech |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-02-26 00:18:27 |
Source code size: | 1850 bytes / 62 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 673 / 820 |
Version history: | 8 change(s) |
Referenced in: | [show references] |