Skip to content

Commit

Permalink
fix: add support for leading zero in transcription when spoken by user
Browse files Browse the repository at this point in the history
- Ensures that leading zero is included in the transcription when explicitly voiced.
  • Loading branch information
chihangc authored Nov 21, 2024
1 parent 173ff7d commit fdd1b6f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions whisper/normalizers/english.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ def output(result: Union[str, int]):
prefix = current[0] if has_prefix else prefix
if f.denominator == 1:
value = f.numerator # store integers as int
# count the number of leading zeros and add back all leading zeros if they were removed
leading_zeros = len(current_without_prefix) - len(current_without_prefix.lstrip('0'))
if leading_zeros > 0 and value != 0:
value = "0" * leading_zeros + str(value)
else:
value = current_without_prefix
elif current not in self.words:
Expand Down

0 comments on commit fdd1b6f

Please sign in to comment.