Actions on google 可以播放音频文件或流吗?

Actions on google 可以播放音频文件或流吗?,actions-on-google,dialogflow-es,google-home,Actions On Google,Dialogflow Es,Google Home,可以使用library播放音频文件或流吗?使用可以返回最长120秒的音频剪辑 <speak> <audio src="https://actions.google.com/sounds/v1/animals/cat_purr_close.ogg"> <desc>a cat purring</desc> PURR (sound didn't load) </audio> </speak> 为了给Nic

可以使用library播放音频文件或流吗?

使用可以返回最长120秒的音频剪辑

<speak>
  <audio src="https://actions.google.com/sounds/v1/animals/cat_purr_close.ogg">
    <desc>a cat purring</desc>
    PURR (sound didn't load)
  </audio>
</speak>

为了给Nick的答案增加一点,你还可以建立一个媒体响应,允许你播放一个长的音频文件(我目前正在我的应用程序中播放50分钟的专辑)。 你可以在谷歌的文档上找到它

Node.js中的一个简短示例可以是:

const richResponse = app.buildRichResponse()
 .addSimpleResponse("Here's song one.")
  .addMediaResponse(app.buildMediaResponse()
  .addMediaObjects([
    app.buildMediaObject("Song One", "https://....mp3")
      .setDescription("Song One with description and large image.") // Optional
      .setImage("https://....jpg", app.Media.ImageType.LARGE)
        // Optional. Use app.Media.ImageType.ICON if displaying icon.
  ])
)
.addSuggestions(["other songs"]);
然后你就可以

app.ask(richResponse)
更新:

根据评论请求,以下是我的应用程序为mediaResponse发送的JSON响应:

{
  "conversationToken": "[\"_actions_on_google\"]",
  "expectUserResponse": true,
  "expectedInputs": [
    {
      "inputPrompt": {
        "richInitialPrompt": {
          "items": [
            {
              "simpleResponse": {
                "textToSpeech": "Here is my favorite album."
              }
            },
            {
              "mediaResponse": {
                "mediaType": "AUDIO",
                "mediaObjects": [
                  {
                    "name": my_name,
                    "description": my_descr,
                    "largeImage": {
                      "url": my_url
                    },
                    "contentUrl": my_contentURL
                  }
                ]
              }
            }
          ],
          "suggestions": [
            {
              "title": my_suggestion
            }
          ]
        }
      },
      "possibleIntents": [
        {
          "intent": "assistant.intent.action.TEXT"
        }
      ]
    }
  ],
  "responseMetadata": {
    "status": {
      "message": "Success (200)"
    },
    "queryMatchInfo": {
      "queryMatched": true,
      "intent": "0a3c14f8-87ca-47e7-a211-4e0a8968e3c5",
      "parameterNames": [
        my_param_name
      ]
    }
  },
  "userStorage": "{\"data\":{}}"
}

不高吗?我想在播放中播放完整的播客。不幸的是,不支持完整的播客播放,至少不支持这种方式。你可以阅读播客动作。SSML不够长,我无法播放。这不是我想要的答案。直播内容呢?直播媒体流在这个平台上不受支持。我试过,它似乎只能播放mp3。你能在这里发布一个REST(Json)响应格式吗。我正在Google Home中寻找流媒体音频,但我可能没有使用他们提供的nodejs sdk。@Vikram当然,我会用Google simulator上的操作获得的响应选项卡更新我的答案。
{
  "conversationToken": "[\"_actions_on_google\"]",
  "expectUserResponse": true,
  "expectedInputs": [
    {
      "inputPrompt": {
        "richInitialPrompt": {
          "items": [
            {
              "simpleResponse": {
                "textToSpeech": "Here is my favorite album."
              }
            },
            {
              "mediaResponse": {
                "mediaType": "AUDIO",
                "mediaObjects": [
                  {
                    "name": my_name,
                    "description": my_descr,
                    "largeImage": {
                      "url": my_url
                    },
                    "contentUrl": my_contentURL
                  }
                ]
              }
            }
          ],
          "suggestions": [
            {
              "title": my_suggestion
            }
          ]
        }
      },
      "possibleIntents": [
        {
          "intent": "assistant.intent.action.TEXT"
        }
      ]
    }
  ],
  "responseMetadata": {
    "status": {
      "message": "Success (200)"
    },
    "queryMatchInfo": {
      "queryMatched": true,
      "intent": "0a3c14f8-87ca-47e7-a211-4e0a8968e3c5",
      "parameterNames": [
        my_param_name
      ]
    }
  },
  "userStorage": "{\"data\":{}}"
}