Compare commits

..

1 Commits

Author SHA1 Message Date
raojianb
64bb29760e feat: simplify api 2024-09-22 01:53:18 -07:00

View File

@@ -2,7 +2,7 @@ import type { StartAvatarResponse } from "@heygen/streaming-avatar";
import StreamingAvatar, {
AvatarQuality,
StreamingEvents, TaskType,
StreamingEvents,
} from "@heygen/streaming-avatar";
import {
Button,
@@ -109,10 +109,11 @@ export default function InteractiveAvatar() {
return;
}
// speak({ text: text, task_type: TaskType.REPEAT })
await avatar.current.speak({ text: text }).catch((e) => {
setDebug(e.message);
});
await avatar.current
.speak({ text: text })
.catch((e) => {
setDebug(e.message);
});
setIsLoadingRepeat(false);
}
async function handleInterrupt() {
@@ -128,7 +129,12 @@ export default function InteractiveAvatar() {
});
}
async function endSession() {
await avatar.current?.stopAvatar();
if (!avatar.current) {
setDebug("Avatar API not initialized");
return;
}
await avatar.current.stopAvatar();
setStream(undefined);
}