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

Function get_value

utils/text_norm.py:322–342  ·  view source on GitHub ↗
(value_string, use_zeros=True)

Source from the content-addressed store, hash-verified

320 traditional=False, alt_zero=False, alt_one=False, alt_two=True,
321 use_zeros=True, use_units=True):
322 def get_value(value_string, use_zeros=True):
323
324 striped_string = value_string.lstrip('0')
325
326 # record nothing if all zeros
327 if not striped_string:
328 return []
329
330 # record one digits
331 elif len(striped_string) == 1:
332 if use_zeros and len(value_string) != len(striped_string):
333 return [system.digits[0], system.digits[int(striped_string)]]
334 else:
335 return [system.digits[int(striped_string)]]
336
337 # recursively record multiple digits
338 else:
339 result_unit = next(u for u in reversed(
340 system.units) if u.power < len(striped_string))
341 result_string = value_string[:-result_unit.power]
342 return get_value(result_string) + [result_unit] + get_value(striped_string[-result_unit.power:])
343
344 system = create_system(numbering_type)
345

Callers 1

num2chnFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected