Skip to content

Trigger recognized event based on duration #8

@MatekBratko

Description

@MatekBratko

I have a issue regarding the recognizing, recognized event. I have issue, that when a speaker speeks for a long time without interruption the recognized event does not get triggered for a long time, and alot of recognizing text starts being displayed/corrected which makes it hard to read for the user. I would like a faster trigger from the recognizing to the recognized event. Is there any way in the SDK to make a limit, lets say that after 5 seconds of speech it automatically triggers the recognized event.

CODE:

async function sttFromMic() {
const tokenObj = await getTokenOrRefresh();
const speechConfig = speechsdk.SpeechConfig.fromAuthorizationToken(tokenObj.authToken, tokenObj.region);
speechConfig.speechRecognitionLanguage = 'en-US';
const audioConfig = speechsdk.AudioConfig.fromDefaultMicrophoneInput();
const recognizer = new speechsdk.SpeechRecognizer(speechConfig, audioConfig);

    setDisplayText('speak into your microphone...');

    recognizer.recognizing = (s, e) => {
        setDisplayText(`RECOGNIZING: Text=${e.result.text}`);
    };

    recognizer.recognizeOnceAsync(result => {
        if (result.reason === speechsdk.ResultReason.RecognizedSpeech) {
            setDisplayText(`RECOGNIZED: Text=${result.text}`);
        } else {
            setDisplayText('ERROR: Speech was cancelled or could not be recognized. Ensure your microphone is working properly.');
        }
    });
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions