feat: add task type (#18)

This commit is contained in:
Joby
2024-09-23 13:38:15 -07:00
committed by GitHub
parent efb98f612b
commit 5dd784d63e

View File

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