{"record":{"id":"4403eb68004dcc1e","repo":"huggingface/transformers","slug":"only-a-single-or-a-list-of-entries-is-supported-bu","errorCode":null,"errorMessage":"only a single or a list of entries is supported but got type={type(audio_url_or_urls)}","messagePattern":"only a single or a list of entries is supported but got type=(.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"src/transformers/feature_extraction_sequence_utils.py","lineNumber":387,"sourceCode":"        return padding_strategy\n\n    def fetch_audio(self, audio_url_or_urls: str | list[str] | list[list[str]], sampling_rate: int | None = None):\n        \"\"\"\n        Convert a single or a list of urls into the corresponding `np.ndarray` objects.\n\n        If a single url is passed, the return value will be a single object. If a list is passed a list of objects is\n        returned.\n        \"\"\"\n        # Accepted input types for `raw_audio`: \"np.ndarray | list[float] | list[np.ndarray] | list[list[float]]\"\n        sampling_rate = sampling_rate if sampling_rate else self.sampling_rate\n        if isinstance(audio_url_or_urls, list) and not isinstance(audio_url_or_urls[0], float):\n            return [self.fetch_audio(x, sampling_rate=sampling_rate) for x in audio_url_or_urls]\n        elif isinstance(audio_url_or_urls, str):\n            return load_audio(audio_url_or_urls, sampling_rate=sampling_rate)\n        elif is_valid_audio(audio_url_or_urls):\n            return audio_url_or_urls\n        else:\n            raise TypeError(f\"only a single or a list of entries is supported but got type={type(audio_url_or_urls)}\")\n","sourceCodeStart":369,"sourceCodeEnd":388,"githubUrl":"https://github.com/huggingface/transformers/blob/a597f974857b3d92939971296bc0deb93d33d780/src/transformers/feature_extraction_sequence_utils.py#L369-L388","documentation":"fetch_audio accepts a single URL string, a list of URLs, or already-valid raw audio (ndarray/list-of-float per is_valid_audio). Anything else — an int, dict, None, bytes — has no defined fetch behavior and raises TypeError with the offending type.","triggerScenarios":"Calling fetch_audio with e.g. an int index, a Path object, bytes, or a nested list of lists of floats in an unexpected shape; also lists whose first element is float are treated as raw audio and then fail validity for outer types.","commonSituations":"Passing Path objects instead of str URLs; data pipelines that sometimes hand over None; assuming local file paths or file-likes are supported when only URL strings and raw arrays are.","solutions":["Convert Path to str: fetch_audio(str(path_or_url))","Pass raw audio as np.ndarray (float) or list of floats instead of odd containers","Filter None/invalid entries before calling fetch_audio"],"exampleFix":"# before\nfe.fetch_audio(Path(\"/tmp/a.wav\"))\n\n# after\nfe.fetch_audio(str(Path(\"/tmp/a.wav\").resolve()))","handlingStrategy":"type-guard","validationCode":"from pathlib import Path\n\ndef normalize_audio_arg(x):\n    return str(x) if isinstance(x, Path) else x","typeGuard":"def is_fetchable_audio(x) -> bool:\n    import numpy as np\n    return isinstance(x, str) or (isinstance(x, list) and all(isinstance(i, str) for i in x)) or \\\n           isinstance(x, np.ndarray)","tryCatchPattern":"try:\n    fe.fetch_audio(src)\nexcept TypeError as e:\n    if \"only a single or a list\" in str(e):\n        raise TypeError(f\"unsupported audio source {type(src)}; pass str URL or np.ndarray\") from e\n    raise","preventionTips":["Convert Path objects to str at the boundary","Validate inputs against str | list[str] | ndarray before fetching","Drop None candidates before calling fetch_audio"],"tags":["feature-extractor","audio","type-error","transformers"],"backgroundTag":null,"analyzedSha":"a597f974857b3d92939971296bc0deb93d33d780","analyzedAt":"2026-08-14T18:24:08.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}