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

Method decode_list

utils/text_encoder.py:79–98  ·  view source on GitHub ↗

Transform a sequence of int ids into a their string versions. This method supports transforming individual input/output ids to their string versions so that sequence to/from text conversions can be visualized in a human readable format. Args: ids: list of in

(self, ids)

Source from the content-addressed store, hash-verified

77 return " ".join(self.decode_list(ids))
78
79 def decode_list(self, ids):
80 """Transform a sequence of int ids into a their string versions.
81
82 This method supports transforming individual input/output ids to their
83 string versions so that sequence to/from text conversions can be visualized
84 in a human readable format.
85
86 Args:
87 ids: list of integers to be converted.
88
89 Returns:
90 strs: list of human-readable string.
91 """
92 decoded_ids = []
93 for id_ in ids:
94 if 0 <= id_ < self._num_reserved_ids:
95 decoded_ids.append(RESERVED_TOKENS[int(id_)])
96 else:
97 decoded_ids.append(id_ - self._num_reserved_ids)
98 return [str(d) for d in decoded_ids]
99
100 @property
101 def vocab_size(self):

Callers 1

decodeMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected