funasr_onnx: bare `raise "string"` masks the real exception (TypeError: exceptions must derive from BaseException)
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 70/100
Direzione di ricerca
Inizia da runtime/python/onnxruntime/funasr_onnx/sensevoice_bin.py alle righe indicate, quindi esamina paraformer_online_bin.py e gli altri file *_bin.py per verificare la stessa gestione degli errori. Controlla ogni percorso che utilizza un bare except o solleva una stringa e verifica che l’errore di importazione originale rimanga visibile, mentre gli errori non correlati non vengano classificati erroneamente come assenza di funasr.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Several error paths in funasr_onnx do raise "some message". That is invalid in Python 3 — a string is not an exception — so the interpreter discards the intended message and raises TypeError: exceptions must derive from BaseException instead.
Combined with the surrounding bare except:, the actual cause is swallowed entirely.
Where
runtime/python/onnxruntime/funasr_onnx/sensevoice_bin.py (current main), lines 50, 54, 66:
try:
from funasr import AutoModel
except:
raise "You are exporting onnx, please install funasr and try it again. ..."
The same pattern appears in paraformer_online_bin.py and other *_bin.py files.
What the user sees
File ".../funasr_onnx/sensevoice_bin.py", line 66, in __init__
raise "You are exporting onnx, please install funasr and try it again..."
TypeError: exceptions must derive from BaseException
What was actually wrong
In my case funasr was installed. The import failed on a missing transitive
dependency:
File ".../funasr/utils/load_utils.py", line 9, in <module>
import torchaudio
ModuleNotFoundError: No module named 'torchaudio'
The message told me to install a package I already had, while hiding the one I was
missing. Diagnosing it required reading the library source and reproducing the import
by hand.
I hit the same thing a second time on onnxscript (required by newer torch.onnx),
and again when loading a model from a local path — line 54 fires whenever the path
check fails for any reason, so a simple wrong-path mistake also surfaces as
TypeError.
Suggested fix
try:
from funasr import AutoModel
except ImportError as e:
raise ImportError(
"Exporting ONNX requires funasr: pip3 install -U funasr"
) from e
raise ... from e keeps the original traceback, so a missing torchaudio stays
visible. Narrowing except: to except ImportError: also stops unrelated failures
from being reported as a missing package.
Happy to send a PR if that would help.
- Lingua principale
- Python
- Stelle
- 20.4k
- Fork
- 2k
- Merge medio
- 4h 55m
- PR unite (30g)
- 169
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di modelscope/FunASR
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
modelscope/FunASR#3704 · 1 commento ·
-
bug needs feedback
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
modelscope/FunASR#3401 · 2 commenti ·
-
funasr-nano在电话录音识别场景表现不是很好 Apertaneeds triage question
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
modelscope/FunASR#3718 · 3 commenti ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 48/100
modelscope/FunASR#3717 · 1 commento ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
modelscope/FunASR#3715 ·
Tutte le issue di modelscope/FunASR
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
use-agent-os/agent-os#3314 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
BasedHardware/omi#15662 · 1 commento ·
-
documentation help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
AiursoftWeb/AnduinOS-2#19 ·