最新消息: 电脑我帮您提供丰富的电脑知识,编程学习,软件下载,win7系统下载。

Microsoft语音识别+ nodejs

IT培训 admin 11浏览 0评论

Microsoft语音识别+ nodejs

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

[值得注意的是,没有发布示例将AudioConfig.fromDefaultMicrophoneInput用于nodejs。使用AudioConfig.fromStreamInput

,nodejs sdk可以正常工作

以下是相关代码:

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:

回答如下:

针对此错误,Microsoft工程师对此进行了解释here。

这是由于默认麦克风支持使用Web Audio API来让人联想到麦克风流。节点环境不支持这个。

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

希望有帮助:)

Microsoft语音识别+ nodejs

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

[值得注意的是,没有发布示例将AudioConfig.fromDefaultMicrophoneInput用于nodejs。使用AudioConfig.fromStreamInput

,nodejs sdk可以正常工作

以下是相关代码:

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:

回答如下:

针对此错误,Microsoft工程师对此进行了解释here。

这是由于默认麦克风支持使用Web Audio API来让人联想到麦克风流。节点环境不支持这个。

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

希望有帮助:)

与本文相关的文章

发布评论

评论列表 (0)

  1. 暂无评论