Alexa 技能中的 Amazon Polly?

Amazon Polly in Alexa Skill?

是否可以在 Alexa 技能中使用 amazon Polly 在翻译或其他多语言环境中提供例如 2 种语言的响应? 如果是,谁有通过 lambda 函数使用此服务的经验?

更新: 根据 这个答案已经更新以反映 Polly 的最新变化。 Polly 现在无需转换即可与 Alexa 一起使用,不再需要下面的步骤 7-9。

我更新了以下步骤以反映基于项目alexa-meets-polly.

通过lambda函数使用Polly w/Alexa的新过程

来自 alexa-meets-polly:

  1. User speaks to an Alexa device and asks for e.g. "What is "Good Morning" in Polish?"

  2. NLU of Alexa triggers the Translate-intent and passes in a language-slot with value Polish and a term-slot having the value Good Morning. An AWS Lambda function whose code is contained in this Repo implements a Speechlet that handles the request and returns the translation.

  3. Before this skill uses the translation API and TTS service of Polly, it first looks into its own dictionary where all the previous translations are stored. If it finds a record for Good Morning in Polish in the database it will skip the entire round-trip (step 4 to 9) and uses the S3 audio-file referenced in the Dynamo record (learn how it got there in step 10.)

  4. However, if Good Morning in Polish has never been translated before the skill requests Good Morning in Polish from Microsoft Translator API (or interchangeably from Google Translate).

  5. The returned translation is then passed to AWS Polly. Polly responds with an MP3 bitstream with the spoken translation.

  6. The stream is persisted in AWS S3 as an mp3-file.

7.-9. No custom conversion of Polly-mp3 necessary anymore as it's now aligned to Alexa requirements.

  1. Finally, a record is created for Good Morning in Polish in the Dynamo dictionary. Another record that references the new dictionary entry is created for the user so Alexa keeps in mind the last translation. This is how a user can request Alexa to repeat the most recent translation.

  2. The skill creates the output-speech text and squeezes in an audio-SSML tag with the mp3-url.

  3. Output-speech is returned to the Alexa device. Alexa speaks and plays back the translated text with one of Polly's voices. A card is returned to the Alexa app providing the written translation.