MCPcopy Create free account
hub / github.com/MoonInTheRiver/DiffSinger / encode

Method encode

utils/text_encoder.py:46–60  ·  view source on GitHub ↗

Transform a human-readable string into a sequence of int ids. The ids should be in the range [num_reserved_ids, vocab_size). Ids [0, num_reserved_ids) are reserved. EOS is not appended. Args: s: human-readable string to be converted. Returns:

(self, s)

Source from the content-addressed store, hash-verified

44 return self._num_reserved_ids
45
46 def encode(self, s):
47 """Transform a human-readable string into a sequence of int ids.
48
49 The ids should be in the range [num_reserved_ids, vocab_size). Ids [0,
50 num_reserved_ids) are reserved.
51
52 EOS is not appended.
53
54 Args:
55 s: human-readable string to be converted.
56
57 Returns:
58 ids: list of integers
59 """
60 return [int(w) + self._num_reserved_ids for w in s.split()]
61
62 def decode(self, ids, strip_extraneous=False):
63 """Transform a sequence of int ids into a human-readable string.

Callers 6

encodeMethod · 0.45
encodeMethod · 0.45
process_itemMethod · 0.45
process_itemMethod · 0.45
process_itemMethod · 0.45
add_dur_lossMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected