!7 sclass HearMyselfTest > DynPrintLog { S text = "I like you", heard; transient JTextField tfText; JComponent visualize() { ret withCenteredButtons( northAndCenter(vstack( jsection("Text to say", tfText = jLiveValueTextField_bothWays(dm_fieldLiveValue('text))), jsection("What I heard", tfHeard = jLiveValueTextField(dm_fieldLiveValue('heard)))), super.visualize()), "Do the test", rThread doIt); } void doIt { print("Initiating voice"); O voiceOutput = dm_requireModule("#1016614/VoiceOutput"); print("Initiating ear"); O katze = dm_requireModule("#1016461/Katze"); call(katze, 'startListening); if (!chromeSpeech_hasRecognizer()) { do { sleepSeconds(1); } while (!chromeSpeech_hasRecognizer()); } sleepSeconds(2); // give time to start S text = getTextTrim(tfText); if (empty(text)) ret; double seconds = 10; long logLength = fileSize(speechRecognitionLog()); print("Saying & listening for " + seconds + " seconds: " + text); call(voiceOutput, 'say, text); long timeout = sysTime()+toMS(seconds); new Var vLine; ManualTailFile tail = new(speechRecognitionLog(), vfAppendToLineBuffer(unquotingLineBuffer(vfSetVar(vLine)))); tailFile_newOnly(tail); while (sysTime() < timeout && !vLine.has()) { tail.check(); sleep(100); } print("Stop listening."); call(katze, 'stopListening); S s = speechRecognitionLog_extractUtterance(vLine!); setField(heard := s); print("Got line: " + s); if (match(text, s)) { print("Yes, I can hear me!!"); setModuleName("I can hear me :)"); } else if (nempty(s)) { print("I said: " + quote(text) + ", but I heard: " + quote(s)); setModuleName("I can't really hear me"); } else { print("I said: " + quote(text) + ", but I heard nothing."); setModuleName("I can't hear me :("); } } }