Skip to main content
Version: 1.3.x

AIPlayer Method

MethodDescription
init(json)Initializing the AIPlayer object
setter(json)Set AI object information
getter(string)Get AI object information
preload(json)Pre-load for AI Speaking (Four Parameter Types Reference))
send(json)Command AI Speaking (Four Parameter Types Reference)
pause()Pause speaking
resume()Resume speaking
stopSpeak()Stop speaking and reset all data. (cannot resume)
release()Release resource (terminate AIPlayer)
generateToken()Generate authentication token
getAIList()Get a list of available AI models
getGesture()Get a list of available AI gestures

1. AIPlayer.init(json)

Initializes AI Player object with the given AI model parameters

  • Parameter

    ParamTypeDescription
    jsonObjectparameters of the init function
    json.ai_nameStringAI model name
    json.zIndexNumberAI model zIndex (optional, default: -1)
    json.sizeFloatAI model size (optional, default: 1.0)
    json.leftNumberAI model left (optional, default: 0, pixel)
    json.topNumberAI model top (optional, default: 0, pixel)
    json.speedFloatAI model speed (optional, step, 0.1, range : 0.5~1.5, default: 1)
  • Return Paramter

    ParamTypeDescription
    returnObjectinit return
    return.textsArray<String\>AI Default Text List
  • Example
  const result = await AI_PLAYER.init({
aiName: "...", zIndex: 0, size: 1.0, left: 0, top: 0, speed: 1.0
});

// TODO: It is recommended to use "await AI_PLAYER.getSampleTextList()" instead of "result.texts"
const texts = result.texts;

2. AIPlayer.setter(json)

Set AI object information

  • Parameter

    ParamTypeDescription
    jsonObjectparameters of the setter function
    json.zIndexNumberAI model zIndex (default: -1)
    json.sizeFloatAI model size (optional, range: 0 ~ 2.0, default: 1.0)
    json.topNumberAI model top (optional, default: 0)
    json.leftNumberAI model left (optional, default: 0)
    json.speedFloatAI model speech rate (optional, step, 0.1, range : 0.5 ~ 1.5, default: 0)
    json.tokenStringApp verified token
    json.appIdStringApp verified appId
  • Example

AI_PLAYER.setter({
token: "xxxxxxxxxxxxxxxxxxxxxx",
zIndex: 2,
size: 1.2,
top: 20,
left: 20,
speed: 1.2,
token: "...",
appId: "..."
});

3. AIPlayer.getter(key)

Get AI object information

  • Return Parameter: \* - AI object information

    ParamTypeValueDescription
    keyString'maxTextLength' | 'language' | 'size' | 'top' | 'left' | 'speed'AI Object Information
  • Example

  AI_PLAYER.getter("key");

4. AIPlayer.preload(...)

Pre-load function for AI Speech

  • You may choose from four parameter types depending on use case.

    ParamTypeDescription
    textStringA sentence to preload. Used for preloading a single sentence.
    textsArray<String\>A list of sentences to preload. Used for preloading multiple sentences.
    AIClipSetObjectA gesture sentence. Used for preloading a single gesture.
    AIClipSetsArray<Object\>A list of gesture sentences. Used for preloading multiple gesture sentences
  • Example

// Case1. One Sentence Preload (text)
AI_PLAYER.preload("Nice to meet you");
// Case2. Multi Sentence Preload (String Array)
AI_PLAYER.preload(["Nice to meet you", "How are you?"]);
// Case3. One Gesture Preload (json)
AI_PLAYER.preload({ text: "Nice to meet you", gst: "hi" });
// Case4. Multi Gesture Preload (json Array)
AI_PLAYER.preload([{ text: "Nice to meet you", gst: "hi" }, { text: "How are you?" }]);

5. AIPlayer.send(...)

Command used for making the AI speak or perform gesture actions. (If there exists a preloaded data, this data is reused) To make the AI speak multiple sentences, send an Array of String or AIClipSet Object.

  • You may choose from four parameter types depending on use case.

    ParamTypeDescription
    textStringA single sentence. Used for single sentence speaking.
    textsArray<String\>A list of sentences.. Used for multiple sentences speaking.
    AIClipSetObjectA gesture sentence. Used for single gesture action.
    AIClipSetsArray<Object\>A list of gesture sentences. Used for multiple gesture actions.
  • Example

//Case1. One Sentence Speak (text)
AI_PLAYER.send("Nice to meet you");
//Case2. Multi Sentences Speak (String Array)
AI_PLAYER.send(["Nice to meet you", "How are you?"]);
//Case3. One Gesture Speak (json)
AI_PLAYER.send({ text: "Nice to meet you", gst: "hi" });
//Case4. Multi Gestures Speak (json Array)
AI_PLAYER.send([{ text: "Nice to meet you", gst: "hi" }, { text: "How are you?" }]);

6. AIPlayer.stopSpeak()

Stop AI speech and reset all data on stack. (cannot resume)

7. AIPlayer.pause()

Temporarily pause AI speech.

8. AIPlayer.resume()

Resume speech if the AI state was paused previously.

9. AIPlayer.release()

Used to release system resources in use. (Not reusable)

10. AIPlayer.getGestures()

Get a list of available gestures

  • Return Parameter: Array<AIGesture\>

  • Examples

  const gestures = AI_PLAYER.getGestures();

11. AIPlayer.getSampleTextList()

Gets the sample text list of AI's default language or set voice language

  • Return Parameter: Array<String\>

  • Examples

  const texts = AI_PLAYER.getSampleTextList();

12. AIPlayer.getGender()

Gets the current AI gender ('MALE', 'FEMALE', 'UNI') and returns null if there is no value.

  • Return Parameter: MALE || FEMALE || UNI || null

  • Examples

  const gender = AI_PLAYER.getGender();

13. AIPlayer.getSpeakableLanguages(gender)

Gets the language list of currently loaded voices, valid after loadCustomVoice() or generateToken() method calls.

  • Return Parameter: Array<String\>

  • Examples

  const languages = AI_PLAYER.getSpeakableLanguages(gender);

14. AIPlayer.getCustomVoice()

Gets the currently set voice and returns null if there is no set value or default voice.

  • Return Parameter: CustomVoice || null

  • Examples

  const customVoice = AI_PLAYER.getCustomVoice();

15. AIPlayer.getCustomVoicesWith(language, gender)

Gets the list of custom voices that correspond to the language and gender of the input among the loaded voices If you type null in language, you get all languages, and if you type null in gender, you get values that correspond to all genders.
Valid after loadCustomVoice() or generateToken() method call.

  • Return Parameter: Array<CustomVoice\>

  • Examples

  const customVoices = AI_PLAYER.getSpeakableLanguages(language, gender);

16. AIPlayer.findCustomVoice(voiceId)

Gets the CustomVoice object corresponding to id in the voice list, and returns null if there is no value.

  • Return Parameter: CustomVoice || null

  • Examples

  const customVoice = AI_PLAYER.findCustomVoice(voiceId);

17. AIPlayer.setCustomVoice(customVoice)

It sets the voice of AI and returns true on success and false on failure. Also, when null is entered, it is set to the original voice.

  • Return Parameter: true || false

  • Examples

  const isSuccess = AI_PLAYER.setCustomVoice(customVoice);

18. AIPlayer.setCustomVoiceForLanguage(language, gender)

Voice is set by desired language and gender, and when null is entered in language, it is set as the original voice.
If you enter the language value and enter null in the gender, it is set as the first voice in the voice list of the language.

  • Return Parameter: true || false

  • Examples

  const isSuccess = AI_PLAYER.setCustomVoiceForLanguage(language, gender);