我希望 Azure 语音转短信服务至少等待 1 分钟,然后才能开始识别语音。或者演讲者自己在完成演讲后单击按钮,然后 azure 语音转文本服务应该开始识别演讲中的文本。
我尝试了下面的代码,但它不起作用
const speechConfig = SpeechConfig.fromSubscription(
subscriptionKey,
serviceRegion,
);
const audioConfig = AudioConfig.fromDefaultMicrophoneInput();
speechConfig.setProperty(
PropertyId.SpeechServiceConnection_EndSilenceTimeoutMs,
'60000',
);
const recognizer = new SpeechRecognizer(speechConfig, audioConfig);
recognizer.startContinuousRecognitionAsync();
console.log(new Date().toString());
recognizer.recognizeOnceAsync((result) => {
if (result.reason === ResultReason.RecognizedSpeech) {
const recognized = result.text;
console.log(new Date().toString());
console.log(recognized);
}}
我得到答案了,Speech_SegmentationSilenceTimeoutMs 允许的最大值是 5000,
这是更新后的代码
const speechConfig = SpeechConfig.fromSubscription(
subscriptionKey,
serviceRegion,
);
const audioConfig = AudioConfig.fromDefaultMicrophoneInput();
speechConfig.setProperty(
PropertyId.Speech_SegmentationSilenceTimeoutMs,
'5000',
);
const recognizer = new SpeechRecognizer(speechConfig, audioConfig);
console.log(new Date().toString());
recognizer.recognizeOnceAsync((result) => {
if (result.reason === ResultReason.RecognizedSpeech) {
const recognized = result.text;
console.log(new Date().toString());
}
}