Ste*_*son 3 javascript azure speech-to-text azure-cognitive-services azure-speech
我正在使用 Azure SpeechSDK 服务通过recognizeOnceAsync. 当前的代码类似于:
var SpeechSDK, recognizer, synthesizer;
var speechConfig = SpeechSDK.SpeechConfig.fromSubscription('SUB_KEY', 'SUB_REGION');
var audioConfig = SpeechSDK.AudioConfig.fromDefaultMicrophoneInput();
recognizer = new SpeechSDK.SpeechRecognizer(speechConfig, audioConfig);
new Promise(function(resolve) {
recognizer.onend = resolve;
recognizer.recognizeOnceAsync(
function (result) {
recognizer.close();
recognizer = undefined;
resolve(result.text);
},
function (err) {
alert(err);
recognizer.close();
recognizer = undefined;
}
);
}).then(r => {
console.log(`Azure STT enterpreted: ${r}`);
});
Run Code Online (Sandbox Code Playgroud)
在 HTML 文件中,我导入 Azure 包,如下所示:
<script src="https://aka.ms/csspeech/jsbrowserpackageraw"></script>
Run Code Online (Sandbox Code Playgroud)
问题是我想增加方法recognizeOnceAsync返回结果之前允许的“静默时间”量。(也就是说,假设您已经讲完了,您应该能够停下来呼吸一下,而无需使用该方法)。有什么办法可以做到这一点fromDefaultMicrophoneInput吗?我尝试过各种方法,例如:
const SILENCE_UNTIL_TIMEOUT_MS = 5000;
speechConfig.SpeechServiceConnection_EndSilenceTimeoutMs = SILENCE_UNTIL_TIMEOUT_MS;
audioConfig.setProperty("Speech_SegmentationSilenceTimeoutMs", SILENCE_UNTIL_TIMEOUT_MS);
Run Code Online (Sandbox Code Playgroud)
但似乎没有人正确延长“沉默时间津贴”。
小智 5
根据您的描述,您需要设置分段静默超时。不幸的是,目前 JS SDK 中有一个错误,并且PropertyId.Speech_SegmentationSilenceTimeoutMs没有正确设置。
作为解决方法,您可以按如下方式设置分段超时:
const speechConfig = SpeechConfig.fromSubscription(subscriptionKey, subscriptionRegion);
speechConfig.speechRecognitionLanguage = "en-US";
const reco = new SpeechRecognizer(speechConfig);
const conn = Connection.fromRecognizer(reco);
conn.setMessageProperty("speech.context", "phraseDetection", {
"INTERACTIVE": {
"segmentation": {
"mode": "custom",
"segmentationSilenceTimeoutMs": 5000
}
},
mode: "Interactive"
});
reco.recognizeOnceAsync(
(result) =>
{
console.log("Recognition done!!!");
// do something with the recognition
},
(error) =>
{
console.log("Recognition failed. Error:" + error);
});
Run Code Online (Sandbox Code Playgroud)
请注意,分段超时允许的范围是 100-5000 毫秒(含)
| 归档时间: |
|
| 查看次数: |
1870 次 |
| 最近记录: |