Nodes/Quality of Life Nodes for ComfyUI/JSON Audio Decoder (Soze)
ComfyUI Node

JSON Audio Decoder (Soze)

Strings back to audio — the permissive decoder

By SozeInc·Created 2 years ago·Updated 8 days ago· 10
JSON Audio Decoder (Soze)
    • audio
    • count
    • status
    encoded

    The audio half of the Soze JSON family ends here: JSON Audio Decoder (Soze) takes a STRING and hands you back a ComfyUI AUDIO value. It's the inverse of the JSON Audio Encoder, and like the image decoder it's deliberately permissive about what it'll accept - a data URI, a file path, an http(s) URL, a JSON array, or a newline-separated list. Wire in whatever text you have; get audio out.

    Where you'll actually use it: after pulling audio strings out of an API response or JSON file and needing them as tensors for preview, playback, or further processing; or as the round-trip endpoint after encoding audio into a payload. It can also stack multiple values into one AUDIO batch, which makes it the natural landing point for the audio array pair's output.

    How it works

    The input is split into values (JSON array or newline split, else a single value). Each is decoded with torchaudio.load - data URIs are base64-decoded first, URLs are fetched via requests, everything else is a file path. It reads whatever torchaudio can, which is broader than the encoder's MP3-only output: WAV, FLAC, OGG, M4A, AAC included. Then the results are aligned into one batch:

    • sample rates are resampled to the first audio's rate
    • frames whose channel count doesn't match the first are skipped (noted in status)
    • shorter waveforms are zero-padded to the longest

    so you end up with one consistent AUDIO dict instead of a shape mismatch.

    Inputs and outputs

    • encoded - required STRING: data URI, file path, URL, JSON array, or newline-separated list.

    Outputs: audio (the AUDIO), count (INT - frames decoded), and status (STRING - OK: decoded 3/3 value(s), 1 frame(s) x 2ch, 5.20s @ 44100Hz, with failure details when some values fail).

    Installing it

    Part of the Soze pack:

    cd ComfyUI/custom_nodes
    git clone https://github.com/SozeInc/ComfyUI_Soze.git
    pip install -r ComfyUI_Soze/requirements.txt
    

    Restart ComfyUI, or search ComfyUI_Soze in ComfyUI Manager. Requires torchaudio (in the pack's requirements).

    Gotchas

    Three things can go wrong, and two are environment-shaped. Missing torchaudio gives you a clear "pip install torchaudio" error. If decoding a URL fails, check that the URL is actually reachable - the fetch has a timeout, and a dead link lands in the status's failure list rather than killing the run. The third is content: mismatched channel counts get dropped (status tells you), so a batch of mono clips plus one stereo clip silently loses the odd one out. If every value fails you get a silent blank audio with an ERROR status - read the status string, it's the only place the details live.

    CategorySoze Nodes/JSON

    Inputs (1)

    NameTypeDefaultDescription
    encodedSTRINGData URI, file path, URL, JSON array, or newline-separated list.

    Outputs (3)

    NameTypeDescription
    audioAUDIO
    countINT
    statusSTRING