Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (message instanceof PlayCollectSpeech.FullSpeech) {
- String recognition = ((PlayCollectSpeech.FullSpeech) message).getMostConfidenceRecognitionText().toLowerCase();
- Optional<Map.Entry<O, Option>> matchOption = optionMap.entrySet().stream()
- .filter(option ->
- recognition.contains(option.getValue().getId())
- || option.getValue().getLocalizedVariants(locale).stream().anyMatch(recognition::contains)
- )
- .max((option1, option2) -> compare2Options(option1, option2, recognition));
- if (matchOption.isPresent()) {
- platform.accept(log(format("recognise option(%s) on asr", matchOption.get().getValue().getId()),
- ImmutableMap.of("sid", message.getSession().getSid(), "question", question, "recognition",
- ((PlayCollectSpeech.Speech) message).getRecognition())));
- return states.waitStop.withData(states.options.get(matchOption.get().getKey()).withData(matchOption.get().getValue().getId()));
- } else {
- platform.accept(log("unknown option on speech complete",
- ImmutableMap.of("sid", message.getSession().getSid(), "question", question, "recognition",
- ((PlayCollectSpeech.Speech) message).getRecognition())));
- platform.accept(result(question, ((PlayCollectSpeech.Speech) message).getMostConfidenceRecognitionText()));
- return states.waitStop.withData(unknownState.withData(((PlayCollectSpeech.Speech) message).getMostConfidenceRecognitionText()));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement