Skip to content

Commit b7d50a9

Browse files
Merge pull request #187 from sally-baolian/patch-3
Update how-to-pronunciation-assessment.md
2 parents 1ebaf7a + 6e3689d commit b7d50a9

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

articles/ai-services/speech-service/how-to-pronunciation-assessment.md

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,10 @@ using (var speechRecognizer = new SpeechRecognizer(
333333
speechConfig,
334334
audioConfig))
335335
{
336+
// (Optional) get the session ID
337+
speechRecognizer.SessionStarted += (s, e) => {
338+
Console.WriteLine($"SESSION ID: {e.SessionId}");
339+
};
336340
pronunciationAssessmentConfig.ApplyTo(speechRecognizer);
337341
var speechRecognitionResult = await speechRecognizer.RecognizeOnceAsync();
338342

@@ -355,7 +359,10 @@ Word, syllable, and phoneme results aren't available by using SDK objects with t
355359
auto speechRecognizer = SpeechRecognizer::FromConfig(
356360
speechConfig,
357361
audioConfig);
358-
362+
// (Optional) get the session ID
363+
speechRecognizer->SessionStarted.Connect([](const SessionEventArgs& e) {
364+
std::cout << "SESSION ID: " << e.SessionId << std::endl;
365+
});
359366
pronunciationAssessmentConfig->ApplyTo(speechRecognizer);
360367
speechRecognitionResult = speechRecognizer->RecognizeOnceAsync().get();
361368

@@ -372,13 +379,17 @@ To learn how to specify the learning language for pronunciation assessment in yo
372379
::: zone-end
373380
374381
::: zone pivot="programming-language-java"
382+
375383
For Android application development, the word, syllable, and phoneme results are available by using SDK objects with the Speech SDK for Java. The results are also available in the JSON string. For Java Runtime (JRE) application development, the word, syllable, and phoneme results are only available in the JSON string.
376384
377385
```Java
378386
SpeechRecognizer speechRecognizer = new SpeechRecognizer(
379387
speechConfig,
380388
audioConfig);
381-
389+
// (Optional) get the session ID
390+
speechRecognizer.sessionStarted.addEventListener((s, e) -> {
391+
System.out.println("SESSION ID: " + e.getSessionId());
392+
});
382393
pronunciationAssessmentConfig.applyTo(speechRecognizer);
383394
Future<SpeechRecognitionResult> future = speechRecognizer.recognizeOnceAsync();
384395
SpeechRecognitionResult speechRecognitionResult = future.get(30, TimeUnit.SECONDS);
@@ -403,7 +414,10 @@ speechRecognitionResult.close();
403414

404415
```JavaScript
405416
var speechRecognizer = SpeechSDK.SpeechRecognizer.FromConfig(speechConfig, audioConfig);
406-
417+
// (Optional) get the session ID
418+
speechRecognizer.sessionStarted = (s, e) => {
419+
console.log(`SESSION ID: ${e.sessionId}`);
420+
};
407421
pronunciationAssessmentConfig.applyTo(speechRecognizer);
408422

409423
speechRecognizer.recognizeOnceAsync((speechRecognitionResult: SpeechSDK.SpeechRecognitionResult) => {
@@ -426,10 +440,10 @@ To learn how to specify the learning language for pronunciation assessment in yo
426440
speech_recognizer = speechsdk.SpeechRecognizer(
427441
speech_config=speech_config, \
428442
audio_config=audio_config)
429-
443+
# (Optional) get the session ID
444+
speech_recognizer.session_started.connect(lambda evt: print(f"SESSION ID: {evt.session_id}"))
430445
pronunciation_assessment_config.apply_to(speech_recognizer)
431446
speech_recognition_result = speech_recognizer.recognize_once()
432-
433447
# The pronunciation assessment result as a Speech SDK object
434448
pronunciation_assessment_result = speechsdk.PronunciationAssessmentResult(speech_recognition_result)
435449

@@ -447,7 +461,10 @@ To learn how to specify the learning language for pronunciation assessment in yo
447461
SPXSpeechRecognizer* speechRecognizer = \
448462
[[SPXSpeechRecognizer alloc] initWithSpeechConfiguration:speechConfig
449463
audioConfiguration:audioConfig];
450-
464+
// (Optional) get the session ID
465+
[speechRecognizer addSessionStartedEventHandler: ^ (SPXRecognizer *sender, SPXSessionEventArgs *eventArgs) {
466+
NSLog(@"SESSION ID: %@", eventArgs.sessionId);
467+
}];
451468
[pronunciationAssessmentConfig applyToRecognizer:speechRecognizer];
452469

453470
SPXSpeechRecognitionResult *speechRecognitionResult = [speechRecognizer recognizeOnce];
@@ -467,7 +484,9 @@ To learn how to specify the learning language for pronunciation assessment in yo
467484
468485
```swift
469486
let speechRecognizer = try! SPXSpeechRecognizer(speechConfiguration: speechConfig, audioConfiguration: audioConfig)
470-
487+
// (Optional) get the session ID
488+
speechRecognizer.addSessionStartedEventHandler { (sender, evt) in
489+
print("SESSION ID: \(evt.sessionId)")
471490
try! pronConfig.apply(to: speechRecognizer)
472491
473492
let speechRecognitionResult = try? speechRecognizer.recognizeOnce()

0 commit comments

Comments
 (0)