gpt4 book ai didi

python - 尝试在用 Python 编写的 Tropo 应用程序中创建简单的本地语法

转载 作者:太空宇宙 更新时间:2023-11-04 05:41:04 25 4
gpt4 key购买 nike

我正在使用 Python 在 Tropo 中创建一个应用程序,我想知道我是否可以创建一个本地的小语法。我已经阅读了有关外部语法 SRGSGRXML 的内容,但我可以在代码中使用 Python 列表创建一个吗?以下是我正在尝试做的事情。

food = ['cheeseburger', 'hot dog', 'salad']

ask("What food would you like?",
#{'choices': "cheeseburger, hot dog, salad",
{'choices': food,
'attempts':3,
'onChoice': fill,
'onBadChoice': nomatch,
'onTimeout': noinput })

上面的代码编译通过了,但是遇到这个问题就挂了。

最佳答案

如果您希望 Tropo 询问调用者“您想要什么食物”,并尝试 3 次尝试使用“食物”中的一个短语来回答,请尝试发送以下 json 响应:

{
"tropo": [
{
"ask": {
"choices": {
"value": "cheeseburger, hot dog, salad",
"mode": "speech",
"terminator": "#"
},
"attempts": 3,
"name": "foodchoice",
"recognizer": null,
"required": null,
"say": {
"value": "What food would you like"
}
}
},
{
"on": {
"event": "continue",
"name": null,
"next": "/fill",
"required": true
}
},
{
"on": {
"event": "incomplete",
"name": null,
"next": "/noinput",
"required": true
}
},
{
"on": {
"event": "error",
"name": null,
"next": "/nomatch",
"required": true
}
}
]
}

要准确回答您的问题,您需要了解 Python Tropo 库。我不熟悉 python 库,但 Tropo 的 Java 和 NodeJS 库似乎已经过时了......所以如果 Python 库过时了,那么你将不得不做更多的工作来构建和返回这个 JSON 对象。

关于python - 尝试在用 Python 编写的 Tropo 应用程序中创建简单的本地语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33878899/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com