botframework - 如何使用直线在 botframework 的音频文件中获取语音?

标签 botframework speech direct-line-botframework

我在 C# 中为我的聊天机器人使用 botframework channel 直达线,最近我添加了 Bing 语音,用于文本到语音,反之亦然,但是当用户说话时,除了纯文本之外,是否还有音频文件作为消息事件中的附件。

提前致谢。

问候

最佳答案

对于 Webchat channel ,您可以查看来源以了解它是如何使用语音识别的。

特别是,您可以看到所有语音部分都是在将消息发送给机器人之前由网络聊天制作的 (sources):

const startListeningEpic: Epic<ChatActions, ChatState> = (action$, store) =>
    action$.ofType('Listening_Starting')
    .do((action : ShellAction) => {
        var locale = store.getState().format.locale;
        var onIntermediateResult = (srText : string) => { store.dispatch({ type: 'Update_Input', input: srText, source:"speech" })};
        var onFinalResult = (srText : string) => {
                srText = srText.replace(/^[.\s]+|[.\s]+$/g, "");
                onIntermediateResult(srText);
                store.dispatch({ type: 'Listening_Stop' });
                store.dispatch(sendMessage(srText, store.getState().connection.user, locale));
            };
        var onAudioStreamStart = () => { store.dispatch({ type: 'Listening_Start' }) };
        var onRecognitionFailed = () => { store.dispatch({ type: 'Listening_Stop' })};
        Speech.SpeechRecognizer.startRecognizing(locale, onIntermediateResult, onFinalResult, onAudioStreamStart, onRecognitionFailed);
    })
    .map(_ => nullAction)

Web 应用程序上的机器人代码是通过 sendMessage(srText... 调用的,没有音频。

关于botframework - 如何使用直线在 botframework 的音频文件中获取语音?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48398684/

相关文章:

iphone - 用于语音转文本(语音识别)iPhone 的 API 或 SDK

java - Android 上的语音转文本

audio - 改变音调的算法

botframework - 在 MS Teams 中检测 session 结束

对 Bot 框架的 CURL POST 请求

node.js - 从 NodeJS 向 Skype for Business 发送附件

javascript - MS Bot Framework 将值从服务器代码 (C#) 传递到前端代码 (JavaScript)

node.js - 在 Azure Bot Framework (Nodejs) 中使用 session.send 向对话发送 Webhook 响应

c# - 我们可以在没有 azure 或机器人模拟器的情况下在自己的客户端中测试机器人吗?

c# - Botframework DirectLineClient.Conversations.PostActivityAsync 返回 null