Uses 911K of libraries. Click here for Pure Java version (5210L/26K).
1 | !7 |
2 | |
3 | // Goes well with a headphone detector like #1027532 |
4 | |
5 | cmodule AudioFeedbackPreventer > DynPrintLogAndEnabled {
|
6 | // from end of talking to recognition coming in |
7 | switchable double expectedDelay = 3.0; |
8 | |
9 | transient long talkingSince; |
10 | transient LongRange lastTalked; |
11 | |
12 | start {
|
13 | dm_registerAs_direct audioFeedbackPreventer(); |
14 | dm_vmBus_onMessage talking(r { talkingSince = sysNow() });
|
15 | dm_vmBus_onMessage doneTalking(r {
|
16 | lastTalked = longRange(talkingSince, sysNow()); |
17 | talkingSince = 0; |
18 | }); |
19 | } |
20 | |
21 | // API |
22 | |
23 | bool recognizedSpeechIsProbablyMyOwnUtterance(O... _) {
|
24 | if (isTrue(dm_haveHeadphones())) {
|
25 | // Voice output goes to headphones, so we can't hear it |
26 | print("Assuming I can't hear myself (headphones)");
|
27 | false; |
28 | } |
29 | if (talkingSince != 0) true; |
30 | if (lastTalked == null) false; |
31 | double elapsed = elapsedSeconds_sysNow(lastTalked.end); |
32 | bool b = elapsed <= expectedDelay; |
33 | if (nempty(_)) print(asList(_)); |
34 | print("Time since my last utterance: " + formatDouble(elapsed, 1) + "s, guessing it is " + (b ? "" : "not ") + " my utterance");
|
35 | ret b; |
36 | } |
37 | } |
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: | #1027542 |
| Snippet name: | Audio Feedback Preventer [OK, stops speech output -> recognition endless loops] |
| Eternal ID of this version: | #1027542/12 |
| Text MD5: | b8abb3b982e9e7a4ab6fab74115f22c0 |
| Transpilation MD5: | 18ac157b189f323ee165af3523104c91 |
| Author: | stefan |
| Category: | javax / stefan's os |
| Type: | JavaX source code (Dynamic Module) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2020-03-23 14:13:30 |
| Source code size: | 1170 bytes / 37 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 441 / 9767 |
| Version history: | 11 change(s) |
| Referenced in: | [show references] |