IC Python API:RLPy RIVisemeComponent

From Reallusion Wiki!
Jump to: navigation, search

Main article: Modules. Last modified: 04/22/2020

Description

This class provides viseme related operations including reading an audio source and creating a viseme clip out of it. It can also add and remove keys from the viseme clip as well as provide Text-to-Speech capabilities. A viseme track within the timeline will show viseme clips and mouth shapes (viseme keys). The lip options track also includes the viseme smooth clip which can be used to smooth out the transition between the different mouth shapes in the event of a lip-sync animation.

Viseme keys in the "Lips" track.

Member Functions

LoadVocal ( self, pAudio, kStartTime, strClipName )

Create a viseme clip for this character with a given audio source.

Parameters

pAudio [IN] Audio source object - RIAudioObject
kStartTime [IN] Clip start time - RTime
strClipName [IN] Clip name - str

Return

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
 1 # Get avatar viseme component
 2 avatar_list = RLPy.RScene.GetAvatars()
 3 avatar = avatar_list[0]
 4 viseme_component = avatar.GetVisemeComponent()
 5 
 6 # Load vocal with create audio object
 7 audio = RLPy.RAudio.CreateAudioObject()
 8 audio_path = "./SpecialDay.wav"
 9 start_time = RLPy.RGlobal.GetTime()
10 RLPy.RAudio.LoadAudioToObject(avatar, audio_path, start_time)
11 clip_name = "Default"
12 result = viseme_component.LoadVocal(audio, start_time, clip_name)
13 
14 # Load vocal with audio recorder
15 audio_recorder = RLPy.RAudioRecorder()
16 audio_recorder.Start()
17 audio_recorder.Stop()
18 audio_source = audio_recorder.GetAudio()
19 start_time = RLPy.RGlobal.GetTime()
20 clip_name = "Default"
21 result = viseme_component.LoadVocal(audio_source, start_time, clip_name)

AddVisemeOptionClip ( self, kSmoothOption, kStartTime, strClipName )

Add a viseme smooth settings clip to the character. If a viseme clip does not exist at the start time, then a viseme smooth clip will not be deployed.

Parameters

kSmoothOption [IN] Viseme smooth option - RVisemeSmoothOption
kStartTime [IN] Clip start time - RTime
strClipName [IN] Clip name - str

Return

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
 1 # Get avatar viseme component
 2 avatar_list = RLPy.RScene.GetAvatars()
 3 avatar = avatar_list[0]
 4 viseme_component = avatar.GetVisemeComponent()
 5 
 6 # Add viseme option clip
 7 smooth_option = RLPy.RVisemeSmoothOption()
 8 smooth_option.SetStrengthEnable(True, True, True)
 9 smooth_option.SetStrengthValue(0, 0, 1)
10 start_time = RLPy.RGlobal.GetTime()
11 clip_name = "Default"
12 result = viseme_component.AddVisemeOptionClip(smooth_option, start_time, clip_name)

AddVisemeKey ( self, kKey )

Add a viseme key inside the current viseme clip. If the strength value of the viseme key lies outside of the range (0-100), or if a viseme clip does not exist then return RLPy.RStatus.Failure.

See Also: RemoveVisemesKey

Parameters

kKey [IN] The viseme key to be added. - RVisemeKey

Return

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
 1 # Get avatar viseme component
 2 avatar_list = RLPy.RScene.GetAvatars()
 3 avatar = avatar_list[0]
 4 viseme_component = avatar.GetVisemeComponent()
 5 
 6 # Add viseme key
 7 Key = RLPy.RVisemeKey()
 8 key.SetTime(RLPy.RTime(0))
 9 key.SetID(RLPy.EVisemeID_AH)
10 key.SetWeight(50)
11 result = viseme_component.AddVisemeKey(key)

AddVisemesClip ( self, kTime, nClipName, kClipLength )

Add an empty viseme clip to the character.

See Also: RemoveVisemesClip

Parameters

kTime [IN] Clip start time - RTime
nClipName [IN] Clip name - str
kClipLength [IN] Clip length - RTime

Return

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
 1 # Get avatar viseme component
 2 avatar_list = RLPy.RScene.GetAvatars()
 3 avatar = avatar_list[0]
 4 viseme_component = avatar.GetVisemeComponent()
 5 
 6 # Add visemes clip
 7 clip_start_time = RLPy.RTime(150)
 8 clip_name = "Clip1"
 9 clip_length = RLPy.RTime(500)
10 result = viseme_component.AddVisemesClip(clip_start_time, clip_name, clip_length)

RemoveVisemesClip ( self, kTime )

Remove a viseme clip on the character at the requested time. If a viseme clip does not exist at the given time then return RLPy.RStatus.Failure.

See Also: AddVisemesClip

Parameters

kTime [IN] Delete viseme clip at the specified time - RTime

Return

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
1 # Get avatar viseme component
2 avatar_list = RLPy.RScene.GetAvatars()
3 avatar = avatar_list[0]
4 viseme_component = avatar.GetVisemeComponent()
5 
6 # Remove a viseme clip at 1000 ms
7 result = viseme_component.RemoveVisemesClip(RLPy.RTime(1000))

