Play audio after intent is invoked for Google Action

120 Views Asked by At

I need help understanding the way SSML works for google action.

I would like a sound to be played when my intent is called something like so:

function playAudio(assistant) {
      let text_to_speech = '<speak>'
        + 'I can play a sound'
        + '<audio src="https://actions.google.com/sounds/v1/alarms/digital_watch_alarm_long.ogg">a digital watch alarm</audio>. '
        + '</speak>'
      assistant.tell(text_to_speech);
    };

app.intent('my-intent', (conv) => {

 playAudio(conv);

});

It seems that this is the wrong syntax for such a function, I am not sure how i am supposed to appropriately call playAudio(), it seems that 'conv' is not the correct parameter.

1

There are 1 best solutions below

1
On BEST ANSWER

I'm not sure where this tell() function came from, It seems that ask() can handle ssml just fine.

app.intent('my-intent', (conv) => {

  const ssml = '<speak>Hi! <break time="1"/> ' +
  'I can read out an ordinal like <say-as interpret-as="ordinal">123</say-as>. ' +
  'Say a number.</speak>'
conv.ask(ssml)
});