fix(common): load the expanded abbreviation set instead of assigning to list.extend - #16109
Open
udsy19 wants to merge 1 commit into
Open
fix(common): load the expanded abbreviation set instead of assigning to list.extend#16109udsy19 wants to merge 1 commit into
udsy19 wants to merge 1 commit into
Conversation
`clean_abbreviations(version="expanded")` assigned to `list.extend` instead of calling it, which raises `AttributeError: 'list' object attribute 'extend' is read-only`. `CharParser._normalize` wraps `clean_text` in a bare `except Exception: return None`, and `AudioText` treats a `None` token list as a filtered sample, so every utterance parsed by `ENCharParser(abbreviation_version="expanded")` was silently dropped - including utterances containing no abbreviation at all. Build a new list instead of mutating in place: the local name aliases the module-level `ABBREVIATIONS_COMMON`, so an in-place `extend()` would leak the expanded entries into every later `version=None`/`"fastpitch"` call in the process. Adds unit tests covering both the expansion and the absence of cross-call and cross-instance state leakage. Signed-off-by: Udaya Tejas <udayatejas2004@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do ?
Makes the
expandedabbreviation set actually load, soENCharParser(abbreviation_version='expanded')stops returningNone.Collection: Common
Fixes #16108.
Changelog
clean_abbreviations(version="expanded")assigned tolist.extendinstead of calling it:list.extendis read-only, so this raisesAttributeError: 'list' object attribute 'extend' is read-only.clean_abbreviationsis on the unconditional path insideclean_text, andCharParser._normalizewrapsclean_textinexcept Exception: return None;AudioTextthen treatsthe
Nonetoken list as a filtered sample. The result is thatENCharParser(abbreviation_version="expanded")silently drops every utterance — includingutterances with no abbreviation in them — and the dataset loads zero samples with no traceback.
The fix builds a new list rather than mutating in place.
abbbreviationsaliases the module-levelABBREVIATIONS_COMMON, so the obvious repairabbbreviations.extend(ABBREVIATIONS_EXPANDED)wouldpermanently grow that global and leak the expanded abbreviations into every later
version=Noneandversion="fastpitch"call in the same process.Scope: one line in
cleaners.pyplus a new unit-test module.version=Noneandversion="fastpitch"behaviour is unchanged.
Testing
New
tests/collections/common/test_preprocessing_cleaners.py(8 unit tests). No existing test moduleimported
cleanersorENCharParser."expanded"now expands both the common abbreviations (mr.→mister) and theexpanded-only ones (
ltd.→limited).version=Noneandversion="fastpitch"are asserted unchanged; both pass before andafter the fix.
ABBREVIATIONS_COMMON/ABBREVIATIONS_TTS_FASTPITCHare unmodified after an"expanded"call, a laterversion=Nonecall does not gain the expanded entries, and twoENCharParserinstances stay independent regardless of construction order.Results on this branch:
AttributeError: 'list' object attribute 'extend' is read-only;assert None == [9, 6, 13, 13, 16])abbbreviations.extend(ABBREVIATIONS_EXPANDED)insteadThe middle row is deliberate: the tests are written so that a fix which expands correctly but mutates
the module-level list still fails.
Wider run on this branch —
tests/collections/common/test_preprocessing_cleaners.py,tests/collections/asr/test_asr_ctcencdec_model.py,tests/collections/common/tokenizers:18 passed, 48 skipped.
Style:
black24.10.0 andisort5.13.2 (repo settings, line length 119) report no changes;flake8 --config .flake8.otherexits 0;pylint --rcfile .pylintrc.otherratescleaners.py10.00/10;pre-commit run --from-ref main --to-ref HEADpasses.No documentation change:
abbreviation_versionis not documented indocs/, and this restores thedocumented-by-signature behaviour rather than changing an API.
GitHub Actions CI
Trusted PRs run automatically through copy-pr-bot. For an untrusted PR, a maintainer can trigger CI by commenting
/ok to test <head-sha>; repeat this after a new push if the PR remains untrusted.Before your PR is "Ready for review"
Pre checks:
PR Type: