Skip to content

Commit a743f2d

Browse files
Merge pull request #231829 from alexeyo26/alexeyo/stt-javascript-session-id
[CogSvc] Speech. Getting STT Session ID. Adding JavaScript part
2 parents 5cfc71e + b552efd commit a743f2d

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

articles/cognitive-services/Speech-Service/how-to-get-speech-session-id.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,27 +29,34 @@ To get the Session ID, when using SDK you need to:
2929
1. Enable application logging.
3030
1. Find the Session ID inside the log.
3131

32-
If you use [Speech CLI](spx-overview.md), you can also get the Session ID interactively. See details [below](#get-session-id-using-speech-cli).
32+
If you use Speech SDK for JavaScript, get the Session ID as described in [this section](#get-session-id-using-javascript).
3333

34-
In case of [Speech-to-text REST API for short audio](rest-speech-to-text-short.md) you need to "inject" the session information in the requests. See details [below](#provide-session-id-using-rest-api-for-short-audio).
34+
If you use [Speech CLI](spx-overview.md), you can also get the Session ID interactively. See details in [this section](#get-session-id-using-speech-cli).
35+
36+
In case of [Speech-to-text REST API for short audio](rest-speech-to-text-short.md) you need to "inject" the session information in the requests. See details in [this section](#provide-session-id-using-rest-api-for-short-audio).
3537

3638
### Enable logging in the Speech SDK
3739

3840
Enable logging for your application as described in [this article](how-to-use-logging.md).
3941

4042
### Get Session ID from the log
4143

42-
Open the log file your application produced and look for `SessionId:`. The number, that would follow is the Session ID you need. In the log excerpt example below `0b734c41faf8430380d493127bd44631` is the Session ID.
44+
Open the log file your application produced and look for `SessionId:`. The number that would follow is the Session ID you need. In the following log excerpt example `0b734c41faf8430380d493127bd44631` is the Session ID.
4345

4446
```
4547
[874193]: 218ms SPX_DBG_TRACE_VERBOSE: audio_stream_session.cpp:1238 [0000023981752A40]CSpxAudioStreamSession::FireSessionStartedEvent: Firing SessionStarted event: SessionId: 0b734c41faf8430380d493127bd44631
4648
```
49+
### Get Session ID using JavaScript
50+
51+
If you use Speech SDK for JavaScript, you get Session ID with the help of `sessionStarted` event from the [Recognizer class](/javascript/api/microsoft-cognitiveservices-speech-sdk/recognizer).
52+
53+
See an example of getting Session ID using JavaScript in [this sample](https://github.com/Azure-Samples/cognitive-services-speech-sdk/blob/master/samples/js/browser/index.html). Look for `recognizer.sessionStarted = onSessionStarted;` and then for `function onSessionStarted`.
4754

4855
### Get Session ID using Speech CLI
4956

50-
If you use [Speech CLI](spx-overview.md), then you will see the Session ID in `SESSION STARTED` and `SESSION STOPPED` console messages.
57+
If you use [Speech CLI](spx-overview.md), then you'll see the Session ID in `SESSION STARTED` and `SESSION STOPPED` console messages.
5158

52-
You can also enable logging for your sessions and get the Session ID from the log file as described above. Run the appropriate Speech CLI command to get the information on using logs:
59+
You can also enable logging for your sessions and get the Session ID from the log file as described in [this section](#get-session-id-from-the-log). Run the appropriate Speech CLI command to get the information on using logs:
5360

5461
```console
5562
spx help recognize log

0 commit comments

Comments
 (0)