Skip to content

Commit

Permalink
show original error if avatar synthesis failed (#768)
Browse files Browse the repository at this point in the history
  • Loading branch information
yulin-li committed Dec 8, 2023
1 parent fb04a09 commit b062648
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/sdk/AvatarSynthesizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
AvatarEventArgs,
PropertyCollection,
PropertyId,
ResultReason,
SpeechConfig,
SpeechSynthesisOutputFormat,
SpeechSynthesisResult,
Expand Down Expand Up @@ -99,6 +100,14 @@ export class AvatarSynthesizer extends Synthesizer {
this.privProperties.setProperty(PropertyId.TalkingAvatarService_WebRTC_SDP, JSON.stringify(peerConnection.localDescription));

const result: SpeechSynthesisResult = await this.speak("", false);
if (result.reason !== ResultReason.SynthesizingAudioCompleted) {
return new SynthesisResult(
result.resultId,
result.reason,
result.errorDetails,
result.properties,
);
}
const sdpAnswerString: string = atob(result.properties.getProperty(PropertyId.TalkingAvatarService_WebRTC_SDP));
const sdpAnswer: RTCSessionDescription = new RTCSessionDescription(
JSON.parse(sdpAnswerString) as RTCSessionDescriptionInit,
Expand Down Expand Up @@ -156,6 +165,10 @@ export class AvatarSynthesizer extends Synthesizer {
* @returns {Promise<void>} The promise of the void result.
*/
public async stopSpeakingAsync(): Promise<void> {
while (this.synthesisRequestQueue.length() > 0) {
const request = await this.synthesisRequestQueue.dequeue();
request.err("Synthesis is canceled by user.");
}
return this.privAdapter.stopSpeaking();
}

Expand Down

0 comments on commit b062648

Please sign in to comment.