如何等待说话者沉默1分钟后再开始识别

问题描述 投票:0回答:1

我希望 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);
}}
 
reactjs azure speech-recognition azure-cognitive-services speech-to-text
1个回答
0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.