Reputation: 7
I'm currently new into nodejs, but I've been trying to make an Alexa Skill using the Nodejs Trivia Sample provided on GitHub.
Nothing has been modified in the code, just the content (questions). The change is, instead of Question (words), I would like to to play Audio MP3. That should/is possible using SSML Audio
I tried to do that, but my Skill wouldn't work that way, won't even start.
Here's original sample:
{
'What Makes Santa\'s Reindeer Fly?': [
'Magical Reindeer Dust',
'Fusion',
'Amanita muscaria',
'Elves',
],
},
What I did, using the Audio SSML:
{
'<audio src="link_to_the.mp3' />": [
'Magical Reindeer Dust',
'Fusion',
'Amanita muscaria',
'Elves',
],
},
The github source: https://github.com/alexa/skill-sample-nodejs-trivia/tree/en-US/lambda/custom
What am I doing wrong here? It's supposed to work, right?
Upvotes: 0
Views: 648
Reputation: 194
Please check your audio length(The audio file cannot be longer than ninety (90) seconds) and make sure you have converted the mp3 to correct format.
I hope you have gone through this documentation - Using Audio in Your Response
Edit:- Hey, I just tried and found a solution.
{ 'https://mp3_link': [ 'Magical Reindeer Dust', 'Fusion', 'Amanita muscaria', 'Elves', ], },
In the index.js file, find the variable named "spokenquestion" and add the audio tag to it. Find example below
const spokenQuestion = '<audio src="'+Object.keys(translatedQuestions[gameQuestions[currentQuestionIndex]])[0]+'" />';
Note: This will only work when you include the mp3 link to all the questions. If some questions have mp3 links and some questions have text then please add conditions accordingly. Find sample example below
if(question.substring have https) then audio else text
Edit 2 : 1.Add audio file name in the question.
{ 'name_of_the _audio_file': [ 'Magical Reindeer Dust', 'Fusion', 'Amanita muscaria', 'Elves', ], },
2.Add audio link in the audio tag
const spokenQuestion = '<audio src="https://s3.amazonaws.com/s3_bucket_name/'+Object.keys(translatedQuestions[gameQuestions[currentQuestionIndex]])[0]+'.mp3" />';
Upvotes: 1