【问题标题】:How to make Amazon Polly speak and also show text when using Amazon Lex如何在使用 Amazon Lex 时让 Amazon Polly 说话并显示文本
【发布时间】:2017-06-20 22:12:08
【问题描述】:

所以我在这里陷入了一个令人困惑的境地。我正在构建一个 Amazon Lex 机器人,当让 Amazon Polly 以音频格式给出最终确认时,它只提供音频输出,但文本不会显示在 Lex 控制台中。

例如,在我的 python 代码中,这是一个最后的确认片段:

if outputDialogMode == 'Text':

    return close(
        session_attributes,
        'Fulfilled',
        {
            'contentType': 'PlainText',
            'content': 'Your reservation has been confirmed from"+str(start_time)+" to "+str(end_time)+". Your Booking ID is " + str(booking_id)
        }
    )
elif outputDialogMode == 'Voice':
    return close(
        session_attributes,
        'Fulfilled',
        {
            'contentType': 'SSML',
            'content': '<speak>Your reservation has been confirmed from"+str(start_time)+" to "+str(end_time)+". Your Booking ID is " + str(booking_id) +'</speak>'

        }
    )

现在,当我希望 Lex 以音频格式 (outputDialogMode == 'Voice') 输出 content 时,它只会说出它并且不会在控制台上显示文本。有没有办法让它同时说话和显示文本?

注意:上面的代码只是我整个代码中发送输出消息的部分。

【问题讨论】:

    标签: python amazon-lex amazon-polly


    【解决方案1】:

    文本响应在 HTTP 响应的 message 字段中返回。

    如果您只对用于记录/调试目的的输出文本感兴趣,您可以log the result 并在CloudWatch 中查看它

    【讨论】:

      猜你喜欢
      • 2022-01-15
      • 1970-01-01
      • 1970-01-01
      • 2020-11-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多