Advertisement
BoberDiversant

Untitled

Nov 17th, 2019
454
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.70 KB | None | 0 0
  1. if (message instanceof PlayCollectSpeech.FullSpeech) {
  2.             String recognition = ((PlayCollectSpeech.FullSpeech) message).getMostConfidenceRecognitionText().toLowerCase();
  3.             Optional<Map.Entry<O, Option>> matchOption = optionMap.entrySet().stream()
  4.                     .filter(option ->
  5.                             recognition.contains(option.getValue().getId())
  6.                                     || option.getValue().getLocalizedVariants(locale).stream().anyMatch(recognition::contains)
  7.                     )
  8.                     .max((option1, option2) -> compare2Options(option1, option2, recognition));
  9.             if (matchOption.isPresent()) {
  10.                 platform.accept(log(format("recognise option(%s) on asr", matchOption.get().getValue().getId()),
  11.                         ImmutableMap.of("sid", message.getSession().getSid(), "question", question, "recognition",
  12.                                 ((PlayCollectSpeech.Speech) message).getRecognition())));
  13.                 return states.waitStop.withData(states.options.get(matchOption.get().getKey()).withData(matchOption.get().getValue().getId()));
  14.             } else {
  15.                 platform.accept(log("unknown option on speech complete",
  16.                         ImmutableMap.of("sid", message.getSession().getSid(), "question", question, "recognition",
  17.                                 ((PlayCollectSpeech.Speech) message).getRecognition())));
  18.                 platform.accept(result(question, ((PlayCollectSpeech.Speech) message).getMostConfidenceRecognitionText()));
  19.                 return states.waitStop.withData(unknownState.withData(((PlayCollectSpeech.Speech) message).getMostConfidenceRecognitionText()));
  20.             }
  21.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement