| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
Independent confirmation, from a different and more consequential failure mode than #2798 (which only affected test collection). This breaks import pyannote.audio outright in normal usage — not in a test suite. pyannote.audio's speaker-embedding loading path touches speechbrain's deprecation-redirect shims (speechbrain.k2_integration, .wordemb, .lobes.models.spacy/.flair) during torch's fake-kernel registration, and any shim whose target is a genuinely-missing optional package (k2, flair, spacy) raises ImportError, which propagates through inspect.getmodule's hasattr() check and kills whatever unrelated import triggered it. Minimal repro needs no pyannote at all: python -c "import speechbrain, torchvision" # ImportError python -c "import torchvision, speechbrain" # fine Confirmed this PR's fix (os.path.basename(...) == "inspect.py") resolves it on Windows 10 / Python 3.13 / speechbrain 1.1.0, with real lazy exports, deprecation warnings, and genuine ImportErrors for explicitly-requested missing integrations all still behaving correctly. One thing worth flagging for anyone hitting this in the meantime: pyannote.audio 4.0.7 looks like it fixes this (a quick import pyannote.audio succeeds), but it only reorders pyannote's own imports to dodge the trigger — import speechbrain; import pyannote.audio still fails on 4.0.7. Any code importing speechbrain earlier (ours did, via audio-loading libraries) hits this regardless of pyannote version. Would be great to see this merged — it's a one-line fix for a guard whose intent (per the existing code comment about "PyTorch's op registering machinery") is already exactly right. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
What does this PR do?
On Windows, inspect.py lives at paths like C:\Python311\Lib\inspect.py, so this guard never triggers. Lazy modules with optional dependencies (notably speechbrain.integrations.k2_fsa, which requires k2) can be imported unintentionally during normal model loading, causing hard ImportError crashes on Windows even when k2 is never used.
Replace the slash-specific endswith("/inspect.py") check with os.path.basename(importer_frame.filename) == "inspect.py".
os is already imported in this file; no new dependencies.
Before submittingPR review
Reviewer checklist