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

JSON Chain Audio Pair (Soze)

Audio inside your JSON — MP3-shaped values in the chain

By SozeInc·Created 2 years ago·Updated 8 days ago· 10
JSON Chain Audio Pair (Soze)
  • audio
  • chain_in
  • chain_out
name
modedata_uri
save_path
append_suffixtrue

Text-to-speech and audio-model APIs are increasingly common in ComfyUI workflows, and those requests often want an audio sample embedded in the JSON body. JSON Chain Audio Pair (Soze) is the family's audio-aware pair node: it takes a ComfyUI AUDIO value, encodes it as MP3, and adds the result to your JSON chain under the name you choose. Same shape as the Image Pair, different media.

If you've built any payload with the Soze JSON family, this needs no introduction - wire an AUDIO in, pick a mode, done. It uses the first frame of the audio batch (the audio family's array variant handles the rest). Because it's MP3, the strings stay a lot more compact than raw WAV would be, which makes the data_uri mode actually practical for API bodies.

How it works

ComfyUI's AUDIO type is a dict - {"waveform": tensor[B,C,S], "sample_rate": int} - and the node encodes the first frame to MP3 via torchaudio.save, then hands you either a base64 data URI or a file path:

  • data_uri (default) - data:audio/mpeg;base64,.... Self-contained, and MP3 compression keeps it reasonable.
  • filepath - writes an .mp3 to disk (relative to ComfyUI's output dir, or an absolute path) and emits the path. .mp3 is appended if you omit the extension; append_suffix (default true) adds _00001 when the target exists.

The encoding dependency is worth knowing: MP3 encoding goes through torchaudio, which needs its ffmpeg backend. ComfyUI normally ships that, but if you're on a bare environment it's the one thing that can bite you.

Inputs and outputs

  • name - required string widget, the JSON key.
  • audio - required AUDIO input (forced). First frame of the batch.
  • mode - data_uri or filepath.
  • save_path, append_suffix - optional filepath-mode controls.
  • chain_in - optional JSON_PAIRS.

Output: chain_out. Example:

Audio Pair("voice_sample", audio, mode=data_uri) → JSON Generate

{"voice_sample":"data:audio/mpeg;base64,...."}.

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. The pack's requirements include torchaudio.

Gotchas

The ffmpeg backend is the real failure point. If encoding throws something about not being able to encode MP3, the fix is making sure torchaudio can find ffmpeg - torchaudio>=2.1 plus a system ffmpeg usually sorts it. And note the encoder always emits MP3 (no WAV option), while the decoder is more permissive - it'll read whatever torchaudio.load handles. If your downstream API needs a different format, encode here and convert at the edge.

CategorySoze Nodes/JSON

Inputs (6)

NameTypeDefaultDescription
nameSTRING
audioAUDIO
modeCOMBOdata_uri2 options: data_uri, filepath
save_pathoptSTRINGfilepath mode: target path (relative to ComfyUI output dir, or absolute). `.mp3` is added if missing.
append_suffixoptBOOLEANtruefilepath mode: append _00001 if the target already exists.
chain_inoptJSON_PAIRS

Outputs (1)

NameTypeDescription
chain_outJSON_PAIRS