alexa / avs-device-sdk

An SDK for commercial device makers to integrate Alexa directly into connected products.
https://developer.amazon.com/alexa/alexa-voice-service
Apache License 2.0
1.26k stars 604 forks source link

How can I barge-in during play shopping list? #280

Closed boyce-xx closed 6 years ago

boyce-xx commented 7 years ago

I got a problem when playing shopping list: after I say a wakeword, to stop mediaplayer, but I still can get "SpeechSynthesizer" directive, then it will play next shopping list item.

so, how can I stop the shopping list when I want to barge-in it.

thanks.

frozenberg commented 7 years ago

Hi @boyce-xx, could you provide the logs from when you encountered this issue?

Make sure to pass the flag "-DCMAKE_BUILD_TYPE=DEBUG" when you run cmake and to add the "DEBUG9" flag when you run the ./SampleApp program

boyce-xx commented 7 years ago

Hi @frozenberg , I have put log to this, but I don't use SampleApp to run, I'm using my custom APP.

The SPEAK which is saying that I have 5 items on my shopping list has same DialogID as Recognize event: 2017-11-09 12:38:12.072 [ e] I DirectiveSequencer:onDirective:UnparsedDirective={"directive"\:{"header"\:{"namespace"\:"SpeechSynthesizer"\,"name"\:"Speak"\,"messageId"\:"fea4a343-4eca-4944-9844-03b1eb340692"\,"dialogRequestId"\:"9e81da2a-ac77-4108-b7a6-57deb0329fae"}\,"payload"\:{"url"\:"cid\:NamedListIntroductionWithSizePrompt.v1ba3dea1d-b59d-40b2-b79d-c4be51bede56_502137127"\,"format"\:"AUDIO_MPEG"\,"token"\:"amzn1.as-ct.v1.Domain\:Application\:Lists#ACRI#NamedListIntroductionWithSizePrompt.v1ba3dea1d-b59d-40b2-b79d-c4be51bede56"}}}

But all SPEAK directives that are arriving after that, one for each ITEM on shopping list, does not have dialodID. 2017-11-09 12:38:16.082 [ e] I DirectiveSequencer:onDirective:UnparsedDirective={"directive"\:{"header"\:{"namespace"\:"SpeechSynthesizer"\,"name"\:"Speak"\,"messageId"\:"6b4086e2-5d17-4f3d-8cc4-384f2208142d"}\,"payload"\:{"url"\:"cid\:82a2b433-087a-34b1-a0a9-abd57085434236e0664a-a4dc-417f-91b1-ec6de1c4e0df_1486976022"\,"format"\:"AUDIO_MPEG"\,"token"\:"amzn1.as-ct.v1.Domain\:Application\:Lists#ACRI#82a2b433-087a-34b1-a0a9-abd57085434236e0664a-a4dc-417f-91b1-ec6de1c4e0df"}}}

Do you have any suggestions?

scotthea-amazon commented 7 years ago

Hi @boyce-xx,

The absence of dialogRequestId values on some Speak directives in list enumerations returned by AVS is a known issue. There are efforts underway to address this problem.

In these cases, each Speak directive after the first is sent in response to a SpeechFinished event sent by the client. Barge-in should cancel any ongoing or queued Speak directive, and prevent SpeechFinished from being sent. That in turn should stop the enumeration of the list.

However, there is a small window of time between the sending of SpeechFinished and the arrival of the next Speak directive. A barge that occurs inside that window has nothing to cancel, so the barge in is ignored.

Are you experiencing barge-in failing consistently (in which case it may be that an ongoing Speak directive is not getting interrupted, or if interrupted it may still be sending SpeechFinished), or is this only happening occasionally (in which case it may be a symptom of barge-in between sending SpeechFinished and the next Speak directive) ?

Looking at the logs you posted, I think you are experiencing the problem occasionally, when barge-in occurs inside that window described above. Here is an annotated excerpt of your logs that seems to indicate this:

** SpeechFinished event sent for a list item**
2017-11-09 12:38:19.551 [  7] 0 EventBuilder:buildJsonEventString:messageId=67e433e7-77ef-4766-ae16-af17ff9f2256,namespace=SpeechSynthesizer,name=SpeechFinished
AVSConnectionManager::sendMessage {"event":{"header":{"namespace":"SpeechSynthesizer","name":"SpeechFinished","messageId":"67e433e7-77ef-4766-ae16-af17ff9f2256"},"payload":{"token":"amzn1.as-ct.v1.Domain:Application:Lists#ACRI#82a2b433-087a-34b1-a0a9-abd57085434236e0664a-a4dc-417f-91b1-ec6de1c4e0df"}}}

**Recognizing begins**
2017-11-09 12:38:20.306 [  9] 0 AudioInputProcessor:setState:from=IDLE,to=RECOGNIZING

**Speak directive for next list item arrives**
2017-11-09 12:38:21.590 [  e] I DirectiveSequencer:onDirective:UnparsedDirective={"directive"\:{"header"\:{"namespace"\:"SpeechSynthesizer"\,"name"\:"Speak"\,"messageId"\:"2dca958c-4016-4616-aadf-01c61f9ae173"}\,"payload"\:{"url"\:"cid\:598a5cd1-ae73-396c-bc33-6070c37c1de5939c66f6-d67b-44e5-83f9-f38bb901b2ac_1731580980"\,"format"\:"AUDIO_MPEG"\,"token"\:"amzn1.as-ct.v1.Domain\:Application\:Lists#ACRI#598a5cd1-ae73-396c-bc33-6070c37c1de5939c66f6-d67b-44e5-83f9-f38bb901b2ac"}}}

**Subsequent speak directive steals focus from Audio Input Processor**
2017-11-09 12:38:21.597 [ 11] 0 SpeechSynthesizer:onFocusChanged:newFocus=FOREGROUND
2017-11-09 12:38:21.598 [  9] 0 AudioInputProcessor:executeOnFocusChanged:newFocus=NONE
2017-11-09 12:38:21.598 [  9] 0 AudioInputProcessor:executeOnFocusChanged:reason=Lost focus

If that is what you are experiencing, then the defect is in the AVS service and not the client.

Thank you, -SWH

boyce-xx commented 7 years ago

Hi @frozenberg ,

Thanks for your reply. I'm experiencing the problem consistently, as my log showed, I am start to barge-in when alexa speaking the second shopping list item, then the error happen.

I'm using Sensory+WAKEWORD profile to start recognize a request, when I speak "Alexa", sensory wakeword detector will be detected, then it will send speechFinished event to alexa. maybe that is the cause result in this issue.

waiting for your solution.

thanks!

mradulan commented 6 years ago

@boyce-xx , can you try with the latest SDK version 1.3 to see if the issue still exists. If not please close the issue.

boyce-xx commented 6 years ago

Hi @mradulan , Yes, I have verified the issue with the SDK V1.3.0, the issue is still exists.

boyce-xx commented 6 years ago

Hi @mradulan , The issue has been fixed, so I close this case. Thank you.