Skip to main content
Version: 1.3.x

AIPlayer Basic Speaking Features

1. Send Speaking

After the aiPlayer resource loading is completed, call the send method. Input a sentence into a textbox as shown below and press the SPEAK button to make the AI speak.

You can input just string to make AI speak but AIClipSet is also able to do it. When using AIClipSet, you can make AI speak with some gestures. For example, you can order AI to wave and say "hello!" This is called gesture speech. Details are described in the Gesture part.

If the text to speak is too long, it may not be possible to synthesize the resources required for the speaking. There are some models that can synthesize long sentences. Although it varies from AI to AI, it is generally recommended that sentences be cut to an appropriate length in Korean, usually within 30 to 40 characters, and at a similar level in English.

//Case1. One Sentence Speak
AI_PLAYER.send("Nice to meet you");

//Case2. One Gesture Speak
const AIClipSet = { text: "Nice to meet you", gst: "hi" };
AI_PLAYER.send(AIClipSet);

2. Pause Speaking

AI_PLAYER.pause();

3. Resume Speaking (Resume from Pause)

AI_PLAYER.resume();

4. Stop Speaking (Resets all the data you have. No resume allowed)

: Stop speaking and reset all data. (cannot resume)

AI_PLAYER.stopSpeak();

After the send method is called, you can keep track of the state in the registered listener. This feedback is returned by calling the method (onAIPlayerStateChanged(state)) of the listener. onAIPlayerStateChanged sequentially returns the following string values.

  • speakingPrepareStarted: on synthesis start
  • speakingPrepareComplete: on synthesis complete
  • speakingStarted: on speech start
  • speakingComplete: on speech end
AI_PLAYER.onAIPlayerStateChanged = async function (state) {
if (state === "speakingPrepareStarted") {
// TODO: speak prepare started handling
}

if (state === "speakingPrepareComplete") {
// TODO: speak prepare complete handling
}

if (state === "speakingStarted") {
// TODO: speaking start handling)
}

if (state === "speakingComplete") {
// TODO: speaking complete handling
}
};