javascript - bixby 在测验示例中使用音频
问题描述
我正在尝试修改Bixby 的测验示例以使其与音频播放器一起使用。我想构建基本的“猜歌游戏测验”,我想在提示后播放音频。但我坚持 Bixby 的逻辑。并且不确定我应该使用什么模型结构。
我添加PlayAudio.model.bxb
到模型中:
action (PlayAudio) {
description (plays audio of quiz)
type (Calculation)
collect {
input (quiz) {
type (Quiz)
min (Required) max (One)
}
computed-input (quiz.audioToPlay) {
description (By passing in the AudioInfo object to the PlayAudio action, we ask the client to play our sound.)
type (audioPlayer.Result)
compute {
intent {
goal: audioPlayer.PlayAudio
value: $expr(quiz.audioToPlay)
}
}
hidden
}
}
output (Quiz)
}
并改变了开始UpdateQuiz.model.bxb
:
action (UpdateQuiz) {
type (Search)
description (Compares the user's answer to the correct answer and updates your score and move to the next question)
collect {
input (answer) {
type (Answer)
min (Required) max (One)
}
input (quiz) {
type (Quiz)
min (Required) max (One)
validate {
if (quiz.audioToPlay != null) {
replan {
intent {
goal: PlayAudio
value { $expr(quiz) }
}
}
}
}
}
}
output (Quiz)
}
它在用户回答后播放音频,但在 Bixby 问题后不播放。我了解我添加了音频意图作为答案验证的一部分,并且验证将在答案后执行,但我不确定如何使其正确播放音频。
解决方案
T 在我更改UpdateQuiz
模型的问题后播放音频。
action (UpdateQuiz) {
type (Search)
description (Compares the user's answer to the correct answer and updates your score and move to the next question)
collect {
input (quiz) {
type (Quiz)
min (Required) max (One)
validate {
if (exists(quiz.audioToPlay) && !quiz.completed) {
replan {
intent {
//goal: UpdateQuiz
goal: PlayAudio
value { $expr(quiz) }
}
}
}
}
}
input (answer) {
type (Answer)
min (Required) max (One)
}
}
output (Quiz)
}
推荐阅读
- javascript - 为什么在运行时 Js 会变得凌乱
- c# - 如何以更通用的方式将运算符应用于表达式
- python - 导入错误
- seaborn - seaborn distplot图中的y轴是什么?
- c# - asp.net中只有一个线程处理一页吗?
- python - 通过扩展用户模型中的电话字段登录
- python-2.7 - 无法使用 Anaconda 4.3.1(64 位)和 Python 2.7.13 连接到 Teradata
- neo4j - Neo4j:如何通过距离为每个节点查找下一个邻居并创建关系
- c++ - 为什么代码会抛出非法内存访问错误
- javascript - Angular *ngFor“id”标签生成不正确与`mat-button-toggle`