Skip to content

Commit

Permalink
Add get_number_tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
WeberJulian committed Oct 20, 2023
1 parent 478fe0b commit 202d747
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions TTS/tts/layers/xtts/tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,3 +509,6 @@ def decode(self, seq):

def __len__(self):
return self.tokenizer.get_vocab_size()

def get_number_tokens(self):
return max(self.tokenizer.get_vocab().values()) + 1
2 changes: 1 addition & 1 deletion TTS/tts/models/xtts.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def __init__(self, config: Coqpit):
def init_models(self):
"""Initialize the models. We do it here since we need to load the tokenizer first."""
if self.tokenizer.tokenizer is not None:
self.args.gpt_number_text_tokens = max(self.tokenizer.tokenizer.get_vocab().values()) + 1
self.args.gpt_number_text_tokens = self.tokenizer.get_number_tokens()
self.args.gpt_start_text_token = self.tokenizer.tokenizer.token_to_id("[START]")
self.args.gpt_stop_text_token = self.tokenizer.tokenizer.token_to_id("[STOP]")

Expand Down

0 comments on commit 202d747

Please sign in to comment.