{"record":{"id":"e73b8a8ebc62cbdb","repo":"Lightning-AI/pytorch-lightning","slug":"expected-a-list-as-audios-found-type-audios","errorCode":null,"errorMessage":"Expected a list as \"audios\", found {type(audios)}","messagePattern":"Expected a list as \"audios\", found (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"src/lightning/pytorch/loggers/wandb.py","lineNumber":518,"sourceCode":"\n        metrics = {key: [wandb.Image(img, **kwarg) for img, kwarg in zip(images, kwarg_list)]}\n        self.log_metrics(metrics, step)  # type: ignore[arg-type]\n\n    @rank_zero_only\n    def log_audio(self, key: str, audios: list[Any], step: Optional[int] = None, **kwargs: Any) -> None:\n        r\"\"\"Log audios (numpy arrays, or file paths).\n\n        Args:\n            key: The key to be used for logging the audio files\n            audios: The list of audio file paths, or numpy arrays to be logged\n            step: The step number to be used for logging the audio files\n            \\**kwargs: Optional kwargs are lists passed to each ``Wandb.Audio`` instance (ex: caption, sample_rate).\n\n        Optional kwargs are lists passed to each audio (ex: caption, sample_rate).\n\n        \"\"\"\n        if not isinstance(audios, list):\n            raise TypeError(f'Expected a list as \"audios\", found {type(audios)}')\n        n = len(audios)\n        for k, v in kwargs.items():\n            if len(v) != n:\n                raise ValueError(f\"Expected {n} items but only found {len(v)} for {k}\")\n        kwarg_list = [{k: kwargs[k][i] for k in kwargs} for i in range(n)]\n\n        import wandb\n\n        metrics = {key: [wandb.Audio(audio, **kwarg) for audio, kwarg in zip(audios, kwarg_list)]}\n        self.log_metrics(metrics, step)  # type: ignore[arg-type]\n\n    @rank_zero_only\n    def log_video(self, key: str, videos: list[Any], step: Optional[int] = None, **kwargs: Any) -> None:\n        \"\"\"Log videos (numpy arrays, or file paths).\n\n        Args:\n            key: The key to be used for logging the video files\n            videos: The list of video file paths, or numpy arrays to be logged","sourceCodeStart":500,"sourceCodeEnd":536,"githubUrl":"https://github.com/Lightning-AI/pytorch-lightning/blob/9fed5c27d2a62ff0efd6c3573599921d6ff67c14/src/lightning/pytorch/loggers/wandb.py#L500-L536","documentation":"WandbLogger.log_audio requires audios to be a Python list (of file paths or data) so each entry can be wrapped into wandb.Audio with per-item kwargs. Passing a tensor, numpy array, or other non-list raises TypeError.","triggerScenarios":"logger.log_audio(numpy_waveform_array, sample_rate=...) or passing a torch tensor of shape (N, samples) directly.","commonSituations":"Feeding a batched audio tensor straight from the training loop instead of splitting into a list of per-sample waveforms.","solutions":["Convert to a list: list(array) / [wav for wav in tensor.cpu().numpy()]","Pass file paths as a list of strings"],"exampleFix":"# before\nlogger.log_audio(batch_wav_tensor, sample_rate=[16000])\n# after\nlogger.log_audio(list(batch_wav_tensor), sample_rate=[16000] * len(batch_wav_tensor))","handlingStrategy":"type-guard","validationCode":"audios = list(audios) if not isinstance(audios, list) else audios","typeGuard":"def is_audio_list(x) -> bool:\n    return isinstance(x, list)","tryCatchPattern":null,"preventionTips":["Wrap single audios in [audio]","Convert waveform arrays to per-clip lists at the logging call site"],"tags":["wandb","lightning","logging","audio","type-error"],"backgroundTag":"invalid-input-type","analyzedSha":"9fed5c27d2a62ff0efd6c3573599921d6ff67c14","analyzedAt":"2026-08-28T11:52:41.083Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}