|
|
|
|
@@ -2,7 +2,7 @@ import type { StartAvatarResponse } from "@heygen/streaming-avatar";
|
|
|
|
|
|
|
|
|
|
import StreamingAvatar, {
|
|
|
|
|
AvatarQuality,
|
|
|
|
|
StreamingEvents, TaskMode, TaskType, VoiceEmotion,
|
|
|
|
|
StreamingEvents, TaskType, VoiceEmotion,
|
|
|
|
|
} from "@heygen/streaming-avatar";
|
|
|
|
|
import {
|
|
|
|
|
Button,
|
|
|
|
|
@@ -91,20 +91,17 @@ export default function InteractiveAvatar() {
|
|
|
|
|
const res = await avatar.current.createStartAvatar({
|
|
|
|
|
quality: AvatarQuality.Low,
|
|
|
|
|
avatarName: avatarId,
|
|
|
|
|
knowledgeId: knowledgeId, // Or use a custom `knowledgeBase`.
|
|
|
|
|
knowledgeId: knowledgeId,
|
|
|
|
|
voice: {
|
|
|
|
|
rate: 1.5, // 0.5 ~ 1.5
|
|
|
|
|
emotion: VoiceEmotion.EXCITED,
|
|
|
|
|
},
|
|
|
|
|
language: language,
|
|
|
|
|
disableIdleTimeout: true,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
setData(res);
|
|
|
|
|
// default to voice mode
|
|
|
|
|
await avatar.current?.startVoiceChat({
|
|
|
|
|
useSilencePrompt: false
|
|
|
|
|
});
|
|
|
|
|
await avatar.current?.startVoiceChat();
|
|
|
|
|
setChatMode("voice_mode");
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error("Error starting avatar session:", error);
|
|
|
|
|
@@ -120,7 +117,7 @@ export default function InteractiveAvatar() {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// speak({ text: text, task_type: TaskType.REPEAT })
|
|
|
|
|
await avatar.current.speak({ text: text, taskType: TaskType.REPEAT, taskMode: TaskMode.SYNC }).catch((e) => {
|
|
|
|
|
await avatar.current.speak({ text: text }).catch((e) => {
|
|
|
|
|
setDebug(e.message);
|
|
|
|
|
});
|
|
|
|
|
setIsLoadingRepeat(false);
|
|
|
|
|
|