RemoveVisemesKey ( self, kKey )

Delete a viseme key within a viseme clip at the given time. If a viseme clip is missing or a viseme key does not exist at the given time, then return RLPy.RStatus.Failure.

Parameters

kTime [IN] Delete the key at the specified time within a viseme clip - RTime

Return

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
 1 # Get avatar viseme component
 2 avatar_list = RLPy.RScene.GetAvatars()
 3 avatar = avatar_list[0]
 4 viseme_component = avatar.GetVisemeComponent()
 5 
 6 # Remove visemes key
 7 key = RLPy.RVisemeKey()
 8 key.SetTime(RLPy.RTime(300))
 9 key.SetID(RLPy.EVisemeID_AH)
10 key.SetWeight(80)
11 result = viseme_component.RemoveVisemesKey(key)

GetVisemeMorphWeights ( self )

Get all of the viseme morph weights on this character.

Returns

Viseme morph weights - float list

1 # Get avatar viseme component
2 avatar_list = RLPy.RScene.GetAvatars()
3 avatar = avatar_list[0]
4 viseme_component = avatar.GetVisemeComponent()
5 
6 # Get viseme morph weights
7 viseme_weights = viseme_component .GetVisemeMorphWeights()

GetVisemeBones ( self )

Get all of the viseme bone joints on this character.

Returns

Return all of the viseme bone joints - RINode list

1 # Get avatar viseme component
2 avatar_list = RLPy.RScene.GetAvatars()
3 avatar = avatar_list[0]
4 viseme_component = avatar.GetVisemeComponent()
5 
6 # Get viseme bones
7 viseme_bones = viseme_component.GetVisemeBones()

GetVisemeKeys ( self )

Get all the viseme keys inside all of the viseme clips on this character.

See Also: GetVisemeKey

Returns

All of the viseme keys of all the viseme clips - RVisemeKey list

1 # Get avatar viseme component
2 avatar_list = RLPy.RScene.GetAvatars()
3 avatar = avatar_list[0]
4 viseme_component = avatar.GetVisemeComponent()
5 
6 # Get viseme keys
7 viseme_key_list = viseme_component.GetVisemeKeys()

GetVisemeKey ( self, kTime, kKey )

Get the viseme key for the given time. If a viseme clip does not exist then return RLPy.RStatus.Failure.

See Also: GetVisemeKeys

Parameters

kTime [IN] Query the viseme key at the specified time - RTime
kKey [OUT] Viseme key at the specified time - RVisemeKey

Return

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
1 # Get avatar viseme component
2 avatar_list = RLPy.RScene.GetAvatars()
3 avatar = avatar_list[0]
4 viseme_component = avatar.GetVisemeComponent()
5 
6 # Get viseme key
7 ret_key = RLPy.RVisemeKey()
8 result = viseme_component.GetVisemeKey(RLPy.RTime(0), ret_key)

TextToSpeech ( self, strContent, eLanguage, fVolume, fPitch, fSpeed )

Create a viseme clip from script processed through text-to-speech;

See Also: TextToVisemeData

Parameters

strContent [IN] Content of speech - string
eLanguage [IN] Language of speech system. - RLPy.ELanguage enum
  • RLPy.ELanguage_TW - The input text is in the Chinese language family.
  • RLPy.ELanguage_US - The input text is in the English language family.
fVolume [IN] Settings of Volume [0.0,100.0]
fPitch [IN] Settings of Pitch [0.0,100.0]
fSpeed [IN] Settings of Speed [0.0,100.0]

Return

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
1 # Get avatar viseme component
2 avatar_list = RLPy.RScene.GetAvatars()
3 avatar = avatar_list[0]
4 viseme_component = avatar.GetVisemeComponent()
5 
6 # Text to speech
7 result = viseme_component.TextToSpeech("speech", RLPy.ELanguage_US, 100, 50, 50)

TextToVisemeData ( self, strContent, fVolume, fPitch, fSpeed )

When this character is provided a script processed by Text-To-Speech (TTS); Use this function can retrieve all the viseme IDs along with their corresponding times.

See Also: TextToSpeech

Parameters

strContent [IN] Content of speech.
fVolume [IN] Settings of Volume [0.0,100.0]
fPitch [IN] Settings of Pitch [0.0,100.0]
fSpeed [IN] Settings of Speed [0.0,100.0]

Returns

All viseme IDs along with their corresponding times.

1 # Get avatar viseme component
2 avatar_list = RLPy.RScene.GetAvatars()
3 avatar = avatar_list[0]
4 viseme_component = avatar.GetVisemeComponent()
5 
6 # Text to viseme data
7 result = viseme_component.TextToVisemeData("speech", 100, 50, 50)

GetStrength ( self )

Get the viseme strength value.

Returns

Viseme strength value - float

1 # Get avatar viseme component
2 avatar_list = RLPy.RScene.GetAvatars()
3 avatar = avatar_list[0]
4 viseme_component = avatar.GetVisemeComponent()
5 
6 # Get viseme strength
7 strength = viseme_component.GetStrength()