Download Jar. Uses 11806K of libraries. Click here for Pure Java version (11900L/86K).
!7 sclass Analyzer { static int baseSize = 1024; S word1, word2; Rect rect; // in baseSize*baseSize float threshold; S analyze(BWImage img) { Rect r = rescaleRect(rect, baseSize, baseSize, img.getWidth(), img.getHeight()); double b = clipBWImage(img, r).averageBrightness(); //print(r + " => " + b); ret b >= threshold ? word1 : word2; } } static LPair<S, BWImage> images = new L; sS word1 = "yes", word2 = "no"; p-exp { L<File> files = audioRecordingsWithSingleClip(); for (File f : allRecordings()) { S word = wordFromAudioFileName(f); if (!eqicOneOf(word, word1, word2)) continue; images.add(pair(word, bwAutoContrast(audio_clipFromLastEntryPoint(audioFileToFrequencyImage(f))))); print(fileName(f)); } showImage(second(random(images))); findBestAnalyzer(); } svoid findBestAnalyzer { final new Best<Analyzer> best; final new AIStrategy_RandomWithVariation<Analyzer> strategy; strategy.random = func -> Analyzer { randomAnalyzer() }; strategy.submit = func(final Analyzer a) -> double { new Scorer scorer; for (Pair<S, BWImage> img : images) scorer.add(eqic(img.a, a.analyze(img.b))); if (best.put(a, scorer!)) print(scorer + " / " + struct(a)); ret scorer!; }; thread { while licensed { strategy.go(); } } } static Analyzer randomAnalyzer() { bool flip = tossCoin(); ret nu(Analyzer, word1 := flip ? word1 : word2, word2 := flip ? word2 : word1, rect := randomRect(Analyzer.baseSize, Analyzer.baseSize), threshold := randomFloat()); }
Began life as a copy of #1018800
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1018810 |
Snippet name: | Distinguish Yes and No Spike [OK] |
Eternal ID of this version: | #1018810/12 |
Text MD5: | 211a46907a1902addef4b1ae3b838db1 |
Transpilation MD5: | f8c2f4982e90d4ca5104a8f4166d0077 |
Author: | stefan |
Category: | javax / audio |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-10-13 22:03:39 |
Source code size: | 1636 bytes / 58 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 404 / 1013 |
Version history: | 11 change(s) |
Referenced in: | #1018823 - Distinguish Up and Down [OK] |