Alexa skills: How to prompt user for response after audio player finish playing a file - echo

I am very new at developing Alexa skill. I know that I cannot do speak, re-prompt, etc at Audioplayer.PlaybackFinished, so is there a way to ask user for response or invoke another intent after an audio file is finished playing?

You have to use SSML audio tag if you want to get an interaction.
<speak>
Hello World!
<audio src="https://m.media-amazon.com/images/G/01/mobile-apps/dex/ask-customskills/audio/lang-ssml/InParisTheyPronounceItParis._TTH_.mp3" />
What do you want?
</speak>
return handlerInput.responseBuilder
.speak(
`Hello World! <audio src="https://m.media-amazon.com/images/G/01/mobile-apps/dex/ask-customskills/audio/lang-ssml/InParisTheyPronounceItParis._TTH_.mp3" /> What do you want?`
)
.reprompt("What do you want?")
.getResponse();
And make sure your mp3 is properly encoded

If you are using an audio player directive and it seems so, then simply no.
You can not prompt any response simply because the audio player is not part of your skill. Your skill just starts the audio player and its session ends afterwards.

Related

(Flutter) How to update the AudioSource of a playlist using Just Audio keeping the shuffled order

I have a playlist generated with dummy source urls (it only has the source url of the playing audio and the others are fake) and when I click "next" I want to send an api request to get the real source url and update the sources of the playlist.
If I generate a new _playlist with the correct source and I do something like:
_audioPlayer.setAudioSource(_playlist, initialIndex: nextAudioIndex, initialPosition: Duration.zero);
the playlist (sequenceState.effectiveSequence) gets re-shuffled and the next audio of the previous order becomes the first one.
If I only do await _audioPlayer.seekToNext();, I get an error because the audio source is fake and I didn't update it with the api request result.
The reason I have dummy source urls is to not send a lot of requests at the beginning and wait for them. Is there a way to do this?

Is there a way to capture & handle "next" and "previous” using Google Actions with Actions SDK as the fulfillment tool When Media Response was sent?

I'm using the Media Response to play audio in my Actions SDK (Action SDK is being used as the Fulfillment tool in my Actions Console) driven Action. At the end of each audio clip, I'm using the MEDIA_STATUS callback to advance to another mp3 file in a predefined playlist. As a result, users should be able to navigate forwards / backwards.
When testing on my Google Home mini, Google Assistant on Android and Smart Display, I can intercept "next" and advance to the next audio clip (it sends a request with intent of type MEDIA_STATUS). However, I can't properly intercept "previous" Whenever I try, the audio will restart. Real devices seems to be handling this intent on it's own and does not throw any console output (as my webhook is not accessed at all).
Dialog Flow seem to handle "next" and "previous" as follow up intents, but I need to do the same without using Dialog Flow as the Fulfillment tool.
Can anyone please help with this particular problem?
Currently only a FINISHED event is supported for the Media Response. So, you would not be able to handle distinguish between next and previous.
Referring to #Leon Nicholls answer, I am really confused. I followed his Google Audioplayer tutorial/guide which links to an audioplayer template action
You can still download it, and if you unzip it, you will see code that is put there specifically to handle previous and next tracks.
Now it appears Leon is saying that it can't handle previous and next by voice (but buttons appear to work).
Here is the sample code below. There are links to tutorial actions in it, but now all the content has been removed. I simply need blind people to be able to select and play various bit of audio, too long for SSML, which must be navigable (at least next and pause/resume later) may be part of a playlist. How do I achieve this? Suggesting "Media Partner" or "Podcast" is not a solution as neither available in the UK.
// Handle the More/Yes/Next intents
app.intent(['More', 'Yes', 'Next'], (conv) => {
console.log(`More: fallbackCount=${conv.data.fallbackCount}`);
nextTrack(conv, false);
});
// Handle the Repeat/Previous intent
app.intent(['Repeat', 'Previous'], (conv) => {
console.log(`Repeat: ${conv.user.storage.track}`);
nextTrack(conv, false, true);
});
// Select the next track to play from the data
const nextTrack = (conv, intro, backwards) => {
console.log(`nextTrack: ${conv.user.storage.track}`);
let track = data[0];
// Persist the selected track in user storage
// https://developers.google.com/actions/assistant/save-data#save_data_across_conversations
if (conv.user.storage.track) {
conv.user.storage.track = parseInt(conv.user.storage.track, 10);
if (backwards) {

is there a way to capture & handle "Previous" using Google Actions & Media Player

I'm using the MediaObject responses to play audio in my Dialogflow driven Action. At the end of each audio clip, I'm using the mediaStatus callback to advance to another episode in a predefined playlist. As a result, users should be able to navigate forwards / backwards.
On Alexa, Next/Previous are built in intents, but my understanding is that with Google Actions, you have to handle these manually.
When testing on my Google Home, I can intercept "Hey Google, Next" and advance to the next audio clip. However, I can't properly intercept "Hey Google, Previous." Whenever I try, the audio will restart / break the conversation. Google Home seems to be handling this intent on it's own & does not throw any console output (so it's happening on device perhaps?)
Does anyone have a reliable solution for this?
If your action is still running, then the user just has to say "next" or "previous". Saying, "OK, Google..." will take it out of the context of your action and then it is up to the assistant to decide if it wants to handle the user request. Dialogflow provides follow-up intents for "next" and "previous" that you can add to your agent.
I'm working with MediaResponse as you too,
Actually I can implemented features : Next|Previous, manually.
The logic is so simple, so you don't need to get help from Google.
The logic should be :
1 - Had song list
2 - Define the selected song index
3 - Play the first song with selected song index = 0
4 - Next|Previous feature just be increase|decrease selected song index (selectedSongIndex++|selectedSongIndex--)
p/s : You can define phrase like "please next" "next" "next song" ... with your Custom Intents, to catch it

How do I play an audio file when using Fulfillment with Dialogflow

I'm making a Google Assistant action, similar to what Google does when you say "Play an E note".
I've managed to get my nodejs app to reply back the parameter, but now I need to pass an audio file. How do I do that?
The typical way to do this is to place the audio file on a hosting service somewhere (Firebase Hosting is a good choice, particularly if you're also using Firebase Cloud Functions for your Action, but any place that can serve a file via HTTPS works) and then send back SSML as your response that includes the audio.
This might look something like this:
var audioUrl = 'https://example.com/audiofile.mp3';
var msg = `<speak><audio src="${audioUrl}"></audio></speak>`
app.tell( msg );
Adjust this for your own audio file, and you might want to use app.ask() instead of tell if you are prompting the user to reply to your audio.

Track limit on SoundCloud custom player?

My custom player at woofdriver.com only shows the first 50 of my SoundCloud account's 81 tracks. How can I get the full list to display in the player? I see some references to "limit", but only in the context of the API.
I'm using this custom player http://developers.soundcloud.com/docs/custom-player and the following code to invoke it on the page. The player works great, but it just shows the first 50 tracks instead of the 81 in my stream at http://soundcloud.com/williamhelman,
$("a.wooftraxplayer").scPlayer({
autoPlay : false
});
it seams the custom player has a limit and i dont know the way around it, but maybe you can use the new stylish Widget!!
try going to the SoundCloud Widget API Playground
and entering the url:
http://api.soundcloud.com/users/williamhelman
i get more than 80 songs in the player and it has some nice features like
hope this helps
Actually, I got a response back from SoundCloud on this. When you use just the base URL for the account, it limits to 50 with the custom player. However, if you create a set, there is no such limit. So, using http://soundcloud.com/williamhelman/sets/woofdriverhits as my URL, I now get all of the tracks in the list.