- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我尝试使用 MediaObject 播放音频,MediaObject 未播放给定的 mp3 音频文件,但我收到以下错误消息“必须设置 MalformedResponse 'final_response'。”
'use strict';
const functions = require('firebase-functions');
const {WebhookClient} = require('dialogflow-fulfillment');
const {Card, Suggestion} = require('dialogflow-fulfillment');
const {
dialogflow,
BasicCard,
BrowseCarousel,
BrowseCarouselItem,
Button,
Carousel,
LinkOutSuggestion,
List,
MediaObject,
Suggestions,
SimpleResponse,
} = require('actions-on-google');
process.env.DEBUG = 'dialogflow:debug'; // enables lib debugging statements
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
const agent = new WebhookClient({ request, response });
console.log('Dialogflow Request headers: ' + JSON.stringify(request.headers));
console.log('Dialogflow Request body: ' + JSON.stringify(request.body));
function welcome(agent) {
agent.add(`Welcome to my agent!`);
}
function fallback(agent) {
agent.add(`I didn't understand`);
agent.add(`I'm sorry, can you try again?`);
}
// // Uncomment and edit to make your own intent handler
// // uncomment `intentMap.set('your intent name here', yourFunctionHandler);`
// // below to get this function to be run when a Dialogflow intent is matched
function yourFunctionHandler(agent) {
agent.add(`This message is from Dialogflow's Cloud Functions for Firebase editor!`);
let conv = agent.conv();
conv.ask(new Suggestions('Suggestion Chips'));
conv.close(new MediaObject({
name: 'Jazz in Paris',
url: 'https://storage.googleapis.com/automotive-media/Jazz_In_Paris.mp3',
description: 'A funky Jazz tune',
icon: new Image({
url: 'https://storage.googleapis.com/automotive-media/album_art.jpg',
alt: 'Media icon',
}),
}));
conv.ask(new Suggestions(['suggestion 1', 'suggestion 2']));
}
// Run the proper function handler based on the matched Dialogflow intent name
let intentMap = new Map();
//intentMap.set('Default Welcome Intent', welcome);
//intentMap.set('Default Fallback Intent', fallback);
intentMap.set('PlaySongIntents', yourFunctionHandler);
// intentMap.set('your intent name here', googleAssistantHandler);
agent.handleRequest(intentMap);
});
我收到的回复如下
"responseMetadata": {
"status": {
"code": 10,
"message": "Failed to parse Dialogflow response into AppResponse because of empty speech response",
"details": [
{
"@type": "type.googleapis.com/google.protobuf.Value",
"value": "{\"id\":\"ff0ee47a-9df3-46c9-97db-f6db6442179b\",\"timestamp\":\"2018-06-15T09:42:53.424Z\",\"lang\":\"en-us\",\"result\":{},\"status\":{\"code\":206,\"errorType\":\"partial_content\",\"errorDetails\":\"Webhook call failed. Error: Request timeout.\"},\"sessionId\":\"1529055750970\"}"
}
]
}
}
}
最佳答案
该错误消息表明您没有包含除要播放的音频之外应说明的消息。需要随音频一起包含 SimpleResponse
。
您混合了 Dialogflow 响应和 Actions on Google 响应,这可能会使响应解析器感到困惑。您应该将 SimpleResponse
添加到 conv
对象作为响应的一部分。所以这部分代码可能看起来像这样:
function yourFunctionHandler(agent) {
let conv = agent.conv();
conv.ask(new SimpleResponse("Here is a funky Jazz tune"));
conv.ask(new Suggestions(['suggestion 1', 'suggestion 2']));
conv.close(new MediaObject({
name: 'Jazz in Paris',
url: 'https://storage.googleapis.com/automotive-media/Jazz_In_Paris.mp3',
description: 'A funky Jazz tune',
icon: new Image({
url: 'https://storage.googleapis.com/automotive-media/album_art.jpg',
alt: 'Media icon',
}),
}));
}
此外,您没有将 Image
对象作为 require('actions-on-google')
的一部分导入,这就是导致错误的原因该函数运行。确保您获得了所需的所有对象作为 require
的一部分。
关于node.js - Google Actions sdk 不使用 MediaObject 播放音频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50872985/
我想播放一些 WAV 文件,但我在 Visual Studio 中遇到错误 C2664: error C2664: 'Phonon::MediaObject::setCurrentSource' :
我尝试使用 MediaObject 播放音频,MediaObject 未播放给定的 mp3 音频文件,但我收到以下错误消息“必须设置 MalformedResponse 'final_response
我有一个 Action 可以自动循环播放一系列短片音轨(每个大约 30 秒)。 在真实智能手机上执行的 Google Assistant 应用上的操作(相同的操作,相同的代码)运行良好,但在 Goog
我有一个 MediaObject 作为规范化上下文组“模块”中的子资源公开: /** * @ApiResource( * attributes={"access_control"="is_
我是一名优秀的程序员,十分优秀!