alexa-samples / skill-sample-nodejs-buttons-trivia

This is a sample trivia skill that will allow developers to get a head start on their trivia games using Echo Buttons. It allows for roll-call of the players, asking trivia questions, and determining whether the voice inputs matched the answers.
Other
32 stars 35 forks source link

ssml audio #14

Open techyontach opened 5 years ago

techyontach commented 5 years ago

I tried adding an audio file as question and removed the html tags but the skill just returns the question in text form as in https://storage.com/file.mp3 . Am I missing something here? Can you please reply with an example using audio src in the question text. I think I'm doing something wrong.

mdinescu commented 5 years ago

Can you give an example of a question where you added audio? What does the JSON object look like?

It should be something like this:

module.exports = Object.freeze({
    questions_en_US: [
        {
            index: 1,
            question: 'What object makes this sound: <audio src="soundbank://soundlibrary/transportation/amzn_sfx_car_accelerate_01" />',
            answers: ['airplane', 'car', 'train'],
            correct_answer: 'car'
        }

See: https://developer.amazon.com/docs/custom-skills/speech-synthesis-markup-language-ssml-reference.html#audio

techyontach commented 5 years ago

Like this:

{
          index: 1,
          question: '<audio src="https://www.storage.com/file.mp3" />',
          answers: ['cobra', 'coral snake', 'copperhead', 'adder'],
          correct_answer: 'adder'
      }
mdinescu commented 5 years ago

The way you have it should work. Of course, assuming the URL is a valid audio file, as explained here: https://developer.amazon.com/docs/custom-skills/speech-synthesis-markup-language-ssml-reference.html#audio

This is where the question is added to the output speech queue: https://github.com/alexa/skill-sample-nodejs-buttons-trivia/blob/master/lambda/custom/utils/game.js#L712 and as you can see, the question text is not changed.

This is where the output speech queue is rendered, and again, there is nothing in here that would modify the question text: https://github.com/alexa/skill-sample-nodejs-buttons-trivia/blob/master/lambda/custom/handlers/globalHandlers.js#L108-L113

When you say that "the skill just returns the question in text form as in https://storage.com/file.mp3", are you saying that Alexa spells out the URL?