From 8b041bd856bf45b114c2513e8e7dcfe93620c6b4 Mon Sep 17 00:00:00 2001 From: Fran Riadigos Date: Thu, 25 Mar 2021 12:28:00 +0100 Subject: [PATCH] [bug] Fixing speech checking --- android-buildsystem | 2 +- .../assistant/InteractiveAssistant.java | 4 ++++ .../assistant/InteractiveAssistantImpl.java | 20 ++++++++++++++++--- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/android-buildsystem b/android-buildsystem index 121a36b..659da3f 160000 --- a/android-buildsystem +++ b/android-buildsystem @@ -1 +1 @@ -Subproject commit 121a36b29d7f6fa4636d5c60ed309efec0e8f333 +Subproject commit 659da3f5e4de5e7f9e1693bc4ef4b6d1ad802635 diff --git a/interactive-assistant/src/main/java/chattylabs/assistant/InteractiveAssistant.java b/interactive-assistant/src/main/java/chattylabs/assistant/InteractiveAssistant.java index 54b6b21..52f1f59 100644 --- a/interactive-assistant/src/main/java/chattylabs/assistant/InteractiveAssistant.java +++ b/interactive-assistant/src/main/java/chattylabs/assistant/InteractiveAssistant.java @@ -120,6 +120,10 @@ public InteractiveAssistant build() { void setupSpeech(SynthesizerListener.OnStatusChecked listener); + boolean isCheckingSpeech(int requestCode); + + void checkSpeech(int resultCode); + void release(); void pause(); diff --git a/interactive-assistant/src/main/java/chattylabs/assistant/InteractiveAssistantImpl.java b/interactive-assistant/src/main/java/chattylabs/assistant/InteractiveAssistantImpl.java index 77e9523..a6bc89d 100644 --- a/interactive-assistant/src/main/java/chattylabs/assistant/InteractiveAssistantImpl.java +++ b/interactive-assistant/src/main/java/chattylabs/assistant/InteractiveAssistantImpl.java @@ -438,19 +438,33 @@ public void setupSpeech(RecognizerListener.OnStatusChecked listener) { hideLoading(); listener.execute(recognizerStatus); }); - // TODO: P2 - to show TTS error screen }); } + private SynthesizerListener.OnStatusChecked synthesizerStatusCheckListener; + @Override public void setupSpeech(SynthesizerListener.OnStatusChecked listener) { + synthesizerStatusCheckListener = listener; showLoading(); Objects.requireNonNull(voiceComponent).checkSpeechSynthesizerStatus(context, synthesizerStatus -> { context.runOnUiThread(() -> { hideLoading(); - listener.execute(synthesizerStatus); + synthesizerStatusCheckListener.execute(synthesizerStatus); + }); + }); + } + + @Override public boolean isCheckingSpeech(int requestCode) { + return voiceComponent.isCheckingSpeech(requestCode); + } + + @Override public void checkSpeech(int resultCode) { + voiceComponent.checkSpeech(resultCode, synthesizerStatus -> { + context.runOnUiThread(() -> { + hideLoading(); + synthesizerStatusCheckListener.execute(synthesizerStatus); }); - // TODO: P2 - to show TTS error screen }); }