Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.

Commit d214edb

Browse files
committed
update readme es6 usage
1 parent 817cca1 commit d214edb

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,28 @@ function RecognizerStop(SDK, recognizer) {
9595
}
9696
```
9797

98+
## ES6 Module Usage
99+
```javascript
100+
import * as SDK from 'microsoft-speech-browser-sdk';
101+
102+
function RecognizerSetup(recognitionMode, language, format, subscriptionKey) {
103+
let recognizerConfig = new SDK.RecognizerConfig(
104+
new SDK.SpeechConfig(
105+
new SDK.Context(
106+
new SDK.OS(navigator.userAgent, "Browser", null),
107+
new SDK.Device("SpeechSample", "SpeechSample", "1.0.00000"))),
108+
recognitionMode, // SDK.RecognitionMode.Interactive
109+
language, // Supported laguages are specific to each recognition mode. Refer to docs.
110+
format); // SDK.SpeechResultFormat.Simple (Options - Simple/Detailed)
111+
112+
// Alternatively use SDK.CognitiveTokenAuthentication(fetchCallback, fetchOnExpiryCallback)
113+
let authentication = new SDK.CognitiveSubscriptionKeyAuthentication(subscriptionKey);
114+
115+
// return SDK.Recognizer.Create(recognizerConfig, authentication);
116+
return SDK.CreateRecognizer(recognizerConfig, authentication);
117+
}
118+
```
119+
98120
## Try the sample out
99121
What to try the sample ? All you need is a subscription key. [Sign up](https://www.microsoft.com/cognitive-services/en-us/sign-up) to get one.
100122

0 commit comments

Comments
 (0)