Skip to content

Commit

Permalink
[Talking Avatar] update real-time sample code to log result id (turn …
Browse files Browse the repository at this point in the history
…id) for ease of debugging (#2252)
  • Loading branch information
yinhew authored Feb 4, 2024
1 parent 3e7573c commit 3d62e3a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions samples/js/browser/avatar/js/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions samples/js/browser/avatar/js/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 3d62e3a

Please sign in to comment.