Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

26
LINES

< > BotCompany Repo | #1016794 // onSpeechRecognized_withoutMyUtterances

JavaX fragment (include)

please include function onSpeechRecognized.

static int onSpeechRecognized_withoutMyUtterances_magicInterval = 2000;
static int onSpeechRecognized_withoutMyUtterances_reallyLongDelay = 10000;

// f : voidfunc(S) - gets only the utterance
static TailFile onSpeechRecognized_withoutMyUtterances(fO f) {
  ret watchQuotedLog_future(speechRecognitionLog(), onSpeechRecognized_interval, voidfunc(S s) {
    S heard = afterSquareBracketStuff(s);
    long timestamp = parseFirstLong(s);
    
    Pair<Long, S> said = lastVoiceOutputEndBeforeTimestamp(timestamp);
    if (said != null && said.a <= onSpeechRecognized_withoutMyUtterances_reallyLongDelay) {
      S info = "this (delay=" + said.a + " ms): " + heard
        + (match(heard, said.b) ? "" : " (said: " + said.b + ")");
        
      if (said.a <= onSpeechRecognized_withoutMyUtterances_magicInterval) {
        print("Assuming I said " + info);
        ret;
      } else
        print("Assuming I did not say " + info);
    }
    
    pcallF(f, heard);
  });
}

Author comment

Began life as a copy of #1014810

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1016794
Snippet name: onSpeechRecognized_withoutMyUtterances
Eternal ID of this version: #1016794/9
Text MD5: 1f5c92041a28a345857815f0935d0b6d
Author: stefan
Category: javax / speech
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-07-02 17:03:02
Source code size: 1040 bytes / 26 lines
Pitched / IR pitched: No / No
Views / Downloads: 502 / 541
Version history: 8 change(s)
Referenced in: [show references]