From 3d62e3a6ddf556a9151dce65948158188f3e09ab Mon Sep 17 00:00:00 2001 From: yinhew <46698869+yinhew@users.noreply.github.com> Date: Sun, 4 Feb 2024 14:16:07 +0800 Subject: [PATCH] [Talking Avatar] update real-time sample code to log result id (turn id) for ease of debugging (#2252) --- samples/js/browser/avatar/js/basic.js | 4 ++-- samples/js/browser/avatar/js/chat.js | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/samples/js/browser/avatar/js/basic.js b/samples/js/browser/avatar/js/basic.js index 7a1986009..794f24396 100644 --- a/samples/js/browser/avatar/js/basic.js +++ b/samples/js/browser/avatar/js/basic.js @@ -94,9 +94,9 @@ function setupWebRTC(iceServerUrl, iceServerUsername, iceServerCredential) { // start avatar, establish WebRTC connection avatarSynthesizer.startAvatarAsync(peerConnection).then((r) => { if (r.reason === SpeechSDK.ResultReason.SynthesizingAudioCompleted) { - console.log("[" + (new Date()).toISOString() + "] Avatar started.") + console.log("[" + (new Date()).toISOString() + "] Avatar started. Result ID: " + r.resultId) } else { - console.log("[" + (new Date()).toISOString() + "] Unable to start avatar.") + console.log("[" + (new Date()).toISOString() + "] Unable to start avatar. Result ID: " + r.resultId) if (r.reason === SpeechSDK.ResultReason.Canceled) { let cancellationDetails = SpeechSDK.CancellationDetails.fromResult(r) if (cancellationDetails.reason === SpeechSDK.CancellationReason.Error) { diff --git a/samples/js/browser/avatar/js/chat.js b/samples/js/browser/avatar/js/chat.js index 72e7c90f8..1b58952ac 100644 --- a/samples/js/browser/avatar/js/chat.js +++ b/samples/js/browser/avatar/js/chat.js @@ -191,9 +191,9 @@ function setupWebRTC(iceServerUrl, iceServerUsername, iceServerCredential) { // start avatar, establish WebRTC connection avatarSynthesizer.startAvatarAsync(peerConnection).then((r) => { if (r.reason === SpeechSDK.ResultReason.SynthesizingAudioCompleted) { - console.log("[" + (new Date()).toISOString() + "] Avatar started.") + console.log("[" + (new Date()).toISOString() + "] Avatar started. Result ID: " + r.resultId) } else { - console.log("[" + (new Date()).toISOString() + "] Unable to start avatar.") + console.log("[" + (new Date()).toISOString() + "] Unable to start avatar. Result ID: " + r.resultId) if (r.reason === SpeechSDK.ResultReason.Canceled) { let cancellationDetails = SpeechSDK.CancellationDetails.fromResult(r) if (cancellationDetails.reason === SpeechSDK.CancellationReason.Error) { @@ -291,10 +291,10 @@ function speakNext(text, endingSilenceMs = 0) { avatarSynthesizer.speakSsmlAsync(ssml).then( (result) => { if (result.reason === SpeechSDK.ResultReason.SynthesizingAudioCompleted) { - console.log(`Speech synthesized to speaker for text [ ${text} ]`) + console.log(`Speech synthesized to speaker for text [ ${text} ]. Result ID: ${result.resultId}`) lastSpeakTime = new Date() } else { - console.log(`Error occurred while speaking the SSML.`) + console.log(`Error occurred while speaking the SSML. Result ID: ${result.resultId}`) } if (spokenTextQueue.length > 0) {