Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show original error if avatar synthesis failed #768

Merged
merged 1 commit into from
Dec 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
yulin-li marked this conversation as resolved.
Show resolved Hide resolved
const request = await this.synthesisRequestQueue.dequeue();
request.err("Synthesis is canceled by user.");
}
return this.privAdapter.stopSpeaking();
}

Expand Down