fishaudio/fish-speech · error · ValueError

{i} is not a file or directory

Error message

{i} is not a file or directory

What it means

SemanticDataset.init_mock_data_server expands each entry of proto_files (or the equivalent list) into .proto/.protos files: files are kept, directories are recursively globbed. If an entry is neither an existing file nor an existing directory (typo, missing mount, or empty/None path coerced to a nonexistent path), a ValueError is raised.

Source

Thrown at fish_speech/datasets/semantic.py:133

        while True:
            yield self.augment()

    def init_mock_data_server(self):
        if self.groups is not None:
            return

        # Expand the proto files
        expanded_proto_files = []
        for filename in self.proto_files:
            for i in braceexpand(filename):
                i = Path(i)
                if i.is_file():
                    expanded_proto_files.append(i)
                elif i.is_dir():
                    expanded_proto_files.extend(i.rglob("*.proto"))
                    expanded_proto_files.extend(i.rglob("*.protos"))
                else:
                    raise ValueError(f"{i} is not a file or directory")

        expanded_proto_files = sorted(expanded_proto_files)
        Random(self.seed).shuffle(expanded_proto_files)

        self.groups = []
        shard_proto_files = split_by_rank_worker(expanded_proto_files)
        log.info(
            f"Reading {len(shard_proto_files)} / {len(expanded_proto_files)} files"
        )

        count = 0
        for filename in shard_proto_files:
            with open(filename, "rb") as f:
                for text_data in read_pb_stream(f):
                    self.groups.append(text_data)
                    count += 1

        log.info(f"Read total {count} groups of data")

View on GitHub (pinned to befe400174)

Solutions

  1. Verify the path exists: `ls <path>` from the same working directory you launch training
  2. Use absolute paths in the dataset config
  3. Re-download or mount the dataset; create parent dirs if generating .protos files yourself
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path
paths = [Path(p) for p in proto_files]
missing = [p for p in paths if not p.exists()]
assert not missing, f"missing proto paths: {missing}"

Try / catch

try:
    dataset.init_mock_data_server()
except ValueError as e:
    if "is not a file or directory" in str(e):
        # fix paths and retry
        ...
    raise

Prevention

When it happens

Trigger: Calling init_mock_data_server (or sample_data which calls it) with a path string that doesn't exist on disk, e.g. "data/train.protos" when the file was never downloaded or the container path differs.

Common situations: Wrong data_root/protos path in training config YAML, datasets not downloaded/mounted in Docker, running from a different working directory so relative paths don't resolve.

Related errors


AI-assisted analysis of fishaudio/fish-speech@befe400174 (2026-08-27). Data as JSON: /api/errors/d2e2d563ea3eaccf. Report an issue: GitHub.