!7 sclass HearMyselfTest > DynPrintLog { S text = "I like you"; transient JTextField tfText; JComponent visualize() { ret withCenteredButtons( northAndCenter(jsection("Text to say", tfText = jLiveValueTextField_bothWays(dm_fieldLiveValue('text))), super.visualize()), "Do the test", rThread doIt); } void doIt { print("Requiring the cat"); O katze = dm_requireModule("#1016461/Katze"); print("cat=" + katze); print("Requiring voice output"); O voiceOutput = dm_requireModule("#1016614/VoiceOutput"); print("Starting to listen"); call(katze, 'startListening); print("Waiting for recognizer..."); 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!); print("Got line: " + s); if (match(text, s)) print("Yes, I can hear me!!"); else if (nempty(s)) print("I said: " + quote(text) + ", but I heard: " + quote(s)); else print("I said: " + quote(text) + ", but I heard nothing."); } }