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

Method encode

utils/text_encoder.py:108–115  ·  view source on GitHub ↗
(self, s)

Source from the content-addressed store, hash-verified

106 """Encodes each byte to an id. For 8-bit strings only."""
107
108 def encode(self, s):
109 numres = self._num_reserved_ids
110 if six.PY2:
111 if isinstance(s, unicode):
112 s = s.encode("utf-8")
113 return [ord(c) + numres for c in s]
114 # Python3: explicitly convert to UTF-8
115 return [c + numres for c in s.encode("utf-8")]
116
117 def decode(self, ids, strip_extraneous=False):
118 if strip_extraneous:

Callers

nothing calls this directly

Calls 1

encodeMethod · 0.45

Tested by

no test coverage detected