{"record":{"id":"3a8750a03ac78403","repo":"Comfy-Org/ComfyUI","slug":"error-audio-encoder-file-is-invalid-and-does-not","errorCode":null,"errorMessage":"ERROR: audio encoder file is invalid and does not contain a valid model.","messagePattern":"ERROR: audio encoder file is invalid and does not contain a valid model\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"comfy_extras/nodes_audio_encoder.py","lineNumber":30,"sourceCode":"            node_id=\"AudioEncoderLoader\",\n            display_name=\"Load Audio Encoder\",\n            category=\"model/loaders\",\n            inputs=[\n                io.Combo.Input(\n                    \"audio_encoder_name\",\n                    options=folder_paths.get_filename_list(\"audio_encoders\"),\n                ),\n            ],\n            outputs=[io.AudioEncoder.Output()],\n        )\n\n    @classmethod\n    def execute(cls, audio_encoder_name) -> io.NodeOutput:\n        audio_encoder_name = folder_paths.get_full_path_or_raise(\"audio_encoders\", audio_encoder_name)\n        sd = comfy.utils.load_torch_file(audio_encoder_name, safe_load=True)\n        audio_encoder = comfy.audio_encoders.audio_encoders.load_audio_encoder_from_sd(sd)\n        if audio_encoder is None:\n            raise RuntimeError(\"ERROR: audio encoder file is invalid and does not contain a valid model.\")\n        return io.NodeOutput(audio_encoder)\n\n\nclass AudioEncoderEncode(io.ComfyNode):\n    @classmethod\n    def define_schema(cls) -> io.Schema:\n        return io.Schema(\n            node_id=\"AudioEncoderEncode\",\n            category=\"model/conditioning\",\n            inputs=[\n                io.AudioEncoder.Input(\"audio_encoder\"),\n                io.Audio.Input(\"audio\"),\n            ],\n            outputs=[io.AudioEncoderOutput.Output()],\n        )\n\n    @classmethod\n    def execute(cls, audio_encoder, audio) -> io.NodeOutput:","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy_extras/nodes_audio_encoder.py#L12-L48","documentation":"LoadAudioEncoder loads a torch file from the audio_encoders folder and hands its state dict to load_audio_encoder_from_sd; when no known key signature matches, the factory returns None and this RuntimeError reports that the file is not a recognized audio encoder model.","triggerScenarios":"Placing an arbitrary .pt/.safetensors (e.g. a VAE, checkpoint, or corrupt file) in models/audio_encoders and selecting it; a partially downloaded encoder; an encoder saved in a format/key-layout the loader does not recognize (version skew).","commonSituations":"Wrong file dropped into the audio_encoders directory; updating ComfyUI while keeping an old-format encoder file; filename collisions where the wrong model is picked.","solutions":["Verify the file is the intended audio encoder model from a supported source and re-download if corrupt","Inspect the state dict keys (torch.load / safetensors) and compare against the key signatures load_audio_encoder_from_sd expects","Ensure ComfyUI and the encoder file versions match — update one or the other","Remove misplaced files from models/audio_encoders so the combo lists only valid encoders"],"exampleFix":"// before\n# models/audio_encoders/ contains 'some_vae.safetensors' -> selected -> raises\n\n// after\n# keep only genuine encoder files, e.g.:\n# models/audio_encoders/encodec_v1_5hz.safetensors\nsd = comfy.utils.load_torch_file(path, safe_load=True)\nprint(list(sd)[:10])  # confirm keys look like an audio encoder","handlingStrategy":"validation","validationCode":"sd = comfy.utils.load_torch_file(path, safe_load=True)\nfrom comfy.audio_encoders.audio_encoders import load_audio_encoder_from_sd\nif load_audio_encoder_from_sd(sd) is None:\n    print('not a valid audio encoder:', list(sd)[:8])  # diagnose keys","typeGuard":null,"tryCatchPattern":"try:\n    enc = LoadAudioEncoder.execute(name)\nexcept RuntimeError as e:\n    if 'invalid and does not contain a valid model' in str(e):\n        remove_or_replace_file(name)  # re-download correct encoder\n    else:\n        raise","preventionTips":["Keep only genuine encoder files in models/audio_encoders","Verify downloaded file size/hash against the publisher","Match ComfyUI and encoder file versions when updating"],"tags":["model-loading","audio-encoder","state-dict"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}