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

26
LINES

< > BotCompany Repo | #1016835 // isItMyUtterance

JavaX fragment (include)

scope isItMyUtterance.

static int #magicInterval = 2000;
static int #reallyLongDelay = 10000;

// returns (bool result, assumptions)
static Pair<Bool, S> isItMyUtterance(long timestamp, S heard) {
  Pair<Long, S> said = lastVoiceOutputEndBeforeTimestamp(timestamp);
  if (said != null && said.a <= reallyLongDelay) {
    S info = "this (delay=" + said.a + " ms): " + heard
      + (match(heard, said.b) ? "" : " (said: " + said.b + ")");
      
    if (said.a <= magicInterval) {
      ret pair(true, "Assuming I said " + info);
    } else
      ret pair(false, "Assuming I did not say " + info);
  } else ret pair(false, "");
}

static Pair<Bool, S> isItMyUtterance(S s) {
  S heard = afterSquareBracketStuff(s);
  long timestamp = parseFirstLong(s);
  ret isItMyUtterance(timestamp, heard);
}

end scope

Author comment

Began life as a copy of #1016794

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: #1016835
Snippet name: isItMyUtterance
Eternal ID of this version: #1016835/4
Text MD5: d326796264afe568fade9b3667245f6a
Author: stefan
Category: javax / speech
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-07-06 17:46:16
Source code size: 831 bytes / 26 lines
Pitched / IR pitched: No / No
Views / Downloads: 364 / 414
Version history: 3 change(s)
Referenced in: [show references]