Nodes/Boyonodes/Boyo Audio Duration Analyzer
ComfyUI Node

Boyo Audio Duration Analyzer

How long is that audio, exactly? The node that answers before you build around it

By DragonDiffusionbyBoyo·Created 2 years ago·Updated 27 days ago· 16
Boyo Audio Duration Analyzer
  • audio
  • duration_seconds
  • info_text

The entire problem this node solves is "I have an audio tensor and I need to know its duration in seconds, right now, as a number I can feed into other nodes." That's it. It takes any ComfyUI AUDIO tensor, works out how many seconds of audio it holds, and hands you the number. Sounds trivial. It's not, because ComfyUI's audio format is a moving target - tensors arrive shaped (batch, channels, samples) or (batch, samples, channels) or as plain (channels, samples), with sample rates that the author has to guess at when the metadata is missing.

Why you'd actually want it

Duration is the thing every audio-sync workflow needs and nobody wants to compute by hand. Your lip-sync pipeline generates speech, your video model renders a clip, and the two have to line up. This node gives you the number that everything else keys off: feed it to Boyo Audio Padder's target_duration, or drive a frame-count calculation for the video side. It's a measurement node, not an effect - it sits in the graph, reports, and leaves the audio untouched.

How it works

The source is defensive by design. It unpacks whatever audio format it's handed - the standard ComfyUI dict with a waveform key and sample_rate, a (waveform, sample_rate) tuple, or a bare tensor (where it assumes a default 22050 Hz and hopes for the best). It then sniffs the tensor's shape to figure out which dimension is samples versus channels - the (batch, samples, channels) vs (batch, channels, samples) ambiguity is the classic trap here - and computes:

duration_seconds = num_samples / sample_rate

It also builds a human-readable summary string with the sample count, rate, and channel count, so you can eyeball the result in the node output without wiring up a text display.

Inputs and outputs

One required input: audio (AUDIO). Two outputs:

  • duration_seconds (FLOAT) - wire this into anything that needs a number: padding targets, video length, frame counts.
  • info_text (STRING) - the readable summary, handy for debugging or a text-preview node.

Installation

No dependencies beyond the pack itself:

cd ComfyUI/custom_nodes && git clone https://github.com/DragonDiffusionbyBoyo/Boyonodes

restart, and you'll find it under Boyo/Audio/Analysis. (Like the rest of the pack, ComfyUI Manager works too - search "Boyonodes".)

Where it gets you

The workflow the author clearly has in mind is the TTS lip-sync chain: Chatterbox generates speech → this node measures it → Boyo Audio Padder pads it to the video length → save. If you're doing anything where generated audio has to match generated video, this is the glue node that makes the numbers real. The one caveat: if you hand it a bare tensor without sample-rate metadata it defaults to 22050 Hz, which will be wrong if your audio is actually 44.1k or 48k. Most ComfyUI audio sources carry the rate in the dict, so in practice you rarely hit it - but now you know where the failure would come from.

CategoryBoyo/Audio/Analysis

Inputs (1)

NameTypeDefaultDescription
audioAUDIO

Outputs (2)

NameTypeDescription
duration_secondsFLOAT
info_textSTRING