Uses 1113K of libraries. Click here for Pure Java version (7237L/35K).
!7 cmodule2 ListenOnNoise > DynPrintLogAndEnabled { switchable int threshold = 50; switchable int interval = 10; transient float lastVolume; transient Q q; start { q = dm_startQ(); dm_addAudioListener(voidfunc(short[] data) { if (!enabled) ret; // Quickly calculate the volume final float vol = shortSamplesToPercentVolume(data); // Do everything else in our own thread; don't pile up if (q.isEmpty()) q.add(r { //print("vol: " + vol); if (vol >= threshold && lastVolume < threshold) { printWithTime("Got noise (" + iround(vol) + "%)"); /*O katze = dm_getModule(dm_requireModule("#1016461/Katze")); call(katze, 'listenJustOnce);*/ dm_enableSpeechRecognitionFor(interval, "Noise"); } lastVolume = vol; }); }); dm_onUserUtterance("stop listening", r { setEnabled(false); }); } afterVisualize { addButton(dm_intSpinnerWithLabel interval(1, 600)); addButton(dm_intSpinnerWithLabel threshold(1, 80)); } }
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: | 485 / 37622 |
Version history: | 22 change(s) |
Referenced in: | #1026349 - dm_listenOnNoiseModule #1026350 - dm_listenOnNoiseModuleOpt #1026863 - Record On Noise [e.g. for wit.ai recognition with #1019331] |