Predict the coordinates of vowels from 2D sights of a face.
Module CuedSpeech.wherecue
Class WhereVowelPositionsPredictor
Description
Constructor
Create a hand transitions predictor.
Parameters
- version_number: (int) Version of the predictor system ranging (0-3).
View Source
def __init__(self, version_number: int=DEFAULT_VERSION):
"""Create a hand transitions predictor.
:param version_number: (int) Version of the predictor system ranging (0-3).
"""
super(WhereVowelPositionsPredictor, self).__init__()
self._models[0] = BaseWherePositionPredictor
self._models[1] = WherePositionPredictorCustoms
self._models[2] = WherePositionPredictorObserved
self._models[3] = WherePositionPredictorUnified
self.set_version_number(version_number)
Public functions
get_sights_dim
Return the number of sights this predictor was trained for.
View Source
def get_sights_dim(self):
"""Return the number of sights this predictor was trained for."""
return self._model.get_sights_dim()
set_sights_and_predict_coords
Set the sights of a face and predict all vowel positions.
If no sights are provided, it uses default sights. It validates the input type and the number of sights before setting them and predicting vowel coordinates.
Parameters
- sights: (sppasSights | None)
- vowels: (tuple | None) List of vowel position names. Default is all known ones.
Raises
- sppasTypeError: given parameter is not a sppasSights type.
- NotImplementedError: not the expected number of sights
View Source
def set_sights_and_predict_coords(self, sights: sppasSights=None, vowels: tuple=None):
"""Set the sights of a face and predict all vowel positions.
If no sights are provided, it uses default sights. It validates the
input type and the number of sights before setting them and predicting
vowel coordinates.
:param sights: (sppasSights | None)
:param vowels: (tuple | None) List of vowel position names. Default is all known ones.
:raises: sppasTypeError: given parameter is not a sppasSights type.
:raises: NotImplementedError: not the expected number of sights
"""
if self._model is None:
raise sppasCuedPredictorError
self._model.set_sights_and_predict_coords(sights, vowels)
predict_vowels_coords
Estimate the absolute position of all the vowels.
Estimate the absolute positions of specified vowels relative to the sights of a face. It uses predefined coordinates and calculations to determine these positions and stores them in a dictionary. Sights must be set before using this method.
Parameters
- vowels: (tuple) List of vowel position names. If unknown, 'n' is used instead.
Raises
- sppasKeyError: Invalid given vowel code.
View Source
def predict_vowels_coords(self, vowels=('n',)) -> None:
"""Estimate the absolute position of all the vowels.
Estimate the absolute positions of specified vowels relative to the
sights of a face. It uses predefined coordinates and calculations
to determine these positions and stores them in a dictionary.
Sights must be set before using this method.
:param vowels: (tuple) List of vowel position names. If unknown, 'n' is used instead.
:raises: sppasKeyError: Invalid given vowel code.
"""
self._model.predict_vowels_coords(vowels)
get_vowel_coords
Return the absolute position of the given vowel.
Estimated relatively to the sights of a face. Sights must be set before using this method.
Parameters
- vowel: (char) Vowel position name. If unknown, 'n' is used instead.
Returns
- tuple(x, y, r) with point coordinates and radius
Raises
- sppasKeyError: Invalid given vowel code.
View Source
def get_vowel_coords(self, vowel: str='n') -> tuple:
"""Return the absolute position of the given vowel.
Estimated relatively to the sights of a face. Sights must be set
before using this method.
:param vowel: (char) Vowel position name. If unknown, 'n' is used instead.
:return: tuple(x, y, r) with point coordinates and radius
:raises: sppasKeyError: Invalid given vowel code.
"""
return self._model.get_vowel_coords(vowel)
