Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
useEffect(() => {
if (speech === 'bingspeech') {
createCognitiveServicesBingSpeechPonyfillFactory({
authorizationToken: () => fetchAndMemoizeBingSpeechAuthorizationToken(Date.now())
}).then(webSpeechPonyfillFactory => setWebSpeechPonyfillFactory(() => webSpeechPonyfillFactory));
} else if (speech === 'speechservices') {
const webSpeechPonyfillFactory = createCognitiveServicesSpeechServicesPonyfillFactory({
authorizationToken: () => fetchAndMemoizeSpeechServicesAuthorizationToken(Date.now()),
region: 'westus2'
});
setWebSpeechPonyfillFactory(() => webSpeechPonyfillFactory);
} else {
setWebSpeechPonyfillFactory(() => createBrowserWebSpeechPonyfillFactory());
}
}, [speech, setWebSpeechPonyfillFactory]);