使用 Dialogflow 和 C# 的音频响应

Audio Response with Dialogflow and C#

在 Dialogflow 语音设置上我启用了 'Automatic text to Speech'。

它说输出音频将包含在 DetectIntentResponse 和 StreamingDetectIntentResponse 中,但我不太确定该怎么做。

我的脚本当前 return 使用 content.queryResults、fulfilmentText

的文本响应

查看官方文档中的 Detect intent with audio output 以获取类似行为的示例。

您需要在包含大型 base64 音频字符串的响应中查找 "outputAudio" 字段。 C# 中没有示例,但是您应该能够以与访问 fulfillmentText 类似的方式访问它。例如 Node.js

const audioFile = response.outputAudio
const text = response.queryResult.fulfillmentText

和 Python

text = response.query_result.fulfillment_text
audio = response.output_audio

所以我假设 C# 会是这样的

content.outputAudio

记住,这会给你一个大的 base64 音频字符串。