From 8ce9c37314a62f85dcfdc3a6759c60ae483cfda2 Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Thu, 15 Sep 2022 11:08:56 +0800 Subject: [PATCH] Log synthesis cancel reason --- packages/text-to-speech/src/textToSpeech.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/text-to-speech/src/textToSpeech.ts b/packages/text-to-speech/src/textToSpeech.ts index 604835549..a3ad34f29 100644 --- a/packages/text-to-speech/src/textToSpeech.ts +++ b/packages/text-to-speech/src/textToSpeech.ts @@ -81,7 +81,7 @@ export const synthesizeTextToSpeech = async ( if (cancellationDetails.reason === CancellationReason.Error) { str += ': ' + e.result.errorDetails } - console.error('synthesis error:', str) + console.log(str) } // The unit of e.audioOffset is tick (1 tick = 100 nanoseconds), divide by 10,000 to convert to milliseconds. @@ -142,6 +142,9 @@ export const synthesizeTextToSpeech = async ( wordOffset = -start.length const ssml = `${start}${input.text}${endSsml()}` const result = await speakSsmlAsyncPromise(ssml) + if (result.reason === ResultReason.Canceled) { + throw new Error(result.errorDetails) + } return { audioData: Buffer.from(result.audioData), speechMarks,