Comfy-Org/ComfyUI · error · RuntimeError
ERROR: audio encoder file is invalid and does not contain a
Error message
ERROR: audio encoder file is invalid and does not contain a valid model.
What it means
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.
Source
Thrown at comfy_extras/nodes_audio_encoder.py:30
node_id="AudioEncoderLoader",
display_name="Load Audio Encoder",
category="model/loaders",
inputs=[
io.Combo.Input(
"audio_encoder_name",
options=folder_paths.get_filename_list("audio_encoders"),
),
],
outputs=[io.AudioEncoder.Output()],
)
@classmethod
def execute(cls, audio_encoder_name) -> io.NodeOutput:
audio_encoder_name = folder_paths.get_full_path_or_raise("audio_encoders", audio_encoder_name)
sd = comfy.utils.load_torch_file(audio_encoder_name, safe_load=True)
audio_encoder = comfy.audio_encoders.audio_encoders.load_audio_encoder_from_sd(sd)
if audio_encoder is None:
raise RuntimeError("ERROR: audio encoder file is invalid and does not contain a valid model.")
return io.NodeOutput(audio_encoder)
class AudioEncoderEncode(io.ComfyNode):
@classmethod
def define_schema(cls) -> io.Schema:
return io.Schema(
node_id="AudioEncoderEncode",
category="model/conditioning",
inputs=[
io.AudioEncoder.Input("audio_encoder"),
io.Audio.Input("audio"),
],
outputs=[io.AudioEncoderOutput.Output()],
)
@classmethod
def execute(cls, audio_encoder, audio) -> io.NodeOutput:View on GitHub (pinned to 1c6d8d45b3)
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
Example fix
// before # models/audio_encoders/ contains 'some_vae.safetensors' -> selected -> raises // after # keep only genuine encoder files, e.g.: # models/audio_encoders/encodec_v1_5hz.safetensors sd = comfy.utils.load_torch_file(path, safe_load=True) print(list(sd)[:10]) # confirm keys look like an audio encoder
Defensive patterns
Strategy: validation
Validate before calling
sd = comfy.utils.load_torch_file(path, safe_load=True)
from comfy.audio_encoders.audio_encoders import load_audio_encoder_from_sd
if load_audio_encoder_from_sd(sd) is None:
print('not a valid audio encoder:', list(sd)[:8]) # diagnose keys Try / catch
try:
enc = LoadAudioEncoder.execute(name)
except RuntimeError as e:
if 'invalid and does not contain a valid model' in str(e):
remove_or_replace_file(name) # re-download correct encoder
else:
raise Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- Unrecognized optical flow model format: expected a torchvisi
- INVALID_TAG_FILTER
- ERROR: audio encoder file is invalid or unsupported embed_di
- ERROR: audio encoder not supported.
- Control type {max_type_name}({max_type}) is out of range for
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/3a8750a03ac78403.
Report an issue: GitHub.