Nodes/TKNodes/Audio → Waveform Tensor
ComfyUI Node

Audio → Waveform Tensor

How to get raw samples out of ComfyUI's AUDIO type

By trashkollector·Created about a year ago·Updated a day ago· 1
Audio → Waveform Tensor
  • audio
  • waveform

In ComfyUI, AUDIO isn't a tensor you can poke at - it's a dictionary: a waveform tensor plus a sample_rate, wrapped up so that audio-specific nodes can hand it around as one unit. Which is great until you want to actually do math on the samples, or feed them to a node that expects a raw tensor. Audio → Waveform Tensor is the tiny adapter that unwraps the box.

One AUDIO in, one waveform out. The output is typed * (any), which is the giveaway for its real purpose: it's a breakout tool for when you need to bypass the type system and pass the raw [channels, samples] tensor somewhere the standard sockets won't let it go.

How it works

This is about as simple as a node gets. The source literally returns audio["waveform"] - the dictionary key stripped out, the tensor handed over. There's no resampling, no normalization, no conversion. What you get is whatever sample representation the audio came in with, and the sample rate is not passed along, so if you care about what frequency those samples live at you need to remember it yourself.

When you'd reach for it

Two honest use cases:

  • You're doing custom audio processing. Want to visualize a waveform, apply your own gain curve, splice samples with a math node, or drive a modulation from audio amplitude? Raw tensors are what those nodes speak, and this is how you get from AUDIO to raw.
  • You're bridging to a node that doesn't declare an AUDIO input. Plenty of math/utility nodes accept * and will take whatever you feed them - but they can't see inside the dictionary, so they need you to unwrap first. The README frames it the same way: after working with audio segments (the split-up chunks from the chunkers), this is how you consolidate back to one waveform tensor.

The reverse direction - wrapping a raw tensor back into the AUDIO dict - isn't this node's job, so keep that in mind before you build a pipeline expecting round-tripping.

Installing it

Part of the trashkollector/TKNodes pack ("ComfyUI Handy Nodes"). Install via ComfyUI Manager (search "Handy Nodes") or:

cd ComfyUI/custom_nodes
git clone https://github.com/trashkollector/TKNodes

Restart, and it shows up under the audio category. No special dependencies for this node itself, though if you're using it inside the pack's speaker/chunking workflows you'll want the usual pydub + FFmpeg-on-PATH stack that those pull in.

Common issues

The thing people trip on isn't a crash - it's that the output is not in image format. A waveform tensor is [channels, samples], nothing like the [N, H, W, C] image tensors you're used to, so feeding it straight into an image preview or a video node will fail or render nonsense. If that happens, the fix is to make your downstream node actually expect raw audio samples, not to fight the connection. And don't expect a sample rate to travel with it - if a downstream node needs to know the rate, carry it through a separate INT/FLOAT wire from wherever the audio originated.

Categoryaudio

Inputs (1)

NameTypeDefaultDescription
audioAUDIO

Outputs (1)

NameTypeDescription
waveform*