KJNodes/audiogenerated
Play Sound KJ(PlaySoundKJ)
Plays the input audio in the browser. Modes: 'always' plays on every execution, 'on_empty_queue' plays only when the queue finishes, 'on_change' plays only when the audio content changes. Duration limits playback length (0 = full audio).
Play Sound KJ
any_input
audio
any_output
audio_path
STRING
mode
always
volume
0.50
duration
5.0
KJNodes
Description
Plays audio in the browser when execution reaches this node. The audio can be provided via an audio input (AUDIO type) or by specifying a file path in the audio_path string input (used when the audio input is not connected). The node offers three playback modes: always (play on every execution), on_empty_queue (play only when the queue finishes), and on_change (play only when the audio content changes). A duration parameter limits playback length; set to 0.0 to play the full audio file.
Inputs
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
any_input | ANYTYPE | No | — | A generic passthrough input. Allows you to insert this node into a workflow without breaking existing connections. |
audio | AUDIO | No | — | Audio data from another node (e.g., a VAE decode output). When connected, this is the audio source that will be played. |
audio_path | STRING | Yes | "" | File path to an audio file. Used only when the audio input is not connected. Leave empty if using the audio input. |
mode | COMBO | Yes | "always" | Playback trigger mode. Options: "always" – plays on every execution; "on_empty_queue" – plays only when the queue finishes; "on_change" – plays only when the audio content (from audio input or audio_path) changes. |
volume | FLOAT | Yes | 0.5 | Playback volume, from 0.0 (silent) to 1.0 (full volume). Step size 0.01. |
duration | FLOAT | Yes | 5.0 | Duration in seconds to play. Set to 0.0 to play the full audio. Range: 0.0 to 300.0, step 0.1. |
Outputs
| Type | Description |
|---|---|
| ANYTYPE | Passes through the value of the any_input input unchanged, enabling workflow continuity. If any_input is not connected, the output will be None. |
Usage Notes
- Audio source priority: When the
audioinput is connected, it takes precedence overaudio_path. If both are provided, theaudioinput is used. - Mode behavior:
always– suitable for testing or continuous playback.on_empty_queue– useful for playing a notification sound after a batch of generations completes.on_change– plays only when the actual audio data (or the file path, if usingaudio_path) differs from the previous execution. This avoids repeated playback when the node is executed multiple times with the same audio.
- Duration: A value of
0.0plays the entire audio clip. Otherwise, playback is cut off after the specified number of seconds (up to 300 seconds maximum). - Volume: The volume is a linear gain applied to the audio. Values above
1.0are not permitted; for amplification, pre-process the audio elsewhere. - Output: The
any_inputpassthrough allows you to chain this node without affecting the data flow (e.g., connect it in parallel to a node whose output you wish to monitor audibly). - Browser environment: The audio is played through the browser's audio system. Ensure your browser has audio playback enabled and that any autoplay policies are satisfied (the node may require a user gesture on first execution).
Comments
Sign in with GitHub to join the discussion.