Predict the angle of the wrist at all vowel positions.
Create a tier indicating the angles.

Predict the angle of the wrist at all vowel positions.
Create a tier indicating the angles.
Create a new instance of angles predictor.
def __init__(self, predictor_version=WhereAnglesPredictor.DEFAULT_VERSION):
"""Create a new instance of angles predictor.
"""
self.__predictor = WhereAnglesPredictor(predictor_version)
Return the whole list of supported version numbers.
def version_numbers(self) -> list:
"""Return the whole list of supported version numbers."""
return self.__predictor.version_numbers()
Return the version number of the selected predictor (int).
def get_version_number(self) -> int:
"""Return the version number of the selected predictor (int)."""
return self.__predictor.get_version_number()
Change the predictor version number.
def set_version_number(self, version_number: int) -> None:
"""Change the predictor version number.
:param version_number: (int) One of the supported versions.
:raises: sppasKeyError: if invalid version number
"""
self.__predictor.set_version_number(version_number)
Return True if the hand angle must be corrected by the one of the face.
def get_use_face(self) -> bool:
"""Return True if the hand angle must be corrected by the one of the face."""
return self.__predictor.use_face
The angle of the hand is corrected by the one of the face or not.
def set_use_face(self, value: bool) -> None:
"""The angle of the hand is corrected by the one of the face or not.
:param value: (bool) True if the angle of the hand has to be corrected.
"""
self.__predictor.use_face = value
Predict the angles for the given vowels.
Notice that the coordinates of the position can have negative values.
def hand_angles(self, tier_pos: sppasTier, face_sights: sppasTier=None):
"""Predict the angles for the given vowels.
Notice that the coordinates of the position can have negative values.
:param tier_pos: (sppasTier) Coordinates of the vowel positions.
:param face_sights: (sppasTier) Sights of the face corresponding to each vowel.
:return: (sppasTier) tier with name 'CS-HandAngle'
"""
angles = self.__eval_hand_angle(tier_pos, face_sights)
angles_tier = sppasTier('CS-HandAngle')
for (ann, angle) in zip(tier_pos, angles):
loc = ann.get_location().copy()
tag = sppasTag(angle, tag_type='int')
angles_tier.create_annotation(loc, sppasLabel(tag))
return angles_tier
Return angle of the hand for each ann in given tier.
def __eval_hand_angle(self, hand_pos_probas, face_sights):
"""Return angle of the hand for each ann in given tier.
:param hand_pos_probas: (sppasTier) Coordinates of the vowel positions.
:param face_sights: (sppasTier) Sights of the face corresponding to each vowel.
:return: (list) Angle values -- one for each ann in given tier.
"""
angles = list()
for i in range(len(hand_pos_probas)):
cur_vowels = list()
cur_probas = list()
for label in hand_pos_probas[i].get_labels():
for (tag, score) in label:
cur_vowels.append(tag.get_content())
cur_probas.append(score)
face_angle = 90
if face_sights is not None:
(_, _, sights) = face_sights[i]
face_angle = observed_angle((sights.x(8), sights.y(8)), (sights.x(27), sights.y(27)))
self.__predictor.predict_angle_values(cur_vowels)
if len(cur_vowels) == 1:
angles.append(self.__predictor.get_angle(cur_vowels[0], face_angle))
elif len(cur_vowels) == 2:
angle1 = self.__predictor.get_angle(cur_vowels[0], face_angle)
angle2 = self.__predictor.get_angle(cur_vowels[1], face_angle)
da = angle2 - angle1
na = angle1 + int(float(da) * cur_probas[1])
angles.append(na)
return angles