From ComfyUI to any Cog: open audio workflows that scale to zero
How template:name connects ComfyUI to reusable Cog deployments, when to choose open Pocket TTS versus fal audio, and how the shared serverless/pod router returns idle workers to zero.
Listen to this article
On-device voiceUses the voice built into your browser; no article text leaves this page.
Audio narration is not supported by this browser.
An audio workflow should describe what to run, not require somebody to copy a temporary pod URL into a node. We have connected ComfyUI to app.nz's Cog control plane so a graph can name an open recipe such as pocket-tts, submit work, and let the worker disappear when it is no longer useful.
The runnable graph is Autoscaling Open TTS Cog. Download its exact ComfyUI API JSON or inspect the workflow contract.
The first principle: deployment and execution are different state
A model deployment is durable configuration: image digest, schema, hardware, minimum VRAM, and idle policy. A worker is temporary compute. Combining those ideas leads to a simple lifecycle:
template:pocket-tts
│
▼
ensure one deployment
(reuse it when it already exists)
│
▼
queue prediction
low traffic → serverless
sustained traffic → warm pod
│
▼
return AUDIO to Comfy
idle window expires → zero workersRepeated graph runs do not create repeated models. POST /api/cogs/run uses a single atomic ensure operation keyed by account, deployment name, image, and hardware. It returns the model id, prediction id, polling URL, explicit sleep URL, idle window, and scaleToZero: true.
Run the graph
Install the MIT app.nz Comfy nodes, set APPNZ_API_KEY in the worker environment, import the downloaded workflow, and change the text or voice. The AppNZCogAudio node does four visible jobs:
- asks the control plane to ensure the named template;
- queues a normal Cog prediction;
- polls the public prediction state until it reaches a terminal result;
- converts the returned URL or audio data URI into a normal Comfy
AUDIOvalue.
The generic AppNZAnyCog node accepts the same template:name reference for image, video, 3D, JSON, and custom models. An existing model id still works, so the shortcut does not hide the lower-level hosting API.
The same lifecycle without ComfyUI
# Ensure pocket-tts, run it, wait for the result, then let the 60s idle policy reap it.
app cogs run pocket-tts \
--input '{"text":"Kia ora from a worker that scales to zero","voice":"alba","format":"wav"}'
# Or use the API directly.
curl -sX POST https://app.nz/api/cogs/run \
-H "Authorization: Bearer $APP_API_KEY" \
-H 'Content-Type: application/json' \
-d '{"template":"pocket-tts","input":{"text":"hello","voice":"alba","format":"wav"}}'MCP clients use run_cog_template, then get_cog_prediction. The Go desktop bridge exposes /api/desktop/cogs/run, and its built-in MCP server offers cog_template_run. All of them hit the same queue and lifecycle records.
Cog audio or fal audio?
These paths solve different problems:
| Need | Best first path | Why |
|---|---|---|
| Narration, local voices, inspectable serving | Pocket TTS Cog | Small 100M model, MIT serving code, CC-BY-4.0 weights, CPU-friendly, voice cloning, deployment under your control |
| First-party higher-quality speech | appnz-tts Cog | Fish Speech adapter with reusable model cache and serverless/pod promotion |
| Foley, impacts, UI sounds | elevenlabs-sound-effects through fal | Purpose-built prompt-to-SFX endpoint; no model deployment to maintain |
| Beds, loops, long musical texture | stable-audio-25 through fal | Text-to-audio model with duration, steps, guidance, and seed controls |
| Audio-reactive graphics | Local Comfy node | Waveform/FFT work is deterministic CPU math and needs no inference service |
Both fal audio models are now explicit entries in the app.nz model catalogue, so /v1/audio/generations and the AppNZSoundFX node resolve the same IDs. The fal route remains hosted by fal; app.nz does not falsely claim to control its worker lifecycle. Cog routes use app.nz's own serverless/pod scheduler and idle reaper.
Open-source boundaries and licenses
- Pocket TTS has MIT code and is
designed for low-latency CPU execution. Its model weights are CC-BY-4.0, individual bundled voices can carry separate attribution requirements, and cloning requires explicit authorization from the speaker.
- The pocket-tts Cog adapter and
app.nz Comfy nodes are open adapters around that runtime.
- stable-audio-tools is MIT,
but model weights have their own terms. Open code does not automatically make every checkpoint an OSI-licensed model.
app.nz speaks that contract directly; a compliant image does not need a proprietary wrapper.
What actually scales to zero
"Scale to zero" should be observable, not decorative copy. A run returns the chosen tier and prediction state. A low-rate serverless-enabled template can run without a dedicated pod. Sustained demand promotes to a warm pod through the shared Cog/Comfy GPU router. After the model's idle window, the reaper verifies there are no active predictions, terminates the provider machine, and clears the endpoint. Calling the returned sleep URL performs the same teardown immediately.
This boundary also keeps Comfy graphs portable: the workflow stores template:pocket-tts, never a provider pod id or secret. Credentials remain in the worker environment, media moves as HTTPS URLs or data URIs, and the graph can be reviewed without gaining infrastructure access.
Extend it to any Cog
For a custom model, publish a container that serves /health-check, /openapi.json, and /predictions on port 5000. Register it once with POST /api/cogs or the deploy badge, then use its returned model id in AppNZAnyCog. To make it a one-word ensure-and-run recipe, contribute the image, schema, source repository, upstream project, licenses, minimum VRAM, and idle policy to the public Cog template catalogue.
The governing rule is small but useful: keep the recipe durable, keep compute temporary, and keep every license and lifecycle transition inspectable.