MCPcopy Create free account
hub / github.com/FunAudioLLM/FunMusic / tokenize

Function tokenize

inspiremusic/dataset/processor.py:294–310  ·  view source on GitHub ↗

Decode text to chars or BPE Inplace operation Args: data: Iterable[{key, wav, txt, sample_rate}] Returns: Iterable[{key, wav, txt, tokens, label, sample_rate}]

(data, get_tokenizer, allowed_special, mode='train')

Source from the content-addressed store, hash-verified

292 yield sample
293
294def tokenize(data, get_tokenizer, allowed_special, mode='train'):
295 """ Decode text to chars or BPE
296 Inplace operation
297
298 Args:
299 data: Iterable[{key, wav, txt, sample_rate}]
300
301 Returns:
302 Iterable[{key, wav, txt, tokens, label, sample_rate}]
303 """
304 tokenizer = get_tokenizer()
305
306 for sample in data:
307 assert 'text' in sample
308 sample['text_token'] = tokenizer.encode(sample['text'],
309 allowed_special=allowed_special)
310 yield sample
311
312
313def shuffle(data, shuffle_size=10000, mode='train'):

Callers 2

calc_utt_lengthFunction · 0.85
should_mergeFunction · 0.85

Calls 2

get_tokenizerFunction · 0.85
encodeMethod · 0.45

Tested by

no test coverage detected