Discussions

Ask a Question
Back to All

The 'speak' function on the JS SDK is not working

I have this code

await avatar.current?.speak({
          text: "Hi! I'm your AI health coach. I'm here to help you with healthy eating, sleep, meditation, and recovery. What would you like to focus on today?",
          taskType: TaskType.TALK,
          taskMode: TaskMode.SYNC
        });

Which I call after

const res = await avatar.current.createStartAvatar({
          quality: AvatarQuality.Low,
          avatarName: avatarName,
          knowledgeBase: knowledgeBase,
          voice: {
            rate: 1,
            emotion: emotion,
          },
          language: language,
        });

        setData(res);
        await avatar.current?.startVoiceChat();
        setChatMode("voice_mode");
        await avatar.current?.speak({
                  text: "Hi! I'm your AI health coach. I'm here to help you with healthy eating, sleep, meditation, and recovery. What would you like to focus on today?",
                  taskType: TaskType.TALK,
                  taskMode: TaskMode.SYNC
                });

But I get this error

{
    "code": 400001,
    "message": "Key: 'TaskRequest.Text' Error:Field validation for 'Text' failed on the 'required' tag"
}

Before it was working, no I am unable to make the avatar speak the welcome message. Please hel.