【问题标题】:microsoft speech recognition + nodejs微软语音识别+nodejs
【发布时间】:2019-09-25 09:51:10
【问题描述】:

仍然支持 nodejs 认知服务语音 sdk 吗?我知道如何为基于浏览器的 sdk 执行此操作,但看起来 nodejs 版本不起作用,它没有捕获任何麦克风输入。

值得注意的是,没有将 AudioConfig.fromDefaultMicrophoneInput 用于 nodejs 的示例发布。 nodejs sdk 与AudioConfig.fromStreamInput 完美配合

以下是相关代码:

var speechsdk = require("microsoft-cognitiveservices-speech-sdk");
var subscriptionKey = ";)";
var serviceRegion = "eastus"; // e.g., "westus"

const speech_Config = speechsdk.SpeechConfig.fromSubscription(subscriptionKey, serviceRegion, "en-US");
const audioConfig = speechsdk.AudioConfig.fromDefaultMicrophoneInput();
let speech_recognizer= new speechsdk.SpeechRecognizer(speech_Config, audioConfig);

speech_recognizer.recognizeOnceAsync(
    function (result) {
        console.log(result);
        speech_recognizer.close();
        speech_recognizer = undefined;
    },
    function (err) {
        console.trace("err - " + err);
        speech_recognizer.close();
        speech_recognizer = undefined;
 });

我收到一条错误消息:window is not defined

npm:https://www.npmjs.com/package/microsoft-cognitiveservices-speech-sdk

【问题讨论】:

    标签: javascript node.js azure


    【解决方案1】:

    对于这个错误,微软工程师有一个解释here

    这是由于默认麦克风支持使用 Web Audio API 召唤一个麦克风流。节点环境不支持 这个。

    作为一种解决方法,对于纯节点代码,您可以使用文件、推送或拉取 流以将音频输入语音识别引擎。

    希望对你有帮助:)

    【讨论】:

    • 请问有帮助吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-09
    • 1970-01-01
    • 1970-01-01
    • 2011-02-17
    • 1970-01-01
    相关资源
    最近更新 更多