diff --git a/TTS/tts/utils/text/characters.py b/TTS/tts/utils/text/characters.py index 592b048c..8fa45ed8 100644 --- a/TTS/tts/utils/text/characters.py +++ b/TTS/tts/utils/text/characters.py @@ -63,6 +63,18 @@ class BaseVocabulary: the vocabulary.""" return self.char_to_id(self.blank) if self.blank else len(self.vocab) + @property + def bos_id(self) -> int: + """Return the index of the bos character. If the bos character is not specified, return the length of the + vocabulary.""" + return self.char_to_id(self.bos) if self.bos else len(self.vocab) + + @property + def eos_id(self) -> int: + """Return the index of the eos character. If the eos character is not specified, return the length of the + vocabulary.""" + return self.char_to_id(self.eos) if self.eos else len(self.vocab) + @property def vocab(self): """Return the vocabulary dictionary.""" @@ -187,6 +199,14 @@ class BaseCharacters: def blank_id(self) -> int: return self.char_to_id(self.blank) if self.blank else len(self.vocab) + @property + def eos_id(self) -> int: + return self.char_to_id(self.eos) if self.eos else len(self.vocab) + + @property + def bos_id(self) -> int: + return self.char_to_id(self.bos) if self.bos else len(self.vocab) + @property def characters(self): return self._characters