Help us understand the problem. What is going on with this article?

APL(Alexa Presentation Language)のSpeakItemでmp3を鳴らす

More than 1 year has passed since last update.

こんにちは

APLのSpeakItemの中でaudioタグを書いてもmp3が鳴らない仕様があり永らく悩んでいたのですが、APLでmp3を鳴らす方法を見つけたのでざっくり共有します。

追記(2019/6)

echo show5やFireTV一部の機種において、通常のspeakとAPLのSpeakItemを併用するとフリーズする症状を確認しています。通常のspeakを使わずに全てSpeakItemのみで鳴らす事で回避可能です。

例えば

hoge.mp3をAPLで鳴らすAPLを送るとします。
解説の都合上、datasourcesとExecuteCommandsから先に。

datasources-1
"datasources": {
  "pagerAnimationData": {
    "properties": {
      "topicSsml": [
        "<speak><audio src=\"https://s3-ap-.../hoge.mp3\" /></speak>"
      ],
    },
    "transformers": [
      {
        "inputPath": "topicSsml",
        "outputName": "topicSpeech",
        "transformer": "ssmlToSpeech"
      },
      {
        "inputPath": "topicSsml",
        "outputName": "topicText",
        "transformer": "ssmlToText"
      }
    ]
  }
}
ExecuteCommands(抜粋)
{
  "type": "SpeakItem",
  "componentId": "talk_0"
}

鳴らない

さて、以下のようにDocumentを書いておいても鳴りません。

document-1(抜粋)
{
  "type": "Text",
  "id": "talk_0",
  "text": "(音声再生中)",
  "speech": "${payload.pagerAnimationData.properties.topicSpeech[0]}",
  "position": "absolute",
  "width": 0,
  "height": 0
}

以下でもダメでした。

document-1a(差分)
  "speech": "${payload.pagerAnimationData.properties.topicSsml[0]}",

鳴る

下記のように、speechに直接URLを指定すると鳴らす事が出来ます。

datasources-2
"datasources": {
  "pagerAnimationData": {
    "properties": {
      "topicSsml": [
        "(ここにはSSML書かない)"
      ],
      "topicSound": [
        "https://s3-ap-.../hoge.mp3"
      ]
    },
    "transformers": [
      {
        "inputPath": "topicSsml",
        "outputName": "topicSpeech",
        "transformer": "ssmlToSpeech"
      },
      {
        "inputPath": "topicSsml",
        "outputName": "topicText",
        "transformer": "ssmlToText"
      }
    ]
  }
}
document-2
{
  "type": "Text",
  "id": "talk_0",
  "text": "(音声再生中)",
  "speech": "${payload.pagerAnimationData.properties.topicSound[0]}",
  "position": "absolute",
  "width": 0,
  "height": 0
}

気をつける点

開発コンソールのシミュレータでは鳴らない(動作が止まる)のでご注意ください。
・念のためtransformersの影響を受けない場所に置いたほうがいいかも。(未検証)

参考

Alexa Command SpeakItem coupled with self provided mp3 ? - Forums

kyukkyu81
入社したのは1999年9月の事じゃった…すぐさま空気も読まずにY2K問題という恐怖のモンスターが夢と希望と睡眠時間を奪いに襲いかかっt
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした