Difference between revisions of "IC Python API:RLPy RIVisemeComponent"

From Reallusion Wiki!
Jump to: navigation, search
(Created page with "{{TOC}} {{Parent|IC_Python_API:RL_Python_Modules|Modules}} ==Inheritance== This class inherits public member functions from: *RLPy.RIBase ==Detai...")
 
m
Line 1: Line 1:
 
{{TOC}}
 
{{TOC}}
 
{{Parent|IC_Python_API:RL_Python_Modules|Modules}}
 
{{Parent|IC_Python_API:RL_Python_Modules|Modules}}
==Inheritance==
+
{{last_modified}}
This class inherits public member functions from:
+
 
*[[IC_Python_API:RLPy_RIBase|RLPy.RIBase]]
+
== Description ==
==Detailed Description==
+
 
RIVisemeComponent.
+
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.
<syntaxhighlight lang="Python">
+
 
 +
[[File:Rlpy_rivisemecomponent_description_01.png]]
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
# Get avatar viseme component
 
avatar_list = RLPy.RScene.GetAvatars()
 
avatar_list = RLPy.RScene.GetAvatars()
 
avatar = avatar_list[0]
 
avatar = avatar_list[0]
viseme_animator = avatar.GetVisemeComponent()
+
viseme_component = avatar.GetVisemeComponent()
+
#set the RVisemeSmoothOption
+
viseme_smooth_option = RLPy.RVisemeSmoothOption()
+
full_enable = True
+
full_value = 0.3
+
jaw_enable = True
+
jaw_value = 0.4
+
lips_enble = False
+
lips_value = 0.5
+
tongue_enble = True
+
tongue_value = 0.6
+
self.viseme_smooth_option.SetStrengthEnable(full_enable, jaw_enable, lips_enble, tongue_enble) #bFullEnable, bJawEnable, bLipsEnable, bTongueEnable
+
self.viseme_smooth_option.SetStrengthValue(full_value, jaw_value, lips_value, tongue_value) #fFull, fJaw, fLips, fTongue
+
+
# load vocal
+
audio_object = RLPy.RAudio.CreateAudioObject()
+
audio_object.Load("C:\\sample.wav")
+
clip_name = "VisemeClip"
+
clip_start_time = RLPy.RTime(0)
+
viseme_animator.LoadVocal(audio_object, clip_start_time, clip_name)
+
viseme_animator.AddVisemeOptionClip(viseme_smooth_option, clip_start_time, clip_name)
+
  
# add viseme clip
+
# Add viseme key
clip_name = "VisemeClip"
+
Key = RLPy.RVisemeKey()
time_begin = RLPy.RTime(0)
+
key.SetTime(RLPy.RTime(0))
clip_length = RLPy.RTime(1000)
+
key.SetID(RLPy.EVisemeID_AH)
viseme_animator.AddVisemesClip(time_begin, clip_name, clip_length);
+
key.SetWeight(50)
 +
result = viseme_component.AddVisemeKey(key)
  
# add viseme key to viseme clip
+
# Remove visemes key
expressiveness = 50
+
result = viseme_component.RemoveVisemesKey(key)
viseme_animator.AddVisemeKey(RLPy.RTime(100) , RLPy.EVisemeID_AH, expressiveness);
+
</syntaxhighlight>
  
# remove viseme key
+
== Member Functions ==
viseme_animator.AddVisemeKey(RLPy.RTime(0) , RLPy.EVisemeID_AH, 50);
+
viseme_animator.RemoveVisemesKey(RLPy.RTime(0));
+
  
# remove viseme clip
+
=== LoadVocal ( self, pAudio, kStartTime, strClipName ) ===
viseme_animator.AddVisemesClip(RLPy.RTime(2000), "Clip1", RLPy.RTime(1000));
+
viseme_animator.RemoveVisemesClip(RLPy.RTime(2000));
+
  
# get all viseme bones
+
Create a viseme clip for this character with a given audio source.
viseme_bones = viseme_animator.GetVisemeBones();
+
print(len(viseme_bones))
+
print(viseme_bones[0].GetName())
+
  
# get all viseme weights
+
==== Parameters ====
viseme_weights = viseme_animator.GetVisemeMorphWeights();
+
:'''pAudio''' [IN] Audio source object - [[IC_Python_API:RLPy_RIAudioObject|RIAudioObject]]
print(len(viseme_weights))
+
:'''kStartTime''' [IN] Clip start time - [[IC_Python_API:RLPy_RTime|RTime]]
print(viseme_weights[0])
+
:'''strClipName''' [IN] Clip name - str
  
# get all viseme keys
+
==== Return ====
keys = viseme_animator.GetVisemeKeys();
+
:Success - RLPy.RStatus.Success
print(len(keys))
+
:Failure - RLPy.RStatus.Failure
print(keys[0].GetValue())
+
print(keys[1].GetValue())
+
  
#get viseme key info
+
<syntaxhighlight lang="python" line='line'>
viseme_id = 0 #RLPy.EVisemeID_NONE
+
# Get avatar viseme component
viseme_weight = 0
+
avatar_list = RLPy.RScene.GetAvatars()
result = viseme_animator.GetVisemeKey(RLPy.RTime(0), viseme_id, viseme_weight);
+
avatar = avatar_list[0]
print(result[0]) #Success or failure
+
viseme_component = avatar.GetVisemeComponent()
print(result[1]) #viseme id
+
 
print(result[2]) #viseme weight
+
# Load vocal with create audio object
 +
audio = RLPy.RAudio.CreateAudioObject()
 +
audio_path = "./SpecialDay.wav"
 +
start_time = RLPy.RGlobal.GetTime()
 +
RLPy.RAudio.LoadAudioToObject(avatar, audio_path, start_time)
 +
clip_name = "Default"
 +
result = viseme_component.LoadVocal(audio, start_time, clip_name)
 +
 
 +
# Load vocal with audio recorder
 +
audio_recorder = RLPy.RAudioRecorder()
 +
audio_recorder.Start()
 +
audio_recorder.Stop()
 +
audio_source = audio_recorder.GetAudio()
 +
start_time = RLPy.RGlobal.GetTime()
 +
clip_name = "Default"
 +
result = viseme_component.LoadVocal(audio_source, start_time, clip_name)
 
</syntaxhighlight>
 
</syntaxhighlight>
==Member Functions==
+
 
===AddVisemeKey===
+
=== AddVisemeOptionClip ( self, kSmoothOption, kStartTime, strClipName ) ===
<syntaxhighlight lang="Python">
+
 
RLPy.RIVisemeComponent.AddVisemeKey ( self, kTime, eVisemeID, fWeight )
+
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 - [[IC_Python_API:RLPy_RVisemeSmoothOption|RVisemeSmoothOption]]
 +
:'''kStartTime''' [IN] Clip start time - [[IC_Python_API:RLPy_RTime|RTime]]
 +
:'''strClipName''' [IN] Clip name - str
 +
 
 +
==== Return ====
 +
:Success - RLPy.RStatus.Success
 +
:Failure - RLPy.RStatus.Failure
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
# Get avatar viseme component
 +
avatar_list = RLPy.RScene.GetAvatars()
 +
avatar = avatar_list[0]
 +
viseme_component = avatar.GetVisemeComponent()
 +
 
 +
# Add viseme option clip
 +
smooth_option = RLPy.RVisemeSmoothOption()
 +
smooth_option.SetStrengthEnable(True, True, True)
 +
smooth_option.SetStrengthValue(0, 0, 1)
 +
start_time = RLPy.RGlobal.GetTime()
 +
clip_name = "Default"
 +
result = viseme_component.AddVisemeOptionClip(smooth_option, start_time, clip_name)
 
</syntaxhighlight>
 
</syntaxhighlight>
Add a viseme key.
 
<span style="background:#ffcccc">( Experimental Class )</span>
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''kTime''' [IN] The time at which to add the key - RLPy.RTime
+
=== AddVisemeKey ( self, kKey ) ===
  
'''eVisemeID''' [IN] Type of the viseme ID - RLPy.EVisemeID
+
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'''.
*'''RLPy.EVisemeID_NONE'''
+
*'''RLPy.EVisemeID_EE'''
+
*'''RLPy.EVisemeID_ER'''
+
*'''RLPy.EVisemeID_IH'''
+
*'''RLPy.EVisemeID_AH'''
+
*'''RLPy.EVisemeID_OH'''
+
*'''RLPy.EVisemeID_W_OO'''
+
*'''RLPy.EVisemeID_S_Z'''
+
*'''RLPy.EVisemeID_CH_J'''
+
*'''RLPy.EVisemeID_F_V'''
+
*'''RLPy.EVisemeID_TH'''
+
*'''RLPy.EVisemeID_T_L_D_N'''
+
*'''RLPy.EVisemeID_B_M_P'''
+
*'''RLPy.EVisemeID_K_G_H_NG'''
+
*'''RLPy.EVisemeID_AE'''
+
*'''RLPy.EVisemeID_R'''
+
  
'''fWeight''' [IN] Settings of Expressiveness, the range is from 0.0 to 100.0 - float
+
See Also: [[#RemoveVisemesKey ( self, kKey )|RemoveVisemesKey]]
</div>
+
 
====Returns====
+
==== Parameters ====
<div style="margin-left: 2em;">Success or Fail or InvalidParameter - RLPy.RStatus
+
:'''kKey''' [IN] The viseme key to be added. - RVisemeKey
</div>
+
 
-----
+
==== Return ====
===AddVisemeOptionClip===
+
:Success - RLPy.RStatus.Success
<syntaxhighlight lang="Python">
+
:Failure - RLPy.RStatus.Failure
RLPy.RIVisemeComponent.AddVisemeOptionClip ( self, kSmoothOption, kStartTime, strClipName )
+
 
 +
<syntaxhighlight lang="python" line='line'>
 +
# Get avatar viseme component
 +
avatar_list = RLPy.RScene.GetAvatars()
 +
avatar = avatar_list[0]
 +
viseme_component = avatar.GetVisemeComponent()
 +
 
 +
# Add viseme key
 +
Key = RLPy.RVisemeKey()
 +
key.SetTime(RLPy.RTime(0))
 +
key.SetID(RLPy.EVisemeID_AH)
 +
key.SetWeight(50)
 +
result = viseme_component.AddVisemeKey(key)
 
</syntaxhighlight>
 
</syntaxhighlight>
You can separately adjust the viseme animation strength/smooth for the tongue, lips, and jaw from this function.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''kSmoothOption''' [IN] Settings of Smooth/Strength - RLPy.RVisemeSmoothOption
+
=== AddVisemesClip ( self, kTime, nClipName, kClipLength ) ===
  
'''kStartTime''' [IN] Specifies the start time of the clip - RLPy.RTime
+
Add an empty viseme clip to the character.
 +
 
 +
See Also: [[#RemoveVisemesClip ( self, kTime )|RemoveVisemesClip]]
 +
 
 +
==== Parameters ====
 +
:'''kTime''' [IN] Clip start time - [[IC_Python_API:RLPy_RTime|RTime]]
 +
:'''nClipName''' [IN] Clip name - str
 +
:'''kClipLength''' [IN] Clip length - [[IC_Python_API:RLPy_RTime|RTime]]
 +
 
 +
==== Return ====
 +
:Success - RLPy.RStatus.Success
 +
:Failure - RLPy.RStatus.Failure
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
# Get avatar viseme component
 +
avatar_list = RLPy.RScene.GetAvatars()
 +
avatar = avatar_list[0]
 +
viseme_component = avatar.GetVisemeComponent()
  
'''strClipName''' [IN] The name of the clip - string
+
# Add visemes clip
</div>
+
clip_start_time = RLPy.RTime(150)
====Returns====
+
clip_name = "Clip1"
<div style="margin-left: 2em;">Success or Fail or InvalidParameter - RLPy.RStatus
+
clip_length = RLPy.RTime(500)
</div>
+
result = viseme_component.AddVisemesClip(clip_start_time, clip_name, clip_length)
-----
+
===AddVisemesClip===
+
<syntaxhighlight lang="Python">
+
RLPy.RIVisemeComponent.AddVisemesClip ( self, kTime, nClipName, kClipLength )
+
 
</syntaxhighlight>
 
</syntaxhighlight>
Add a viseme clip.
 
<span style="background:#ffcccc">( Experimental Class )</span>
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''kTime''' [IN] Setting of clip's begin time - RLPy.RTime
+
=== RemoveVisemesClip ( self, kTime ) ===
  
'''nClipName''' [IN] Name of the Clip - string
+
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'''.
  
'''kClipLength''' [IN] Time of clip length, the value must be greater than 0 - RLPy.RTime
+
See Also: [[#AddVisemesClip ( self, kTime, nClipName, kClipLength )|AddVisemesClip]]
</div>
+
 
====Returns====
+
==== Parameters ====
<div style="margin-left: 2em;">Success or Fail or InvalidParameter - RLPy.RStatus
+
:'''kTime''' [IN] Delete viseme clip at the specified time - [[IC_Python_API:RLPy_RTime|RTime]]
</div>
+
 
-----
+
==== Return ====
===GetVisemeBones===
+
:Success - RLPy.RStatus.Success
<syntaxhighlight lang="Python">
+
:Failure - RLPy.RStatus.Failure
RLPy.RIVisemeComponent.GetVisemeBones ( self )
+
 
 +
<syntaxhighlight lang="python" line='line'>
 +
# Get avatar viseme component
 +
avatar_list = RLPy.RScene.GetAvatars()
 +
avatar = avatar_list[0]
 +
viseme_component = avatar.GetVisemeComponent()
 +
 
 +
# Remove a viseme clip at 1000 ms
 +
result = viseme_component.RemoveVisemesClip(RLPy.RTime(1000))
 
</syntaxhighlight>
 
</syntaxhighlight>
Get all viseme bones.
+
 
<span style="background:#ffcccc">( Experimental Class )</span>
+
=== RemoveVisemesKey ( self, kKey ) ===
====Returns====
+
 
<div style="margin-left: 2em;">Pointer to viseme root bone - list
+
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'''.
</div>
+
 
-----
+
==== Parameters ====
===GetVisemeKey===
+
:'''kTime''' [IN] Delete the key at the specified time within a viseme clip - [[IC_Python_API:RLPy_RTime|RTime]]
<syntaxhighlight lang="Python">
+
 
RLPy.RIVisemeComponent.GetVisemeKey ( self, kTime, eVisemeID, fWeight )
+
==== Return ====
 +
:Success - RLPy.RStatus.Success
 +
:Failure - RLPy.RStatus.Failure
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
# Get avatar viseme component
 +
avatar_list = RLPy.RScene.GetAvatars()
 +
avatar = avatar_list[0]
 +
viseme_component = avatar.GetVisemeComponent()
 +
 
 +
# Remove visemes key
 +
key = RLPy.RVisemeKey()
 +
key.SetTime(RLPy.RTime(300))
 +
key.SetID(RLPy.EVisemeID_AH)
 +
key.SetWeight(80)
 +
result = viseme_component.RemoveVisemesKey(key)
 
</syntaxhighlight>
 
</syntaxhighlight>
Get viseme key information.
 
<span style="background:#ffcccc">( Experimental Class )</span>
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''kTime''' [IN] Time of the key - RLPy.RTime
+
=== GetVisemeMorphWeights ( self ) ===
  
'''eVisemeID''' [IN] Type of the viseme ID - RLPy.EVisemeID
+
Get all of the viseme morph weights on this character.
*'''RLPy.EVisemeID_NONE'''
+
*'''RLPy.EVisemeID_EE'''
+
*'''RLPy.EVisemeID_ER'''
+
*'''RLPy.EVisemeID_IH'''
+
*'''RLPy.EVisemeID_AH'''
+
*'''RLPy.EVisemeID_OH'''
+
*'''RLPy.EVisemeID_W_OO'''
+
*'''RLPy.EVisemeID_S_Z'''
+
*'''RLPy.EVisemeID_CH_J'''
+
*'''RLPy.EVisemeID_F_V'''
+
*'''RLPy.EVisemeID_TH'''
+
*'''RLPy.EVisemeID_T_L_D_N'''
+
*'''RLPy.EVisemeID_B_M_P'''
+
*'''RLPy.EVisemeID_K_G_H_NG'''
+
*'''RLPy.EVisemeID_AE'''
+
*'''RLPy.EVisemeID_R'''
+
  
'''fWeight''' [IN] Settings of Expressiveness - float
+
==== Returns ====
</div>
+
Viseme morph weights - float list
====Returns====
+
 
<div style="margin-left: 2em;">Success or Fail or InvalidParameter - RLPy.RStatus
+
<syntaxhighlight lang="python" line='line'>
</div>
+
# Get avatar viseme component
-----
+
avatar_list = RLPy.RScene.GetAvatars()
===GetVisemeKeys===
+
avatar = avatar_list[0]
<syntaxhighlight lang="Python">
+
viseme_component = avatar.GetVisemeComponent()
RLPy.RIVisemeComponent.GetVisemeKeys ( self )
+
 
 +
# Get viseme morph weights
 +
viseme_weights = viseme_component .GetVisemeMorphWeights()
 
</syntaxhighlight>
 
</syntaxhighlight>
Get Time of all viseme keys.
+
 
<span style="background:#ffcccc">( Experimental Class )</span>
+
=== GetVisemeBones ( self ) ===
====Returns====
+
 
<div style="margin-left: 2em;">Time of the key - list
+
Get all of the viseme bone joints on this character.
</div>
+
 
-----
+
==== Returns ====
===GetVisemeMorphWeights===
+
Return all of the viseme bone joints - [[IC_Python_API:RLPy_RINode|RINode]] list
<syntaxhighlight lang="Python">
+
 
RLPy.RIVisemeComponent.GetVisemeMorphWeights ( self )
+
<syntaxhighlight lang="python" line='line'>
 +
# Get avatar viseme component
 +
avatar_list = RLPy.RScene.GetAvatars()
 +
avatar = avatar_list[0]
 +
viseme_component = avatar.GetVisemeComponent()
 +
 
 +
# Get viseme bones
 +
viseme_bones = viseme_component.GetVisemeBones()
 
</syntaxhighlight>
 
</syntaxhighlight>
Get all morph weights of viseme.
+
 
<span style="background:#ffcccc">( Experimental Class )</span>
+
=== GetVisemeKeys ( self ) ===
====Returns====
+
 
<div style="margin-left: 2em;">The value of morph weights - float
+
Get all the viseme keys inside all of the viseme clips on this character.
</div>
+
 
-----
+
See Also: [[#GetVisemeKey ( self, kTime, kKey )|GetVisemeKey]]
===LoadVocal===
+
 
<syntaxhighlight lang="Python">
+
==== Returns ====
RLPy.RIVisemeComponent.LoadVocal ( self, pAudio, kStartTime, strClipName )
+
All of the viseme keys of all the viseme clips - RVisemeKey list
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
# Get avatar viseme component
 +
avatar_list = RLPy.RScene.GetAvatars()
 +
avatar = avatar_list[0]
 +
viseme_component = avatar.GetVisemeComponent()
 +
 
 +
# Get viseme keys
 +
viseme_key_list = viseme_component.GetVisemeKeys()
 
</syntaxhighlight>
 
</syntaxhighlight>
Import voice source to generate facial/Lips expressions for avatars.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''pAudio''' [IN] Input audio source - RLPy.RIAudioObject
+
=== GetVisemeKey ( self, kTime, kKey ) ===
  
'''kStartTime''' [IN] Specifies the start time of the clip - RLPy.RTime
+
Get the viseme key for the given time.  If a viseme clip does not exist then return '''RLPy.RStatus.Failure'''.
  
'''strClipName''' [IN] The name of the clip - string
+
See Also: [[#GetVisemeKeys ( self )|GetVisemeKeys]]
</div>
+
====Return Values====
+
<div style="margin-left: 2em;">
+
  
'''RLPy.RStatus.Success''' Success
+
==== Parameters ====
 +
:'''kTime''' [IN] Query the viseme key at the specified time - [[IC_Python_API:RLPy_RTime|RTime]]
 +
:'''kKey''' [OUT] Viseme key at the specified time - RVisemeKey
  
'''RLPy.RStatus.Failure''' Fail
+
==== Return ====
</div>
+
:Success - RLPy.RStatus.Success
-----
+
:Failure - RLPy.RStatus.Failure
===RemoveVisemesClip===
+
 
<syntaxhighlight lang="Python">
+
<syntaxhighlight lang="python" line='line'>
RLPy.RIVisemeComponent.RemoveVisemesClip ( self, kTime )
+
# Get avatar viseme component
 +
avatar_list = RLPy.RScene.GetAvatars()
 +
avatar = avatar_list[0]
 +
viseme_component = avatar.GetVisemeComponent()
 +
 
 +
# Get viseme key
 +
ret_key = RLPy.RVisemeKey()
 +
result = viseme_component.GetVisemeKey(RLPy.RTime(0), ret_key)
 
</syntaxhighlight>
 
</syntaxhighlight>
Remove viseme clip.
 
<span style="background:#ffcccc">( Experimental Class )</span>
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''kTime''' [IN] The time for finding viseme clip - RLPy.RTime
+
=== TextToSpeech ( self, strContent, eLanguage, fVolume, fPitch, fSpeed ) ===
</div>
+
 
====Returns====
+
Create a viseme clip from script processed through text-to-speech;
<div style="margin-left: 2em;">Success or Fail or InvalidParameter - RLPy.RStatus
+
 
</div>
+
See Also: [[#TextToVisemeData ( self, strContent, fVolume, fPitch, fSpeed )|TextToVisemeData]]
-----
+
 
===RemoveVisemesKey===
+
==== Parameters ====
<syntaxhighlight lang="Python">
+
:'''strContent''' [IN] Content of speech - string
RLPy.RIVisemeComponent.RemoveVisemesKey ( self, kTime )
+
:'''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
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
# Get avatar viseme component
 +
avatar_list = RLPy.RScene.GetAvatars()
 +
avatar = avatar_list[0]
 +
viseme_component = avatar.GetVisemeComponent()
 +
 
 +
# Text to speech
 +
result = viseme_component.TextToSpeech("speech", RLPy.ELanguage_US, 100, 50, 50)
 
</syntaxhighlight>
 
</syntaxhighlight>
Remove viseme key.
 
<span style="background:#ffcccc">( Experimental Class )</span>
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''kTime''' [IN] The time for finding viseme key - RLPy.RTime
+
=== TextToVisemeData ( self, strContent, fVolume, fPitch, fSpeed ) ===
</div>
+
 
====Returns====
+
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. 
<div style="margin-left: 2em;">Success or Fail or InvalidParameter - RLPy.RStatus
+
 
</div>
+
See Also: [[#TextToSpeech ( self, strContent, eLanguage, fVolume, fPitch, fSpeed )|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.
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
# Get avatar viseme component
 +
avatar_list = RLPy.RScene.GetAvatars()
 +
avatar = avatar_list[0]
 +
viseme_component = avatar.GetVisemeComponent()
 +
 
 +
# Text to viseme data
 +
result = viseme_component.TextToVisemeData("speech", 100, 50, 50)
 +
</syntaxhighlight>
 +
 
 +
=== GetStrength ( self ) ===
 +
 
 +
Get the viseme strength value.
 +
 
 +
==== Returns ====
 +
Viseme strength value - float
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
# Get avatar viseme component
 +
avatar_list = RLPy.RScene.GetAvatars()
 +
avatar = avatar_list[0]
 +
viseme_component = avatar.GetVisemeComponent()
 +
 
 +
# Get viseme strength
 +
strength = viseme_component.GetStrength()
 +
</syntaxhighlight>

Revision as of 20:06, 22 April 2020

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.

Rlpy rivisemecomponent description 01.png

 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)
12 
13 # Remove visemes key
14 result = viseme_component.RemoveVisemesKey(key)

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()