Uses 1113K of libraries. Click here for Pure Java version (7237L/35K).
1 | !7 |
2 | |
3 | cmodule2 ListenOnNoise > DynPrintLogAndEnabled { |
4 | switchable int threshold = 50; |
5 | switchable int interval = 10; |
6 | |
7 | transient float lastVolume; |
8 | transient Q q; |
9 | |
10 | start { |
11 | q = dm_startQ(); |
12 | dm_addAudioListener(voidfunc(short[] data) { |
13 | if (!enabled) ret; |
14 | |
15 | // Quickly calculate the volume |
16 | final float vol = shortSamplesToPercentVolume(data); |
17 | |
18 | // Do everything else in our own thread; don't pile up |
19 | if (q.isEmpty()) q.add(r { |
20 | //print("vol: " + vol); |
21 | if (vol >= threshold && lastVolume < threshold) { |
22 | printWithTime("Got noise (" + iround(vol) + "%)"); |
23 | /*O katze = dm_getModule(dm_requireModule("#1016461/Katze")); |
24 | call(katze, 'listenJustOnce);*/ |
25 | dm_enableSpeechRecognitionFor(interval, "Noise"); |
26 | } |
27 | lastVolume = vol; |
28 | }); |
29 | }); |
30 | |
31 | dm_onUserUtterance("stop listening", r { |
32 | setEnabled(false); |
33 | }); |
34 | |
35 | } |
36 | |
37 | afterVisualize { |
38 | addButton(dm_intSpinnerWithLabel interval(1, 600)); |
39 | addButton(dm_intSpinnerWithLabel threshold(1, 80)); |
40 | } |
41 | } |
Began life as a copy of #1017158
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1017159 |
Snippet name: | Listen On Noise [using Google speech recognizer] |
Eternal ID of this version: | #1017159/23 |
Text MD5: | 0091989aacada173181edc723bbfdf61 |
Transpilation MD5: | ef23562eef8369af04121713a7a45db6 |
Author: | stefan |
Category: | javax / audio |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-05-23 19:43:33 |
Source code size: | 1079 bytes / 41 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 484 / 37622 |
Version history: | 22 change(s) |
Referenced in: | [show references] |