Conversation
📝 WalkthroughWalkthroughTTSModelInfo now replaces its public Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Note Docstrings generation - SUCCESS |
Docstrings generation was requested by @JarbasAl. * #107 (comment) The following files were modified: * `phoonnx/model_manager.py`
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
phoonnx/model_manager.py (1)
29-78:⚠️ Potential issue | 🟡 MinorThe
configproperty is no longer part of the dataclass__repr__.Since
configchanged from a dataclass field to a property, it will no longer appear inrepr(TTSModelInfo(...)). This is likely the desired behavior (avoids triggering lazy-load onrepr), but the example output in the comments at the bottom of the file (lines ~396-405) is now stale and includesconfig=VoiceConfig(...).
🤖 Fix all issues with AI agents
In `@phoonnx/model_manager.py`:
- Around line 42-58: The conditional for handling tokens_url currently uses a
separate if that can overwrite a previously built self._config from the
vocab_override or vocab_url branches; change that if to an elif so
download_tokens_txt() and the tokens-based VoiceConfig.from_dict(...) only run
when earlier branches did not set self._config, and ensure phoneme_type is
applied to the final config object (self._config) after construction; locate the
logic around self.vocab_override, self.vocab_url, download_vocab(),
download_tokenizer_config(), self.tokens_url, download_tokens_txt(), and
VoiceConfig.from_dict to implement this change.
🧹 Nitpick comments (2)
phoonnx/model_manager.py (2)
80-87: Lazy-load init looks good;os.makedirsstill runs eagerly for every voice.The
_configbacking field initialization is correct. Note thatos.makedirs(line 87) still runs eagerly during construction — so instantiating all ~1400+TTSModelInfoentries (e.g., viamerge_default_voices) creates that many cache directories even ifconfigis never accessed. This pre-dates this PR, but if the goal is to defer I/O, you might consider making this lazy too.
29-32: Preferif self._config is None:overif not self._config:.Using truthiness to guard lazy initialization is fragile — if
VoiceConfigever defines__bool__or__len__, this could cause the property to re-compute on every access. The idiomatic pattern for lazy init is an identity check againstNone.♻️ Proposed fix
`@property` def config(self) -> VoiceConfig: # lazy loaded - if not self._config: + if self._config is None:
Docstrings generation was requested by @JarbasAl. * #107 (comment) The following files were modified: * `phoonnx/model_manager.py` Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
delay network requests until needed 📝 Add docstrings to `fixes` (#108) Docstrings generation was requested by @JarbasAl. * #107 (comment) The following files were modified: * `phoonnx/model_manager.py` Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Docstrings generation was requested by @JarbasAl. * #107 (comment) The following files were modified: * `phoonnx/config.py` * `phoonnx/model_manager.py`
There was a problem hiding this comment.
🧹 Nitpick comments (1)
phoonnx/model_manager.py (1)
99-114: Eagermakedirsfor every voice contradicts the lazy-loading intent.
os.makedirs(self.voice_path, exist_ok=True)on line 106 runs during__post_init__for everyTTSModelInfoinstance. With 1400+ registered voices (permerge_default_voices), this issues 1400+makedirssyscalls at startup, even for voices that are never loaded.Move directory creation into the
configproperty (or into eachdownload_*method) so it only runs when a voice is actually accessed.♻️ Proposed fix — defer makedirs to first use
def __post_init__(self): self._config: Optional[VoiceConfig] = None - os.makedirs(self.voice_path, exist_ok=True) # cast strings to enum for consistency if not isinstance(self.engine, Engine) and isinstance(self.engine, str):Then, at the start of the
configproperty (or in a shared helper called by each download method):`@property` def config(self) -> VoiceConfig: if not self._config: + os.makedirs(self.voice_path, exist_ok=True) if self.config_url:
* refactor!: tokenizer class + deprecate phoneme_ids.py (#70) * fix: coqui compatibility refactor!: tokenizer class + deprecate phoneme_ids.py fix: missing cotovia data files feat: add new galician models from proxecto nós * log * fix * fix * Merge pull request #71 from TigreGotico/coderabbitai/docstrings/cb634ab 📝 Add docstrings to `tokenizer` * adjust --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Increment Version to 1.0.0a1 * Update Changelog * feat: community piper voices + pygoruut support (#73) * feat: community piper voices + pygoruut support update model manager voice index Total voices: 284 Total langs: 67 * fix neurlang voice-id * reorder funcs for readability * 📝 Add docstrings to `models_galore` (#74) Docstrings generation was requested by @JarbasAl. * #73 (comment) The following files were modified: * `phoonnx/model_manager.py` * `phoonnx/util.py` Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Increment Version to 1.1.0a1 * Update Changelog * feat: more piper english community voices (#76) Total voices: 314 * Increment Version to 1.2.0a1 * Update Changelog * feat: transformers support (#78) feat: MMS voices refactor: move index to static .json files * Increment Version to 1.3.0a1 * Update Changelog * documentation: supported voices and languages (#80) * documentation: supported voices and languages * documentation: supported voices and languages * documentation: supported voices and languages * Increment Version to 1.3.0a2 * Update Changelog * documentation: supported voices and languages (#82) * Increment Version to 1.3.0a3 * Update Changelog * fix: failing MMS models indexing (#84) * Increment Version to 1.3.0a4 * Update Changelog * fix: improve lang code standardization (#86) * fix: improve lang code standardization * siimplify error handling * Increment Version to 1.3.1a1 * Update Changelog * Add renovate.json (#89) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Increment Version to 1.3.1a2 * Update Changelog * fix: mantoq2ipa + improve lang code normalization (#90) * fix: improve lang code standardization * siimplify error handling * fix: better arabic ipa g2p * fix tests * rrm unused arg * Increment Version to 1.3.2a1 * chore(deps): update actions/checkout action to v6 (#92) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Increment Version to 1.3.2a2 * chore(deps): update actions/setup-python action to v6 (#96) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Increment Version to 1.3.2a3 * Update Changelog * add more voices (#99) * Increment Version to 1.3.2a4 * Update Changelog * 📝 Add docstrings to `patch-2` (#102) Docstrings generation was requested by @JarbasAl. * #101 (comment) The following files were modified: * `phoonnx/model_manager.py` Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Increment Version to 1.3.2a5 * Update Changelog * Add files via upload * fix: dont chunk on commas, update voice index (#104) * fix: dont chunk on commas, update voice index * fix: dont chunk on commas, update voice index * 📝 Add docstrings to `fixes` (#105) Docstrings generation was requested by @JarbasAl. * #104 (comment) The following files were modified: * `phoonnx/model_manager.py` * `phoonnx/opm.py` * `phoonnx/phonemizers/base.py` * `phoonnx_train/vits/dataset.py` * `phoonnx_train/vits/lightning.py` * `scripts/index_voices.py` Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * fix: dont chunk on commas, update voice index --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Increment Version to 1.3.3a1 * Update Changelog * fix: lazy load VoiceConfig (#107) delay network requests until needed 📝 Add docstrings to `fixes` (#108) Docstrings generation was requested by @JarbasAl. * #107 (comment) The following files were modified: * `phoonnx/model_manager.py` Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Increment Version to 1.3.3a2 * Update Changelog --------- Co-authored-by: JarbasAI <33701864+JarbasAl@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: JarbasAl <JarbasAl@users.noreply.github.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Summary by CodeRabbit
New Features
Refactor