简体   繁体   中英

Alexa Trivia Quiz: trying to add custom audio file in the new game message

I'm trying to add a custom audio file in a Alexa quiz, but can't seem to figure it out. I'm basically using everything from https://github.com/alexa/skill-sample-nodejs-quiz-game just tweaked. Below is the JSON speech code for the text. Also, I'm a hobbyist not really a developer so I'm sorry if this totally doesn't make sense.

 const languageString = { en: { translation: { QUESTIONS: questions.QUESTIONS_EN_US, GAME_NAME: 'Trivia', HELP_MESSAGE: 'I will ask you %s multiple choice questions. Respond with the number of the answer. For example, say one, two, three, or four. To start a new game at any time, say, start game. ', REPEAT_QUESTION_MESSAGE: 'To repeat the last question, say, repeat. ', ASK_MESSAGE_START: 'Would you like to start playing?', HELP_REPROMPT: 'To give an answer to a question, respond with the number of the answer. ', STOP_MESSAGE: 'Would you like to keep playing?', QUIT_MESSAGE: 'Good bye.', CANCEL_MESSAGE: 'Ok, let\'s play again soon.', NO_MESSAGE: 'Ok, we\'ll play another time. Goodbye,': TRIVIA_UNHANDLED, 'Try saying a number between 1 and %s': HELP_UNHANDLED, 'Say yes to continue. or no to end the game,': START_UNHANDLED. 'Say start to start a new game,': NEW_GAME_MESSAGE. 'Welcome to %s, ': WELCOME_MESSAGE, 'I will ask you %s questions. try to get as many right as you can. Just say the number of the answer. Let\'s begin, ': ANSWER_CORRECT_MESSAGE. 'correct, ': ANSWER_WRONG_MESSAGE. 'wrong, ': CORRECT_ANSWER_MESSAGE: 'The correct answer is %s. %s, ': ANSWER_IS_MESSAGE, 'That answer is ': TELL_QUESTION_MESSAGE. 'Question %s, %s ': GAME_OVER_MESSAGE. 'You got %s out of %s questions correct, Thank you for playing:'. SCORE_IS_MESSAGE, 'Your score is %s, ' }, },

You can just add the tags right in your response strings like

playback = 'Here is a sound <audio src="soundbank://soundlibrary/animals/amzn_sfx_bear_groan_roar_01"/>';

The thing to watch out for would be to make sure you use the correct quotes.

Here is a list of all of the Amazon sound library sounds that are available to you. https://developer.amazon.com/en-US/docs/alexa/custom-skills/ask-soundlibrary.html

you can also go right to the alexa developer console and go to the Voice and Tone Tab to test our the syntax. It is going to be encapsulated in a speak tag, but normally you done have to worried about that as it is handled for you.

Alexa 开发控制台[1]

The code to drop in is:

<speak>
<audio src="soundbank://soundlibrary/animals/amzn_sfx_bear_groan_roar_01"/>
</speak>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM