Nodes/TKNodes/Get a Track details from Track
ComfyUI Node

Get a Track details from Track

A two-way switch that swaps prompt and start image per speaker

By trashkollector·Created about a year ago·Updated a day ago· 1
Get a Track details from Track
  • image1
  • image2
  • selectedImage
  • selectedText
  • currentIndex
trackIndex1
speakerNum
prompt1
prompt2

When you're generating a video of two people talking, you usually want different framing for each speaker. Person A gets a prompt about a red room and a start image of them looking left; person B gets the blue office and a different pose. If the speakers alternate across the video, you need something in the graph that flips those pairs of inputs each time the speaker changes - and that's exactly what TKSpeakerDataFromTrack is.

The author's description is refreshingly honest: "Given the Speaker, select the appropriate PROMPT and START IMAGE. since they alternate we need this." It's a small A/B switch with a specific job - keyed on speaker number, carrying both a text prompt and an image per side.

How it works

Think of it as a two-way router in the shape of a data picker. It takes two prepared prompt+image pairs (speaker 1's and speaker 2's) and one speakerNum. If speakerNum is 1, you get back image1 and prompt1. If it's 2, you get image2 and prompt2. Anything else - including 0, which some extractors output - falls back to speaker 1's pair rather than erroring. Whatever you feed in for trackIndex passes straight through on currentIndex, so the rest of your graph can still tell which track it's working on.

In practice, speakerNum comes from the pack's speaker-extraction pipeline, which diarizes the audio (via sherpa-onnx) and hands you per-speaker segments. This node sits in the generation loop: for each track, look up which speaker it belongs to, and pull that speaker's prompt and start image.

The inputs that matter

Five, and they group naturally:

  • speakerNum - which speaker's data to select. This is the wire that drives everything.
  • image1 / prompt1 - speaker 1's start image and prompt.
  • image2 / prompt2 - speaker 2's start image and prompt.
  • trackIndex - bookkeeping, passed through untouched as currentIndex.

The one trap to know about: this node only knows two speakers. It's hardcoded as a 1/2 selector with a fallback to speaker 1. If your audio has three or four distinct speakers, you'll need more than one of these, or a different routing approach. For the classic two-person dialogue video this pack was clearly built around, it's exactly right.

Outputs

Three: selectedImage (IMAGE) and selectedText (STRING) go straight into your conditioning - the start image into the video model's image input, the prompt into your CLIP/text encoder for that segment. currentIndex is the track number riding along so downstream nodes stay in sync.

Install

Part of TKNodes: ComfyUI Manager, search "Handy Nodes", install, restart.

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

One thing that sets this side of the pack apart: the speaker pipeline depends on sherpa-onnx (it's in requirements.txt), and on first use it downloads two ONNX models - a pyannote segmentation model and a Titanet embedding model - into ComfyUI/models/onnx/. Don't panic if the first speaker detection run looks stuck; it's pulling models. FFmpeg on your PATH is required for the audio-file side of things. The node itself, though, is just data selection - no models, no downloads, and it works the moment the pack is installed.

CategoryTKNodes

Inputs (6)

NameTypeDefaultDescription
trackIndexINT11–100
speakerNumINT
image1IMAGE
prompt1STRING
image2IMAGE
prompt2STRING

Outputs (3)

NameTypeDescription
selectedImageIMAGE
selectedTextSTRING
currentIndexINT