我正在尝试创建一个问答游戏,询问一个问题,然后播放一个简短的音频文件。我想让用户能够再次播放音频文件,但是没有语音。我该怎么办?
这是我的更新,它询问问题并播放文件:
action (UpdateGame) {
description (Evaluate user's answer and updates the game state.)
type (UpdateTransaction)
collect {
input (state) {
type (State)
min (Required) max (One)
}
input (fileToPlay) {
description (Create the playlist to play)
type (audioPlayer.AudioInfo)
min (Optional) max (One)
default-init {
intent {
goal: fileAudioInfo
}
}
hidden
}
computed-input (play) {
description (Ask the client to play our sound.)
type (audioPlayer.Result)
compute {
intent {
goal: audioPlayer.PlayAudio
value: $expr(fileToPlay)
}
}
hidden
}
input (answer){
type (Answer)
min (Required) max (One)
default-init {
intent {
goal: ChooseAnswer
}
}
}
}
output (State)
}
我的州对象看起来像这样:
structure (State) {
description (Holds the game state.)
features {
transaction
transient
}
property (game) {
type (Game)
min (Required) max (One)
visibility (Private)
}
property (currentQuestion) {
type (Question)
min (Required) max (One)
visibility (Private)
}
property (restartQuestion){
type (RestartQuestion)
min (Required) max (Many)
visibility (Private)
}
property (completed) {
type (core.Boolean)
min (Optional) max (One)
visibility (Private)
}
property (change) {
type (core.Boolean)
min (Optional) max (One)
visibility (Private)
}
property (say) {
type (core.Text)
min (Optional) max (One)
description(Should the introductory be read or not?)
}
property (display) {
type (core.Text)
min (Required) max (One)
description(Should the introductory be read or not?)
visibility (Private)
}
}
我有一个ReplayAudio动作,如下所示:
action (ReplayAudio) {
description (__DESCRIPTION__)
type (UpdateTransaction)
collect {
input (state) {
type (State)
min (Required) max (One)
default-init {
intent {
goal: ReplayAudio
}
}
validate {
replan{
intent{
goal: UpdateGame
value: State {
currentQuestion: $expr(state.currentQuestion)
display: $expr(state.display)
game: $expr(state.game)
restartQuestion: $expr(state.restartQuestion)
}
}
}
}
}
}
output (State)
}
因此,我试图省略say
字段。问题是,当我在UpdateGame
中再次设置say字段时,它保持空白,并且永远无法重置。
为什么要删除say
字段,使它不再被更新?
答案 0 :(得分:0)
我认为您可以将say
的值重新分配给“”(只有空格的空字符串),这等效于没有语音。