MCPcopy
hub / github.com/KittenML/KittenTTS / _three_digits_to_words

Function _three_digits_to_words

kittentts/preprocess.py:44–60  ·  view source on GitHub ↗

Convert a number 0–999 to English words.

(n: int)

Source from the content-addressed store, hash-verified

42
43
44def _three_digits_to_words(n: int) -> str:
45 """Convert a number 0–999 to English words."""
46 if n == 0:
47 return ""
48 parts = []
49 hundreds = n // 100
50 remainder = n % 100
51 if hundreds:
52 parts.append(f"{_ONES[hundreds]} hundred")
53 if remainder < 20:
54 if remainder:
55 parts.append(_ONES[remainder])
56 else:
57 tens_word = _TENS[remainder // 10]
58 ones_word = _ONES[remainder % 10]
59 parts.append(f"{tens_word}-{ones_word}" if ones_word else tens_word)
60 return " ".join(parts)
61
62
63def number_to_words(n: int) -> str:

Callers 1

number_to_wordsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected