Auto-CS 2.0

https://sourceforge.net/projects/autocs/

Module CuedSpeech.wherecue

Class sppasWhereAnglesPredictor

Description

Predict the angle of the wrist at all vowel positions.

Create a tier indicating the angles.

Constructor

Create a new instance of angles predictor.

Parameters
  • predictor_version
View Source
def __init__(self, predictor_version=WhereAnglesPredictor.DEFAULT_VERSION):
    """Create a new instance of angles predictor.

    """
    self.__predictor = WhereAnglesPredictor(predictor_version)

Public functions

version_numbers

Return the whole list of supported version numbers.

View Source
def version_numbers(self) -> list:
    """Return the whole list of supported version numbers."""
    return self.__predictor.version_numbers()

get_version_number

Return the version number of the selected predictor (int).

View Source
def get_version_number(self) -> int:
    """Return the version number of the selected predictor (int)."""
    return self.__predictor.get_version_number()

set_version_number

Change the predictor version number.

Parameters
  • version_number: (int) One of the supported versions.
Raises
  • sppasKeyError: if invalid version number
View Source
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)

get_use_face

Return True if the hand angle must be corrected by the one of the face.

View Source
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

set_use_face

The angle of the hand is corrected by the one of the face or not.

Parameters
  • value: (bool) True if the angle of the hand has to be corrected.
View Source
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

hand_angles

Predict the angles for the given vowels.

Notice that the coordinates of the position can have negative values.

Parameters
  • tier_pos: (sppasTier) Coordinates of the vowel positions.
  • face_sights: (sppasTier) Sights of the face corresponding to each vowel.
Returns
  • (sppasTier) tier with name 'CS-HandAngle'
View Source
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

Protected functions

__eval_hand_angle

Return angle of the hand for each ann in given tier.

Parameters
  • handposprobas: (sppasTier) Coordinates of the vowel positions.
  • face_sights: (sppasTier) Sights of the face corresponding to each vowel.
Returns
  • (list) Angle values -- one for each ann in given tier.
View Source
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