espnet3.systems.f5tts.src.pinyin.load_vocab_char_map
Less than 1 minute
espnet3.systems.f5tts.src.pinyin.load_vocab_char_map
espnet3.systems.f5tts.src.pinyin.load_vocab_char_map(vocab_file: str) → Dict[str, int]
Load F5’s vocab.txt as {token: index} (line number = index).
- Parameters:vocab_file – Path to F5’s
vocab.txt, one token per line. - Returns: Mapping from token to its line number.
Example
>>> load_vocab_char_map("vocab.txt") # first line is a space
{' ': 0, 'a': 1, 'b': 2}NOTE
Only the trailing newline is stripped, never surrounding whitespace, so F5’s literal space token at index 0 survives. Stripping it would shift every id and silently corrupt the mapping. Unlike an ESPnet token list this vocabulary has no <blank> / <unk> / <sos/eos>.
