Uses 408K of libraries. Click here for Pure Java version (16180L/115K).
!7 module CorrectRecognizedSpeech > DynPrintLog { transient Map<S, MultiSet<S>> corrections = syncCIMap(); bool autoCorrect = true, verbose; S switchableFields() { ret "autoCorrect verbose"; } start { ownResource(watchSpeechConfirmations_fromStart(voidfunc(S heard, S corrected) { MultiSet<S> ms; synchronized(corrections) { ms = corrections.get(heard); if (ms == null) corrections.put(heard, ms = new MultiSet); } ms.add(corrected); if (verbose) print("Learned correction: " + heard + " => " + corrected); })); ownResource(onSpeechRecognized_withoutMyUtterancesAndTyped(voidfunc(fS s) enter { S corrected = getCorrection(s); if (nempty(corrected)) infoBox("Proposing correction: " + corrected); else if (verbose) print("No correction found for: " + s); })); } visualize { ret withRightAlignedButtons(super.visualize(), toolTip("Correct all recognized speech", dm_fieldCheckBox('autoCorrect)), "Show Corrections Database", rThread { showText("Speech Recognition Corrections", formatDoubleArrowMap(mapValues(corrections, f msMostPopularEntry))); }); } // API S getCorrection(S s) { ret l(s) < 2 ? null : msMostPopularEntry(corrections.get(s)); } S getAutoCorrection(S s) { ret autoCorrect ? getCorrection(s) : null; } }
download show line numbers debug dex old transpilations
Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1020219 |
Snippet name: | Correct Recognized Speech [learns from #1019400] |
Eternal ID of this version: | #1020219/18 |
Text MD5: | 7f918592e457fe4db3255cc434701d6e |
Transpilation MD5: | 64079c239be9535020ed239aed258e94 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-01-01 15:46:06 |
Source code size: | 1447 bytes / 46 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 418 / 3939 |
Version history: | 17 change(s) |
Referenced in: | [show references] |