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

Function parse_embedding

inspiremusic/dataset/processor.py:272–292  ·  view source on GitHub ↗

Parse utt_embedding/spk_embedding Args: data: Iterable[{key, wav, label, sample_rate}] Returns: Iterable[{key, feat, label}]

(data, normalize, mode='train')

Source from the content-addressed store, hash-verified

270
271
272def parse_embedding(data, normalize, mode='train'):
273 """ Parse utt_embedding/spk_embedding
274
275 Args:
276 data: Iterable[{key, wav, label, sample_rate}]
277
278 Returns:
279 Iterable[{key, feat, label}]
280 """
281
282 for sample in data:
283 sample['utt_embedding'] = torch.tensor(sample['utt_embedding'],
284 dtype=torch.float32)
285 sample['spk_embedding'] = torch.tensor(sample['spk_embedding'],
286 dtype=torch.float32)
287 if normalize:
288 sample['utt_embedding'] = F.normalize(sample['utt_embedding'],
289 dim=0)
290 sample['spk_embedding'] = F.normalize(sample['spk_embedding'],
291 dim=0)
292 yield sample
293
294def tokenize(data, get_tokenizer, allowed_special, mode='train'):
295 """ Decode text to chars or BPE

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected