![](/img/trans.png)
[英]Microsoft speech recognition PhraseLIst undefined,what is the issue?
[英]microsoft speech recognition + nodejs
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
對於這個錯誤,微軟工程師在這里有一個解釋。
這是由於默認麥克風支持使用 Web 音頻 API 來召喚麥克風 stream。 節點環境不支持這個。
作為一種解決方法,對於純節點代碼,您可以使用文件、推或拉 stream 將音頻輸入語音識別引擎。
希望能幫助到你: )
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.