如何将实时音频流传递到 Direct Line Speech 端点?

How to pass real-time audio stream to the Direct Line Speech endpoint?

我正在尝试在我的自定义语音应用程序中使用直线语音 (DLS)。 Voice 应用程序可以访问我想要的实时音频流(pcm 编码)直接到 Direct Line Speech,允许实时来回通信。

从 DLS 客户端示例代码 (https://github.com/Azure-Samples/Cognitive-Services-Direct-Line-Speech-Client) 中,我看到 Microsoft.CognitiveServices.Speech.Dialog.DialogServiceConnector 命名空间中的方法 ListenOneAsync(),但看起来它正在从本地麦克风捕获媒体。

不过看这里的回复(Is new ms botbuilder directline speech good fit for call center scenario?),好像可以直接把音频流发给DLS。我似乎找不到关于此的任何文档。有人可以阐明如何实现这一目标吗?

我相信您的答案就在 Direct Line Speech 客户端中的Microsoft.CognitiveServices.Speech.Audio.AudioConfig class. Have a look at this line

this.connector = new DialogServiceConnector(config, AudioConfig.FromDefaultMicrophoneInput());

AudioConfig 提供了 FromDefaultMicrophoneInput 之外的许多选项。我怀疑您会想要使用三个 FromStreamInput 重载之一。如果你这样做,那么 ListenOnceAsync 将使用你的流而不是麦克风。