Auto-CS 2.0

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

Module CuedSpeech.wherecue.angle

Class BaseWhereAnglePredictor

Description

Base class to predict the angle of the hand.

Currently, 5 vowel positions are possible, and they are associated to only one angle value. For English langage, this will have to be changed because some vowels have a movement effect: side-forward, side-down.

Angle value is given relatively to the horizontal axis, like in the following unit circle:

90° | | 180° ------- + ------- 0° | | 270° -90°

Constructor

Instantiate a hand angle's predictor.

View Source
def __init__(self):
    """Instantiate a hand angle's predictor.

    """
    self._description = MSG_DESCRIPTION_BASE
    self._vowels = dict()
    self._radius = 10
    self.__vowel_mapping = {'b': self._calculate_angle_b, 'c': self._calculate_angle_c, 'm': self._calculate_angle_m, 's': self._calculate_angle_s, 't': self._calculate_angle_t, 'n': self._calculate_angle_n}

Public functions

vowel_codes

Return the list of vowel codes the class can calculate hand angles for.

View Source
def vowel_codes(self) -> tuple:
    """Return the list of vowel codes the class can calculate hand angles for."""
    return tuple(self.__vowel_mapping.keys())

get_radius

Vagueness of angle value.

View Source
def get_radius(self) -> int:
    """Vagueness of angle value."""
    return self._radius

set_radius

Fix a new radius value.

Parameters
  • r: (int) The new radius value between 0 and MAX_RADIUS.
Raises
  • ValueError: Invalid given radius value.
View Source
def set_radius(self, r: int):
    """Fix a new radius value.

        :param r: (int) The new radius value between 0 and MAX_RADIUS.
        :raises: ValueError: Invalid given radius value.

        """
    r = int(r)
    if r < 0 or r > self.MAX_RADIUS:
        raise IntervalRangeException(r, 0, BaseWhereAnglePredictor.MAX_RADIUS)
    self._radius = r

get_angle

Return the angle at a given position.

Parameters
  • vowel: (char) Vowel position name. If unknown, 'n' is used instead.
Returns
  • (int)
Raises
  • sppasKeyError: Invalid given vowel code.
View Source
def get_angle(self, vowel: str='n') -> tuple:
    """Return the angle at a given position.

        :param vowel: (char) Vowel position name. If unknown, 'n' is used instead.
        :return: (int)
        :raises: sppasKeyError: Invalid given vowel code.

        """
    if vowel in self._vowels:
        return self._vowels[vowel]
    raise sppasKeyError(vowel, 'Predicted Angles')

predict_angle_values

Estimate the angle of the hand for all the given positions.

It uses predefined angles and stores them in a dictionary.

Parameters
  • vowels: (tuple) List of vowel position names. If unknown, 'n' is used instead.
Raises
  • sppasKeyError: Invalid given vowel code.
View Source
def predict_angle_values(self, vowels=('n',)) -> None:
    """Estimate the angle of the hand for all the given positions.

        It uses predefined angles and stores them in a dictionary.

        :param vowels: (tuple) List of vowel position names. If unknown, 'n' is used instead.
        :raises: sppasKeyError: Invalid given vowel code.

        """
    self.check(vowels)
    self._vowels = dict()
    codes = self.vowel_codes()
    for vowel in vowels:
        if vowel not in codes:
            raise sppasKeyError(vowel, 'Position Code')
        self._vowels[vowel] = self.__vowel_mapping[vowel]()

check

Check if the given vowel codes are valid.

Parameters
  • vowels: (list of characters)
Raises
  • sppasKeyError: Invalid given vowel code.
View Source
def check(self, vowels: list):
    """Check if the given vowel codes are valid.

        :param vowels: (list of characters)
        :raises: sppasKeyError: Invalid given vowel code.

        """
    codes = self.vowel_codes()
    for vowel in vowels:
        if vowel not in codes:
            raise sppasKeyError(vowel, 'Position Code')

Private functions

_calculate_angle_n

To be overridden. Calculate the angle at the neutral position.

Returns
  • (int) angle in degrees
View Source
def _calculate_angle_n(self) -> int:
    """To be overridden. Calculate the angle at the neutral position.

        :return: (int) angle in degrees

        """
    return 60

_calculate_angle_b

To be overridden. Calculate the angle at the cheek bone position.

Returns
  • (int) angle in degrees
View Source
def _calculate_angle_b(self) -> int:
    """To be overridden. Calculate the angle at the cheek bone position.

        :return: (int) angle in degrees

        """
    return 60

_calculate_angle_c

To be overridden. Calculate the angle at the chin position.

Returns
  • (int) angle in degrees
View Source
def _calculate_angle_c(self) -> int:
    """To be overridden. Calculate the angle at the chin position.

        :return: (int) angle in degrees

        """
    return 60

_calculate_angle_m

To be overridden. Calculate the angle at the mouse position.

Returns
  • (int) angle in degrees
View Source
def _calculate_angle_m(self) -> int:
    """To be overridden. Calculate the angle at the mouse position.

        :return: (int) angle in degrees

        """
    return 60

_calculate_angle_s

To be overridden. Calculate the angle at the side position.

Returns
  • (int) angle in degrees
View Source
def _calculate_angle_s(self) -> int:
    """To be overridden. Calculate the angle at the side position.

        :return: (int) angle in degrees

        """
    return 60

_calculate_angle_t

To be overridden. Calculate the angle at the throat position.

Returns
  • (int) angle in degrees
View Source
def _calculate_angle_t(self) -> int:
    """To be overridden. Calculate the angle at the throat position.

        :return: (int) angle in degrees

        """
    return 60