diff --git a/nugu-agent/src/main/java/com/skt/nugu/sdk/agent/DefaultASRAgent.kt b/nugu-agent/src/main/java/com/skt/nugu/sdk/agent/DefaultASRAgent.kt index dd49ecd6c..2e22ce672 100644 --- a/nugu-agent/src/main/java/com/skt/nugu/sdk/agent/DefaultASRAgent.kt +++ b/nugu-agent/src/main/java/com/skt/nugu/sdk/agent/DefaultASRAgent.kt @@ -33,6 +33,7 @@ import com.skt.nugu.sdk.core.interfaces.context.* import com.skt.nugu.sdk.core.interfaces.dialog.DialogAttributeStorageInterface import com.skt.nugu.sdk.core.interfaces.directive.BlockingPolicy import com.skt.nugu.sdk.core.interfaces.directive.DirectiveHandlerResult +import com.skt.nugu.sdk.core.interfaces.directive.DirectiveProcessorInterface import com.skt.nugu.sdk.core.interfaces.focus.ChannelObserver import com.skt.nugu.sdk.core.interfaces.focus.FocusState import com.skt.nugu.sdk.core.interfaces.focus.SeamlessFocusManagerInterface @@ -55,6 +56,7 @@ import java.util.concurrent.locks.ReentrantLock import kotlin.concurrent.withLock class DefaultASRAgent( + private val directiveProcessorInterface: DirectiveProcessorInterface, private val inputProcessorManager: InputProcessorManagerInterface, private val focusManager: SeamlessFocusManagerInterface, private val messageSender: MessageSender, @@ -144,6 +146,7 @@ class DefaultASRAgent( private var focusState = FocusState.NONE private var waitingFocusInternalStartRecognitionParam: InternalStartRecognitionParam? = null + private var currentDirectiveBlocker: DirectiveProcessorInterface.Blocker? = null private var currentRequest: Pair? = null private var expectSpeechDirectiveParam: ExpectSpeechDirectiveParam? = null @@ -856,6 +859,10 @@ class DefaultASRAgent( param.callback?.onError(UUIDGeneration.timeUUID().toString(), ASRAgentInterface.StartRecognitionCallback.ErrorType.ERROR_CANNOT_START_RECOGNIZER) } else { + DirectiveProcessorInterface.Blocker(it.eventMessage.dialogRequestId, BlockingPolicy.MEDIUM_AUDIO_ONLY).also { blocker-> + currentDirectiveBlocker = blocker + directiveProcessorInterface.addDirectiveBlocker(blocker) + } currentRequest = Pair(it, param) param.callback?.onSuccess(it.eventMessage.dialogRequestId) } @@ -932,6 +939,10 @@ class DefaultASRAgent( SpeechRecognizer.State.STOP -> { currentAudioProvider?.releaseAudioInputStream(this) currentAudioProvider = null + currentDirectiveBlocker?.let { + directiveProcessorInterface.removeDirectiveBlocker(it) + } + currentDirectiveBlocker = null currentRequest = null ASRAgentInterface.State.IDLE } diff --git a/nugu-android-helper/src/main/java/com/skt/nugu/sdk/platform/android/NuguAndroidClient.kt b/nugu-android-helper/src/main/java/com/skt/nugu/sdk/platform/android/NuguAndroidClient.kt index be9474bd6..bd5aa5b1c 100644 --- a/nugu-android-helper/src/main/java/com/skt/nugu/sdk/platform/android/NuguAndroidClient.kt +++ b/nugu-android-helper/src/main/java/com/skt/nugu/sdk/platform/android/NuguAndroidClient.kt @@ -559,6 +559,7 @@ class NuguAndroidClient private constructor( } DefaultASRAgent( + getDirectiveSequencer(), getInputManagerProcessor(), getAudioSeamlessFocusManager(), getMessageSender(),