Class: com_prsonas_sdk_Avatar

com_prsonas_sdk_Avatar

Avatar Class


new com_prsonas_sdk_Avatar()

Constructs a new Avatar object

Methods


onSpeechTimeout(data)

Fires when the translation session has exceeded the internal limits.

Parameters:
Name Type Description
data Object

The data being handled.


onPhraseRecognized(data)

Handles inbound phrase

Parameters:
Name Type Description
data Object

The data being handled.


onPhraseCancelled(data)

Handles phrase cancellation

Parameters:
Name Type Description
data Object

The data being handled.


onIsCharacterSpeaking(data)

Handles the Is Character Speaking event

Parameters:
Name Type Description
data Object

The data being handled.


getPointFromString()

Converts a camera position string into an object


<async> getCameraPos(callback)

Retrieves the current camera position from the Avatar

Parameters:
Name Type Description
callback function

The callback that will be invoked with the camera
position


setCameraPos(x, y, z)

Sets the current camera position for the Avatar

Parameters:
Name Type Description
x float

The X position axis

y float

The Y position axis

z float

The Z position axis
position


<async> getCameraRot(callback)

Retrieves the current camera rotation from the Avatar

Parameters:
Name Type Description
callback function

The callback that will be invoked with the camera
rotation


setCameraRot(x, y, z)

Sets the current camera rotation for the Avatar

Parameters:
Name Type Description
x float

The X rotation axis

y float

The Y rotation axis

z float

The Z rotation axis
position


<async> getCameraFOV(callback)

Retrieves the current camera field of view from the Avatar

Parameters:
Name Type Description
callback function

The callback that will be invoked with the camera
FOV


setCameraFOV(fov)

Sets the current camera field of view for the Avatar

Parameters:
Name Type Description
fov float

The FOV in degrees
position


<async> getCameraAvatarBox(callback)

Retrieves the current camera settings that define a screen-space box that
frames the Avatar

Parameters:
Name Type Description
callback function

The callback that will be invoked with the Avatar display
box settings


setCameraAvatarBox(top, left, width, height)

Sets the parameters that define a screen-space box where the
Avatar will be displayed. All values are normalized between 0 and 1.0

Parameters:
Name Type Description
top float

The top coordinate of the box

left float

The left coordinate of the box

width float

The width of the box

height float

The height of the box
position


<async> getCameraAvatarView(callback)

Retrieves the current camera settings that define how the Avatar is
framed within the Avatar display box

Parameters:
Name Type Description
callback function

The callback that will be invoked with the Avatar view settings
box


setCameraAvatarView(headroom, bodyView, center, cameraZ)

Adjusts the framing of the Avatar within the display box
Avatar will be displayed. All values are normalized between 0 and <= 1.0.

Parameters:
Name Type Description
headroom float

The amount of space from the top of the Avatar's head to the top of the display box.

bodyView float

The amount of the Avatar's lower body that is displayed in the display box.

center float

The horizontal shift of the character withing the display box.

cameraZ float

The distance from the camera to the center of the Avatar in the display box.
position


playAnimation(anim, synthesizedFromText)

Plays the supplied animation on the avatar

Parameters:
Name Type Description
anim string

The animation to play.

synthesizedFromText string

Optional text string that will be used to generate the animation.


getSupportedLanguages()

Returns a list of languages that the speech recognition supports.

Returns:

Return object with the data property set as the array of languages.

Type
Object

getSupportedLanguagePrefixes()

Returns only the prefixes for each of the supported languages. A lot of methods only require the prefix
instead of the full ISO identifier.

Returns:

Return object with the data property set as the array of language prefixes.

Type
Object

translateText(destLangId, textArray, sourceLangId)

Translates an array of strings or a single string in the source language to into
a different language specified by the destLangId parameter.
Returns an empty array if there is an error.

Parameters:
Name Type Description
destLangId string

The language id that the string will be translated into.

textArray string

An array of text formatted in the sourceLangId that will be translated to the dest language. Can be a single string
or a pipe separated list of strings.

sourceLangId string

The language id specifying what language the text parameter is in. If not supplied then
the internal language specified by the InternalLanguage config setting is used.


getQAProjectInfo(includeQnA)

Returns a dictionary lookup of the properties for the Question and Answer project
associated with the experience. The corresponding admin settings must be present.

Parameters:
Name Type Description
includeQnA boolean

If set to true then question and answer info is included
in the "qna" property of the return value.


setLanguage(language)

Sets the language that the Avatar will respond in.

Parameters:
Name Type Description
language string

The ISO language to start responding in.


setNarrativeLanguage(language)

Sets the native language of the response text on the Avatar

Parameters:
Name Type Description
language string

The ISO language to start responding in.


startListening(language)

Starts up the speech processing engine.

Parameters:
Name Type Description
language string

The ISO language start listening on.


stopListening()

Shuts down the language processing engine


isSpeaking()

Returns the speaking status of the Avatar.

Returns:

True if the character is currently speaking; False otherwise.

Type
boolean

isConnected()

Returns true if the Viewer is currently connected to the Avatar's web socket server.

Returns:

True if the character is currently speaking; False otherwise.

Type
boolean

<async> getManifest(callback)

Returns Avatar manifest object. This call will fail if the Avatar is not
running. Must be called after receiving the WEBSOCKET_CONNECTED event.

Parameters:
Name Type Description
callback function

The callback that will be invoked with the manifest
JSON data.


<async> getAvailableCharacters(callback)

Retrieves a list of details for all available characters.

Parameters:
Name Type Description
callback function

The callback that will be invoked with the character list


<async> getCurrentCharacter(callback)

Retrieves retrieves details about the currently selected character

Parameters:
Name Type Description
callback function

The callback that will be invoked with the character details


<async> setCurrentCharacter(name)

Sets the current Avatar character

Parameters:
Name Type Description
name string

The name of the character to set