question

coolcoder001 avatar image
coolcoder001 asked ·

Alexa is not giving me the audio output when uttered the same intent

Hi , I want to play an alert (basically a large mp3 file 1 hour long ) on speaking up an utterance

and stop it while saying another utterance.

Here is my response after invoking the alert :

{ "body": { "version": "1.0", "response": { "outputSpeech": { "type": "SSML", "ssml": "<speak>Alerting people</speak>" }, "directives": [ { "type": "AudioPlayer.Play", "playBehavior": "ENQUEUE", "audioItem": { "stream": { "expectedPreviousToken": "https://s3.amazonaws.com/helloshounaktest/aaj_0345_Fire_Alarm_01.mp3", "token": "https://s3.amazonaws.com/helloshounaktest/aaj_0345_Fire_Alarm_01.mp3", "url": "https://s3.amazonaws.com/helloshounaktest/aaj_0345_Fire_Alarm_01.mp3", "offsetInMilliseconds": 0 } } } ] }, "userAgent": "ask-java/2.6.0 Java/1.8.0_141" } }

And this is the response when I say it to stop :

{
"body": {
"version": "1.0",
"response": {
"outputSpeech": {
"type": "SSML",
"ssml": "<speak>Stopping the alert and clearing alert.</speak>"
},
"directives": [
{
"type": "AudioPlayer.Stop"
},
{
"type": "AudioPlayer.ClearQueue",
"clearBehavior": "CLEAR_ALL"
}
]
},
"userAgent": "ask-java/2.6.0 Java/1.8.0_141"
}
}

Now , my issue is , for the first time . Alexa is able to play the file .

It is also able to stop playing the file.

But, next time onwards no file is played.


Can you please help me ?I am not able to find any solution for this problem.

Here is my code to invoke the mp3 file.

PlayBehavior playBehaviour = PlayBehavior.ENQUEUE;
String url = "https://s3.amazonaws.com/helloshounaktest/aaj_0345_Fire_Alarm_01.mp3";
return input.getResponseBuilder()
.withSpeech("Alerting people")
.addAudioPlayerPlayDirective(playBehaviour, 0L, url, url, url)
.build()
;

and this is the piece of code to stop playing it:

Optional<Response> response = null;
AudioPlayerState playerState=input.getRequestEnvelope().getContext().getAudioPlayer();
if(playerState!=null) {
PlayerActivity activity=playerState.getPlayerActivity();
if(activity!=null) {
String name = activity.toString();
System.out.println("name ==> "+name);
if(name.equalsIgnoreCase("playing")) {

//response=input.getResponseBuilder()
//.withSpeech("Stopping the alert")
//.addAudioPlayerStopDirective().build();
}
}

}else {
System.out.println("Player state is null");
}
ClearBehavior clearBehavior = ClearBehavior.CLEAR_ALL;
response=input.getResponseBuilder()
.withSpeech("Stopping the alert and clearing alert.")
.addAudioPlayerStopDirective()
.addAudioPlayerClearQueueDirective(clearBehavior)
.build();
return response;
alexa skills kitalexaalexa simulatoralexa dev daysalexa skills challenge
10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Tsuneki@Amazon avatar image
Tsuneki@Amazon answered ·

Hi there,

Foe further investigation, could you share your skill ID and reproduce steps of the issue?

10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.