Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在amazon alexa skill Python上导入文本文件_Python_Alexa Skill - Fatal编程技术网

在amazon alexa skill Python上导入文本文件

在amazon alexa skill Python上导入文本文件,python,alexa-skill,Python,Alexa Skill,对不起我的英语 我是Alexa技能实施新手 我想将一个文本文件(已放置在AWS S3存储中)导入到代码中,以便能够读取它并将其插入到数据帧中,但我无法执行此操作 我有这个密码 class testIntent(AbstractRequestHandler): def can_handle(self, handler_input): # type: (HandlerInput) -> bool return ask_utils.is_intent_name("te

对不起我的英语

我是Alexa技能实施新手

我想将一个文本文件(已放置在AWS S3存储中)导入到代码中,以便能够读取它并将其插入到数据帧中,但我无法执行此操作

我有这个密码

class testIntent(AbstractRequestHandler):
 def can_handle(self, handler_input):
    # type: (HandlerInput) -> bool
    return ask_utils.is_intent_name("test")(handler_input)
    
 def handle(self, handler_input):
    # type: (HandlerInput) -> Response
    
    res = utilis.create_presigned_url("Media/test.txt")
    return (
    handler_input.response_builder.speak("{}".format(res)).response
    
    )
意图的调用应该返回一个链接,我认为(?)

当技能运行时,输出是“对不起,我无法按照您的要求执行操作。请重试。”

我希望获取链接,打开它,阅读它并创建一个数据帧


有人能帮我吗?

UTIL中的预签名URL将向媒体传递引用。它没有传递实际内容。对于带有responsebuilder.setCard()或ssml标记的图像/音频文件,它可以正常工作

但是responsebuilder.speak()处理纯文本的方式有点不同。您需要传递内容,而不是对内容的引用

例如:

 S3 bucket > mytext.txt > ["content abcd"]
现在你通过了

responsebuilder.speak(s3-mybucket-mytext.txt) //path
您需要通过:

responsebuilder.speak("content abcd") //content. read it using boto3 
使用boto3客户端连接到文件:

配置S3 bucket>fetch the file>do read operation>,一旦文本在lambda中,就可以使用responsebuilder.speak()将其发送给Alexa

或者,如果文件是静态的,则可以将文本文件放在代码本身中。使用文件模块导入文件