This sample shows how to integrate the Azure Speech service into a sample React application. This sample shows design pattern examples for authentication token exchange and management, as well as capturing audio from a microphone or file for speech-to-text conversions.
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.
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.');
}
});
}
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);