[docs]classLanguageBasedLyric(music_parameters.abc.Lyric):"""Lyric based on a natural language. :param written_representation: The text. :type written_representation: str :param language_code: The code for the language of the text. If this is `None` the constant `mutwo.music_parameters.configurations.DEFAULT_LANGUAGE_CODE` will be used. Default to `None`. :type language_code: typing.Optional[str] """def__init__(self,written_representation:str,language_code:typing.Optional[str]=None):iflanguage_codeisNone:language_code=music_parameters.configurations.DEFAULT_LANGUAGE_CODEself.written_representation=written_representationself.language_code=language_code@propertydeflanguage_code(self)->str:returnself._language_code@language_code.setterdeflanguage_code(self,language_code:str):# Epitran will raise an error (FileNotFound) in case# the language_code doesn't exist.self._epitran=epitran.Epitran(language_code)self._language_code=language_code@propertydefwritten_representation(self)->str:returnself._written_representation@written_representation.setterdefwritten_representation(self,written_representation:str):self._written_representation=written_representation@propertydefphonetic_representation(self)->str:word_tuple=self.written_representation.split(" ")return" ".join(["".join(self._epitran.xsampa_list(word))forwordinword_tuple])
[docs]classLanguageBasedSyllable(music_parameters.abc.Syllable,LanguageBasedLyric):"""Syllable based on a natural language. :param is_last_syllable: `True` if it is the last syllable of a word and `False` if it isn't the last syllable :type is_last_syllable: bool :param written_representation: The text. :type written_representation: str :param language_code: The code for the language of the text. If this is `None` the constant `mutwo.music_parameters.configurations.DEFAULT_LANGUAGE_CODE` will be used. Default to `None`. :type language_code: typing.Optional[str] **Warning:** It is a known bug that a split word (syllables) and the word itself will return different values for :attr:`phonetic_representation`. For instance: >>> LanguageBasedLyric('hallo').phonetic_representation "halo:" >>> # And now splitted to syllables: >>> LanguageBasedSyllable('hal').phonetic_representation "hA:l" >>> LanguageBasedSyllable('lo').phonetic_representation "lo:" """def__init__(self,is_last_syllable:bool,*args,**kwargs):music_parameters.abc.Syllable.__init__(self,is_last_syllable)LanguageBasedLyric.__init__(self,*args,**kwargs)