BrowserInput¶
source extra: browser-input
Receive the messages that the web page hosting the pipeline hands over.
- Node type:
BrowserInput- Input:
–
- Output:
AudioPayload,ImagePayload,BytesPayloadorObjectPayload- Extra:
browser-input
$ pip install "juturna-nodes[browser-input]"
The node runs only in a Pyodide Worker, with the browser transport of juturna.
The host calls feed() with a message in the wire format of
juturna.transport.browser._io (a JS object {kind, payload, meta}), and
the node puts the decoded message on its own queue. feed() blocks when the
queue is full, so it must be invoked through .callPromising().
How it works¶
The node sets no source function. The page hands a message over to the
Worker, the Worker calls feed(js_message) on the node, and the node puts
the decoded message on its own queue, like file_watcher does with
filesystem events. The wire format is defined in
juturna/transport/browser/_io.py.
feed() blocks when the queue is full, so it must be invoked through
.callPromising(). Concurrent feed() calls may be reordered: the host
should serialise them (a promise chain in JS) whenever order matters, as it
does for audio.
Arguments¶
None.
Input message¶
Not a Juturna message: a JS object {kind, payload, meta} passed to
feed().
kind(required):audio,image,bytesorobject. Any other value raisesValueError.payload: the fields of the matching payload. Unknown fields raiseValueError; a missing field takes the payload default.audio:audio(Float32Array, orInt16Array, normalised to [-1, 1]),sampling_rate,channels,start,end,audio_format. In practiceaudioandsampling_rateare the ones downstream nodes need.image:image(flatUint8Array),width,height,depth,pixel_format,timestamp.width,heightanddepthare needed to rebuild the(height, width, depth)array; without them the image stays flat.bytes:cnt(Uint8Array).object: any JSON-compatible fields.
meta(optional): copied into the messagemeta. No key is required.
Output message¶
The decoded message, forwarded unchanged by update().
Payload:
AudioPayload,ImagePayload,BytesPayloadorObjectPayload, according tokind. Arrays are copied into Python memory (np.float32for audio, the sent dtype for images).creator: the node name.meta: exactly themetasent by the page. The node adds nothing.
License¶
Code: this node is part of juturna-nodes, MIT (its
LICENSEfile).Pyodide: the node runs in the browser on Pyodide, MPL-2.0.
Configuration¶
Default node arguments, as defined in the node config.toml file. Any of
them can be overridden in the node configuration of a pipeline.
[arguments]
[meta]
Pipeline usage¶
{
"name": "browser_input",
"type": "BrowserInput",
"configuration": {}
}
Reference¶
- class BrowserInput(
- node_name: str = '',
- pipe_name: str = '',
- transport: TransportBackend | None = None,
Forward the messages handed over by the page to the pipeline.