Skip to content

Speech2TextStreaming._load_model fails to detect non-standard ESPnet checkpoints (e.g. 3epoch.pth) in Speechcatcher models #19

Description

@MihailMiller

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

  1. Download and use Speechcatcher ESPnet models, e.g.: en_streaming_transformer_m, en_streaming_transformer_l

  2. 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
    
  3. Instantiate Speech2TextStreaming pointing to these models and let _load_model run.

  4. 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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions