The _load_model method in the Speech2TextStreaming class (speech2text_streaming.py) only searches for a fixed set of checkpoint filenames and locations:
# Try different possible checkpoint locations
search_paths = [
self.model_dir / "valid.acc.best.pth",
self.model_dir / "valid.acc.ave_6best.pth",
self.model_dir / "valid.acc.ave.pth",
self.model_dir / "model.pth",
self.model_dir / "checkpoint.pth",
]
# Also search in exp/ subdirectories (ESPnet model structure)
exp_dirs = list(self.model_dir.glob("exp/*/"))
for exp_dir in exp_dirs:
search_paths.extend([
exp_dir / "valid.acc.best.pth",
exp_dir / "valid.acc.ave_6best.pth",
exp_dir / "valid.acc.ave.pth",
exp_dir / "model.pth",
exp_dir / "checkpoint.pth",
])
However, some Speechcatcher ESPnet models are downloaded with checkpoint filenames like 3epoch.pth or 2epoch.pth instead of these expected names. As a result, _load_model fails to find any checkpoint, even though a valid *.pth file exists in the exp/* directory.
To Reproduce
-
Download and use Speechcatcher ESPnet models, e.g.: en_streaming_transformer_m, en_streaming_transformer_l
-
Inspect cache directory (example):
/root/.cache/espnet/models--speechcatcher--wordcab_speechcatcher_english_espnet_streaming_transformer_35k_train_size_l_raw_en_bpe1024/snapshots/ced8af46e25434d1229dde3eb3ff8cfb2e4d1b84/exp/asr_train_asr_streaming_transformer_size_l_raw_en_bpe1024/3epoch.pth
/root/.cache/espnet/models--speechcatcher--wordcab_speechcatcher_english_espnet_streaming_transformer_35k_train_size_m_raw_en_bpe1024/snapshots/c77f02d1bc3dd924912373336ab3434fd6431060/exp/asr_train_asr_streaming_transformer_size_m_raw_en_bpe1024/2epoch.pth
-
Instantiate Speech2TextStreaming pointing to these models and let _load_model run.
-
The loader does not find any matching checkpoint path, because it only checks for the hard-coded filenames.
Expected behavior
Speech2TextStreaming._load_model should be able to discover and load ESPnet checkpoints even when the checkpoint filenames are not one of the hard-coded names (valid.acc.best.pth, valid.acc.ave_6best.pth, valid.acc.ave.pth, model.pth, checkpoint.pth).
In other words, as long as there is a *.pth file in the relevant exp/* directory, the loader should find and use it (or at least provide a reasonable fallback).
Actual behavior
For Speechcatcher models where the checkpoint is named 3epoch.pth, 2epoch.pth, or similar, _load_model does not recognize the path and fails to load any checkpoint, despite a valid *.pth file being present in the exp/* directory.
Workaround / Proposed fix
As a workaround, I currently normalize all downloaded Speechcatcher models by renaming whatever *.pth exists in the exp/* directory to model.pth, so that the current _load_model logic can find it. Without this manual step, the model loading fails.
Suggestion: Instead of requiring callers to run such a workaround, it might be more robust if _load_model:
- After checking the known filenames, falls back to:
- Listing all
*.pth files in self.model_dir and exp/* directories.
- Selecting one deterministically (e.g. by preferred patterns or alphabetical order).
The
_load_modelmethod in theSpeech2TextStreamingclass (speech2text_streaming.py) only searches for a fixed set of checkpoint filenames and locations:However, some Speechcatcher ESPnet models are downloaded with checkpoint filenames like
3epoch.pthor2epoch.pthinstead of these expected names. As a result,_load_modelfails to find any checkpoint, even though a valid*.pthfile exists in theexp/*directory.To Reproduce
Download and use Speechcatcher ESPnet models, e.g.:
en_streaming_transformer_m,en_streaming_transformer_lInspect cache directory (example):
Instantiate
Speech2TextStreamingpointing to these models and let_load_modelrun.The loader does not find any matching checkpoint path, because it only checks for the hard-coded filenames.
Expected behavior
Speech2TextStreaming._load_modelshould be able to discover and load ESPnet checkpoints even when the checkpoint filenames are not one of the hard-coded names (valid.acc.best.pth,valid.acc.ave_6best.pth,valid.acc.ave.pth,model.pth,checkpoint.pth).In other words, as long as there is a
*.pthfile in the relevantexp/*directory, the loader should find and use it (or at least provide a reasonable fallback).Actual behavior
For Speechcatcher models where the checkpoint is named
3epoch.pth,2epoch.pth, or similar,_load_modeldoes not recognize the path and fails to load any checkpoint, despite a valid*.pthfile being present in theexp/*directory.Workaround / Proposed fix
As a workaround, I currently normalize all downloaded Speechcatcher models by renaming whatever
*.pthexists in theexp/*directory tomodel.pth, so that the current_load_modellogic can find it. Without this manual step, the model loading fails.Suggestion: Instead of requiring callers to run such a workaround, it might be more robust if
_load_model:*.pthfiles inself.model_dirandexp/*directories.