Compare commits
2 Commits
feat/simpl
...
feat/add-t
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
85ab8b4b99 | ||
|
|
efb98f612b |
@@ -2,7 +2,7 @@ import type { StartAvatarResponse } from "@heygen/streaming-avatar";
|
||||
|
||||
import StreamingAvatar, {
|
||||
AvatarQuality,
|
||||
StreamingEvents,
|
||||
StreamingEvents, TaskType,
|
||||
} from "@heygen/streaming-avatar";
|
||||
import {
|
||||
Button,
|
||||
@@ -109,11 +109,10 @@ export default function InteractiveAvatar() {
|
||||
|
||||
return;
|
||||
}
|
||||
await avatar.current
|
||||
.speak({ text: text, sessionId: data?.session_id! })
|
||||
.catch((e) => {
|
||||
setDebug(e.message);
|
||||
});
|
||||
// speak({ text: text, task_type: TaskType.REPEAT })
|
||||
await avatar.current.speak({ text: text }).catch((e) => {
|
||||
setDebug(e.message);
|
||||
});
|
||||
setIsLoadingRepeat(false);
|
||||
}
|
||||
async function handleInterrupt() {
|
||||
@@ -123,20 +122,13 @@ export default function InteractiveAvatar() {
|
||||
return;
|
||||
}
|
||||
await avatar.current
|
||||
.interrupt({ sessionId: data?.session_id! })
|
||||
.interrupt()
|
||||
.catch((e) => {
|
||||
setDebug(e.message);
|
||||
});
|
||||
}
|
||||
async function endSession() {
|
||||
if (!avatar.current) {
|
||||
setDebug("Avatar API not initialized");
|
||||
|
||||
return;
|
||||
}
|
||||
await avatar.current.stopAvatar({
|
||||
sessionId: data?.session_id!,
|
||||
});
|
||||
await avatar.current?.stopAvatar();
|
||||
setStream(undefined);
|
||||
}
|
||||
|
||||
@@ -155,9 +147,9 @@ export default function InteractiveAvatar() {
|
||||
const previousText = usePrevious(text);
|
||||
useEffect(() => {
|
||||
if (!previousText && text) {
|
||||
avatar.current?.startListening({ sessionId: data?.session_id! });
|
||||
avatar.current?.startListening();
|
||||
} else if (previousText && !text) {
|
||||
avatar?.current?.stopListening({ sessionId: data?.session_id! });
|
||||
avatar?.current?.stopListening();
|
||||
}
|
||||
}, [text, previousText]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user