-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update speech options to use
credentials
(#2759)
* Update to latest fetch credentials signature * Prettier * Refactor * Apply suggestions from code review Co-Authored-By: Corina <14900841+corinagum@users.noreply.github.com> Co-authored-by: Corina <14900841+corinagum@users.noreply.github.com>
- Loading branch information
Showing
10 changed files
with
105 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
import { AudioConfig } from 'microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/Audio/AudioConfig'; | ||
import createPonyfill from 'web-speech-cognitive-services/lib/SpeechServices'; | ||
|
||
async function resolveFunction(fnOrValue) { | ||
return await (typeof fnOrValue === 'function' ? fnOrValue() : fnOrValue); | ||
} | ||
|
||
export default function createCognitiveServicesSpeechServicesPonyfillFactory({ | ||
audioConfig, | ||
authorizationToken, | ||
credentials, | ||
enableTelemetry, | ||
region, | ||
speechRecognitionEndpointId, | ||
|
@@ -12,6 +17,26 @@ export default function createCognitiveServicesSpeechServicesPonyfillFactory({ | |
subscriptionKey, | ||
textNormalization | ||
}) { | ||
if (!credentials && (authorizationToken || region || subscriptionKey)) { | ||
console.warn( | ||
'botframework-webchat: "authorizationToken", "region", and "subscriptionKey" are being deprecated and will be removed on or after 2020-12-17. Please use "credentials" instead.' | ||
); | ||
|
||
credentials = async () => { | ||
if (authorizationToken) { | ||
return { | ||
authorizationToken: resolveFunction(authorizationToken), | ||
region | ||
}; | ||
} else { | ||
return { | ||
region, | ||
subscriptionKey: resolveFunction(subscriptionKey) | ||
}; | ||
} | ||
}; | ||
} | ||
|
||
// HACK: We should prevent AudioContext object from being recreated because they may be blessed and UX-wise expensive to recreate. | ||
// In Cognitive Services SDK, if they detect the "end" function is falsy, they will not call "end" but "suspend" instead. | ||
// And on next recognition, they will re-use the AudioContext object. | ||
|
@@ -35,14 +60,12 @@ export default function createCognitiveServicesSpeechServicesPonyfillFactory({ | |
return ({ referenceGrammarID }) => { | ||
const ponyfill = createPonyfill({ | ||
audioConfig, | ||
authorizationToken, | ||
credentials, | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
HamdBilalTahir-PwC
|
||
enableTelemetry, | ||
referenceGrammars: [`luis/${referenceGrammarID}-PRODUCTION`], | ||
region, | ||
speechRecognitionEndpointId, | ||
speechSynthesisDeploymentId, | ||
speechSynthesisOutputFormat, | ||
subscriptionKey, | ||
textNormalization | ||
}); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
These credentials don't work