azure 如何等待1分钟的发言人的沉默,然后开始识别

js5cn81o  于 12个月前  发布在  其他
关注(0)|答案(1)|浏览(107)

我希望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);
}}

字符串

wfauudbj

wfauudbj1#

我得到了答案,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());
}
}

字符串

相关问题