Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Per-PR attribution and contributor credits are published automatically on the co
### Fixed
- `GAP_TRIM_MS=0` turns the base chunk trim off. It used to slice every chunk to nothing, so all audio came back silent
- Money with cents reads the whole part right: `-$1.50` is "minus one dollar and fifty cents" (was "minus two dollars"), and `$1.05` says "one dollar", not "one dollars"
- Money with more than two decimals is read as a decimal number: `$3.499` is "three point four nine nine dollars" (was "three dollars and four hundred and ninety-nine cents"), and `$0.0012` no longer becomes "twelve cents"
- Non-streamed WAV (`"stream": false`) has its real length in the header. It said 4 GB, so readers that trust the header, like Python's `wave`, reported a one-sentence file as about 25 hours long (#586)

## [v0.10.0] - 2026-11-08: Websockets/Realtime API, CPU Memory & API Keys
Expand Down
9 changes: 9 additions & 0 deletions api/src/services/text_processing/normalization/english.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,15 @@ def handle(m: re.Match[str]) -> str:
whole = INFLECT_ENGINE.number_to_words(conditional_int(number))
return f"{whole}{multiplier} {bills}"

digits = m.group(3).replace(",", "")
if len(digits.partition(".")[2]) > 2:
# More than two decimals is not a cents amount ($3.499 a gallon,
# $0.0012 per token): read the decimal number, not 499 or 12 cents.
if digits.startswith("."):
digits = "0" + digits
whole = INFLECT_ENGINE.number_to_words(m.group(1) + digits)
return f"{whole} {bills}"

# Read the sign on its own: floor(-1.5) is -2, and int(-0.25) drops the minus.
sign = "minus " if number < 0 else ""
dollars = int(abs(number))
Expand Down
5 changes: 5 additions & 0 deletions api/tests/test_normalizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@
("-$0.25", "minus zero dollars and twenty-five cents"),
("$1.05 each", "one dollar and five cents each"),
("€1.20", "one euro and twenty cents"),
# more than two decimals is a rate, not cents
("Gas is $3.499 a gallon", "Gas is three point four nine nine dollars a gallon"),
("$0.0012 per token", "zero point zero zero one two dollars per token"),
("-$1.005", "minus one point zero zero five dollars"),
("£2.000", "two pounds"),
# issue #224
(
"still slated to lose $400 million.",
Expand Down