Self Checks
Cloud or Self Hosted
Self Hosted (Source)
Environment Details
- Fish Speech: latest main (commit hash: 0def6f3)
- torchaudio: 2.8.0
- Python: 3.12
Steps to Reproduce
Description:
api_server.py fails on startup with:
File "fish_speech/inference_engine/reference_loader.py", line 39, in __init__
backends = torchaudio.list_audio_backends()
^^^^^^^^^^
UnboundLocalError: cannot access local variable 'torchaudio' where it is not associated with a value
Likely Cause:
In ReferenceLoader.__init__, line 49 has:
import torchaudio.io._load_audio_fileobj
Even though this line is inside a nested try/except block that only executes when torchaudio >= 2.9, Python's compiler sees the import torchaudio... statement and marks torchaudio as a local variable for the entire method. This shadows the top-level import torchaudio on line 8, causing the UnboundLocalError on line 39 before any local assignment happens.
Fix:
Change line 49 from:
import torchaudio.io._load_audio_fileobj # noqa: F401
to:
from torchaudio.io import _load_audio_fileobj # noqa: F401
✔️ Expected Behavior
No response
❌ Actual Behavior
No response
Self Checks
Cloud or Self Hosted
Self Hosted (Source)
Environment Details
Steps to Reproduce
Description:
api_server.pyfails on startup with:Likely Cause:
In
ReferenceLoader.__init__, line 49 has:Even though this line is inside a nested
try/exceptblock that only executes whentorchaudio >= 2.9, Python's compiler sees theimport torchaudio...statement and markstorchaudioas a local variable for the entire method. This shadows the top-levelimport torchaudioon line 8, causing theUnboundLocalErroron line 39 before any local assignment happens.Fix:
Change line 49 from:
to:
✔️ Expected Behavior
No response
❌ Actual Behavior
No response