the rift wire contract, protocol 1
Between the rift daemon (dev.gigantic.rift)
and its clients: the rift command line and any program on its socket.
Clients are written against this page; a change here breaks them unless it is
additive. What rift is: the design.
Transport
- A unix stream socket at
<root>/run/rift.sock;<root>is$RIFT_ROOT, default~/.local/state/rift. <root>/runis mode 0700 and the user's; the daemon refuses to start otherwise.- No TCP listener: devices on other machines are a later protocol.
Framing
- NDJSON: UTF-8, one JSON object per line,
\nterminated. - The daemon writes keys in alphabetical order, with no insignificant whitespace.
- A line over 65536 bytes, its
\nnot counted, is answeredtoo_longand the connection is closed.
Hello
The first line on every connection is the client's hello, client
a string and proto an integer:
{"client":"example/1.0.0","op":"hello","proto":1}
The reply when the protocol matches:
{"boot":7,"ok":true,"pid":4211,"proto":1,"since":"2026-11-22T18:04:11.201Z","state":"ready","version":"2026.11.0-abc1234"}
stateisready,degraded(the last write to the log or a segment failed;readyagain once one succeeds, and no event carries either: a client sees it in its next hello or health) orstopping. The socket is bound only once the daemon has derived its state from the log, so no client sees it booting: until then a connect is refused, as when it is down.bootcounts daemon starts from 1, derived from the log.- Any other first line (not JSON, not an object, not a hello, or a hello whose
clientorprotois missing or mistyped) is answeredbad_requestand closed.
Another proto is answered, and the connection closed:
{"code":"proto","ok":false,"proto":1,"version":"2026.11.0-abc1234"}
version is <release>-<build>:
the release's YYYY.M.N (a checkout's build: the crate version), then the
short commit it was built from, -dirty over uncommitted work.
Requests
After hello the connection carries requests, one per line, each answered by
one line (a pong, sound or
done by none). Any line, hello included, may carry "id", a string or number,
and its reply echoes it, an error included; "id":null is no id, and an
id of another type is bad_request, not echoed.
| op | request | reply |
|---|---|---|
| device | {"kind":"ear","name":"desk","op":"device"} {"kind":"mouth","name":"desk","op":"device","plays":true} | {"ears":true,"ok":true,"ping":1764000000000000,"track":"ear-desk"}, then the connection is that track's device; plays, a mouth's alone, makes it one that plays, and its reply carries "plays":true |
| done | {"op":"done","play":3} | a playing mouth's: nothing more of the play will sound or be sent; none |
| ears | {"on":true,"op":"ears"} | as quiet, for the ears |
| end | {"op":"end"} | a giver's: {"ok":true}; nothing more is given, and what was plays out |
| feed | {"after":null,"op":"feed"} {"after":{"boot":7,"seq":12},"op":"feed"} | {"ok":true,"reset":false}, then the connection is a feed; after is required |
| frame | {"op":"frame","pcm":"…","t":81234567} {"mic":"MacBook Pro Microphone","op":"frame","pcm":"…","t":81234567} | a device's: {"ok":true,"t":1764000000020000}, the frame's time on its track, perhaps with a ping; mic, optional, names the microphone it was heard on |
| give | {"op":"give","pcm":"…"} | a giver's: {"given":4800,"ok":true}, the play's samples given so far, withheld while its mouth holds $RIFT_AHEAD_MS or more unplayed (plays) |
| health | {"op":"health"} | the hello reply's fields, plus "quiet":false, "seq":12 (the last event's seq in this boot), and the stream's "archive":null, "devices":["ear-desk"] (the live tracks), "ears":true, "engines":{} (engines), "playing":{"mouth-desk":3} (each open play by its mouth) and "window":600 |
| hush | {"op":"hush","track":"mouth-desk"} | the mouth's play ended at once, then its played fields, {"dropped":8400,"given":38400,"ok":true,"play":4,"played":30000,"reason":"hush","seq":45,"track":"mouth-desk"}; with no play open, {"ok":true,"play":null} |
| keep | {"archive":"/Volumes/a/rift","op":"keep","window":600} | {"ok":true,"seq":14}: the window in seconds and the archive, an absolute directory or null; then a sweep, which the reply does not wait for |
| listen | {"op":"listen","track":"ear-desk"} | {"ok":true}, then the connection follows the track live |
| play | {"op":"play","rate":24000,"track":"mouth-desk"} | {"ok":true,"play":3,"seq":40}, then the connection is that play's giver; rate is the given audio's, 8000 to 48000 Hz |
| pong | {"op":"pong","ping":1764000000000000,"t":81234000} | a device's answer to a ping; none |
| quiet | {"on":true,"op":"quiet"} | {"changed":true,"ok":true,"seq":13}; the value it already has appends nothing and answers "changed":false with the current seq |
| read | {"from":1764000000000000,"op":"read","to":1764000010000000,"track":"ear-desk"} | {"ok":true}, then the range, then end of stream |
| shutdown | {"op":"shutdown"} | {"ok":true}, then the daemon drains and exits 0; the agent does not respawn it |
| sound | {"from":0,"op":"sound","play":3,"samples":9600,"t":81234567} | a playing mouth's: the run so far of the play's samples its output took back to back; none |
Errors are {"code":"<code>","ok":false}, and clients
match on code, never on other text. A request error leaves the connection
open; only too_long and a refused hello close it.
| code | when |
|---|---|
| absent | a play for a mouth no playing device streams (none connected, or a file-fed one) |
| ahead | a frame half a frame or more before its track's end: the device's clock runs fast, and the frame was dropped |
| bad_frame | pcm is not 640 bytes as hex, or mic (a mouth's: speaker) is neither a string nor null; a give's pcm is not 2 to 16384 bytes, whole samples, as hex |
| bad_request | not JSON, not an object, a missing or mistyped field; a kind, name or track not of the form; frame or pong off a device, device, feed, listen or read on one; a read whose from is not before its to; plays on an ear, a play or hush naming an ear's track or a rate out of range, play or hush on a device, give or end off a play's connection or once its play is over, a second end, any other op on a play's connection, sound or done off a playing mouth |
| busy | a play for a mouth that has one open; nothing changed |
| closed | a frame while the ears are closed; it was not taken |
| gone | a read from before now less the window |
| io | a write to the log or a segment failed; the request took no effect, though a segment it closed on the way stays closed, logged, so a retry repeats nothing |
| proto | the hello's protocol is not the daemon's |
| quiet | a play while quiet is on |
| stopping | a request other than health while draining |
| taken | a device for a track another device is streaming |
| too_long | the line is over the limit |
| unknown_op | an op this protocol does not have, a second hello included |
| unsynced | a frame or a sound before its device's first pong: it has no place on the timeline yet |
Events
Every event is one line, in the log and on a feed:
{"boot":7,"e":{"kind":"quiet","on":true},"seq":13,"t":"2026-11-22T18:09:40.118Z"}
seqstarts at 1 in each boot and rises by 1.(boot, seq)is an event's position, ordered byboot, thenseq.tis UTC, RFC 3339, to the millisecond.
| kind | fields | when |
|---|---|---|
| boot | pid, version | the first event of every boot |
| ears | on | the ears opened or closed |
| hole | [mic,] samples, start, track | a gap in a track's frames this boot, or another microphone, logged as the frame after it arrives |
| keep | archive, window | the window or archive was set |
| play | play, rate, track | a play opened on the mouth track; play counts plays from 1 across every boot, never reused |
| played | dropped, given, play, played, reason, track | the play is over, its counts in its own samples at its rate: given = played + dropped (plays); the next boot's for a play a kill left open has neither given nor dropped |
| quiet | on | the quiet setting changed: health's quiet is on from here; on, every open play ends quiet after it |
| sound | from, play, samples, start, track | one run of the play's samples, from up to from + samples, that the output took back to back, the first sounding at start; logged when the run ends, before the next run's and the played |
| segment | [mic,] n, path, samples, start, track | a segment closed; path is under the root, audio/<boot>/<track>/<n>.pcm |
| stop | reason | the drain began: health's state is stopping from here, and nothing follows it in this boot; a killed boot has none |
| track | [mic,] start, track | a track's first frame this boot |
[mic,]: the microphone the event's frames name, present only when
they name one, so a file-fed device's events are as they were; a mouth's name the output they
sounded on, speaker, carried the same way and by the same rule.
Additive, so no proto bump: a new kind, a new field on
an event or a reply, a new op, a new error code. Clients ignore kinds and fields they do not know.
The log
<root>/events.ndjson, append-only, one event per line, written in one unbuffered write before the event reaches any feed and before the request that caused it is answered. There is no fsync: an event survives a kill, not a power loss.- It is the daemon's durable state beside the audio. On boot the daemon
derives from it
boot(the log's last boot plus 1),quietandears(the last such event'son, defaultfalse), the window and archive (the lastkeep, default 600 s and none), and the closed segments still underaudio/, the nextplay(the log's last plus 1) and the plays a kill left open (plays). A torn last line, left by a kill mid-write, is cut off.
Feed
- After the
feedreply the daemon sends events, one per line, and reads nothing more but the end of stream, which ends the feed at once; a client with a request opens another connection. "after":nullstarts at the current boot's first event."after":{"boot":b,"seq":s}starts after the event at exactly that position, later boots included; a position the log does not hold starts at the current boot's first event, and the reply says"reset":true.- Replay and live events are one gapless, duplicate-free sequence.
- A feed with 1024 events queued and unsent is disconnected (what the socket buffers hold is on top of that); it reconnects from its last position.
- End of stream means the daemon stopped or dropped the client; there is no heartbeat.
The stream
- One timeline: the daemon's clock, microseconds since the epoch. Every
start,from,toandping, and thetof a reply or a frame sent to a reader, is on it; only theta device sends is on the device's own clock. - A frame is 20 ms of 16 kHz mono 16-bit little-endian PCM, 640 bytes, carried as 1280 lowercase hex digits so every message stays one JSON line. 320 samples; a sample is 62.5 µs, and a time between two samples takes the earlier.
- A track is
<kind>-<name>: kindear(what a device heard) ormouth(what it played, as played), name 1 to 64 ofA–Z a–z 0–9 - _. One device streams a track at a time. - The ears are open or closed, closed by default, kept across restarts. Closed, devices stay
connected and their frames are refused
closed; closing them closes every open segment. Every device is told each change:{"ears":false}.
Devices
- After its
devicereply a connection sends frames and pongs. What it reads back is a reply (it carriesok, answering its last frame) or a notice of the ears; any line carryingpingis answered with apongholding that ping and the device's clock. - The device reply carries a ping, and a frame's reply carries the next once
$RIFT_PING_MS(default 10 s) has passed since the last. The device's clock read the pong'stbetween the ping's sending and the pong's reading: the first pong is placed at the midpoint, and a later one moves the offset only as far as that span proves it wrong, so a late pong moves no frame and a stepped clock is followed to within one round trip. The first placement may be off by half that first round trip, long on a busy machine: a later pong moving it half a frame or more leaves a hole, or, moving it back, refuses framesaheadfor as long as it moved. Each frame is placed by that offset, never later than it is read. A device stamps its frames on the clock its pongs read, and answers a ping as it arrives. A frame before the first pong is refusedunsynced. Pings ride frame replies, so an idle device is not re-measured until it sends again. - A track's first frame in a boot starts it (
track). A frame half a frame or more past the track's end closes the open segment and is aholefrom that end; one half a frame or more before it is refusedahead, so a fast clock never runs a track ahead of the device; any other frame goes at the end, so jitter never splits a track. Each frame is on disk and with every listener before its reply. - A frame may name its microphone,
mic. A segment holds one microphone's frames: a frame naming another than the track's last (none counts as one) closes the open segment and opens with ahole, however short, zero samples included. Thetrack,holeandsegmentevents carry it, and the archive's index with them; a segment a kill left open takes the microphone of its track's last event of that boot. A mouth's frame names its output,speaker, under the same rule.
Plays
A client, the giver, gives audio to the daemon for a mouth; the daemon passes it to the device streaming that mouth's track, which plays it on its output (the mouth). The daemon holds no audio: what waits, waits in the mouth.
- One play at a time per mouth. A
playfor a mouth with one open is refusedbusy, for one no playing device streamsabsent, while quiet is onquiet. Its reply numbers it (play, logged as theplayevent), and the connection is then the play's: it carriesgives and oneend, any other op refusedbad_request. - Giving.
pcmis 16-bit mono little-endian at the play'srate, 2 to 16384 bytes of whole samples as lowercase hex (a line of at most 32 KiB). A give is given as it is read: counted, then passed to the mouth. Its reply is withheld while the mouth holds$RIFT_AHEAD_MS(default 200) or more of the play given and not yet taken by its output, so a giver faster than real time is paced by its replies and the mouth holds at most that plus one give; a giver that sends ahead of its replies leaves the rest in the socket, not yet read. The daemon passes each give to the mouth on the mouth's own queue; one full (a mouth not reading) is dropped as a slow feed is, and the play endsmouth. - The end. Every play ends in one line to its giver, the
playedevent's fields andseq, with nook, then the end of stream:{"dropped":0,"given":72000,"play":3,"played":72000,"reason":"end","seq":42,"track":"mouth-desk"}. A give whose reply was withheld is answered first; one read afterend, a hush or the play's end is refusedbad_request, never counted or passed on. A play given nothing ends at once at itsendor its hush, with its reason, its mouth never having held any of it. A giver that leaves afterendleaves its play playing out, with no one to tell. - A stall. A play whose mouth owes progress (the play's end after
end, or given past what its output took by more than 64 samples, the interpolator's window both sides, which waits on the next give and is owed nothing, so a giver may pause as long as it likes) and has reported nothing since its last report, give orend, whichever is latest, for$RIFT_STALL_MS(default 15000, headroom for an output's slow open such as a Bluetooth wake; checked every second) endsmouth, its giver answered, its mouth told to drop it: an output failed or stuck in place never holds a giver, and a giver gone while its reply is withheld is seen then at the latest. - Reasons.
end: the giver sentendand the mouth took all it was given.hush: ahushrequest.quiet: quiet was set on.left: the giver's connection ended beforeend, which hushes the play.mouth: the mouth's connection ended, its queue was full, it saiddoneunasked, it stalled, or it had not answered a hush within 1 s and was cut.stop: the daemon's drain.lost: a kill; the next boot's. - Counts. Every count is in the play's own samples at its rate.
playedis how many its mouth's output took, in order from the first, each sounding once that output's latency has passed;droppedthe rest ofgiven, never sounded. The play'ssoundevents, in order, are contiguous runs from 0 whosesamplessum toplayed: a run ends where the output took anything else (the mouth ran dry, its output was reopened), so samplefrom+ k sounded atstart+ k /rates.startis on the daemon's clock, the mouth's own converted by its ping offset and not capped at now: it may lie up to the output's latency after the event'st. - A hush. The daemon tells the mouth, which drops everything the play has
queued at once and reports its last
sound, then, once the track's frame holding the play's last sample has been sent,done; then thesoundandplayedevents, the mouth's open segment closed, the hush's reply and the giver's line. What the output took before the hush still sounds and is counted played. A mouth that has not answered in 1 s is cut, and the play endsmouthat its last report.
On a feed, a play of 3 s at 24 kHz that ran to its end, then one hushed
1.25 s in, its giver 350 ms ahead (the mouth's own track events, when the ears are open,
interleave, its segment closing at each played):
{"boot":7,"e":{"kind":"play","play":3,"rate":24000,"track":"mouth-desk"},"seq":40,"t":"2026-11-22T18:10:00.004Z"}
{"boot":7,"e":{"from":0,"kind":"sound","play":3,"samples":72000,"start":1764000000021000,"track":"mouth-desk"},"seq":41,"t":"2026-11-22T18:10:03.008Z"}
{"boot":7,"e":{"dropped":0,"given":72000,"kind":"played","play":3,"played":72000,"reason":"end","track":"mouth-desk"},"seq":42,"t":"2026-11-22T18:10:03.008Z"}
{"boot":7,"e":{"kind":"play","play":4,"rate":24000,"track":"mouth-desk"},"seq":43,"t":"2026-11-22T18:10:05.000Z"}
{"boot":7,"e":{"from":0,"kind":"sound","play":4,"samples":30000,"start":1764000005019000,"track":"mouth-desk"},"seq":44,"t":"2026-11-22T18:10:06.252Z"}
{"boot":7,"e":{"dropped":8400,"given":38400,"kind":"played","play":4,"played":30000,"reason":"hush","track":"mouth-desk"},"seq":45,"t":"2026-11-22T18:10:06.252Z"}
- The mouth's side. A device whose
devicerequest carries"plays":true(a mouth's alone) plays; its reply says"plays":true. It reads, beside replies, pings and notices of the ears,{"pcm":"…","play":3,"rate":24000}(a give, passed on as given),{"end":3}(play out what is queued, thendone) and{"hush":3}(drop it now, thendone), the plays' lines on a queue of their own beside its replies'. It sendssound, its play's current run (from,samplesso far,tthe first sample's sounding on its own clock), every 20 ms of output and as each run ends; a newfromstarts the next run and logs the last.soundanddonenaming a play that is not open are ignored; adonefor one neither ended nor hushed ends itmouth. The mouth ignores a give for a play it has ended or finished, and anendor hush for one it never held. A device withoutplays, the file-fed mouth among them, streams its track as before and is never given audio. - Its track. The mouth's frames are what its output took, at 16 kHz, cut on one 20 ms grid from the output's open and stamped from the output's callback plus the latency the system reports for it; a frame is sent once its last sample has sounded, so no frame is ahead of now. Only a frame holding some of a play's samples is sent, the one holding its last filled with silence as the play ends: silence between plays, and a mouth run dry for a frame or more, sends nothing, a hole logged at the next play's first frame. The daemon closes the mouth's open segment as each play ends, so nothing of a mouth outlives the window. While the ears are closed it sends none, as an ear; plays go on.
- Lost and re-derived. The drain hushes each open play in turn inside
$RIFT_DRAIN_MS, one whose mouth has not answered by then ended at its last report, and logs eachplayed(stop) beforestop. A kill leaves plays with aplayand noplayed; the next boot logs one for each,"reason":"lost",playedthe sum of its loggedsounds and nogivenordropped: the run under way at the kill is not on disk, only, when the ears were open, the mouth's frames up to it. The mouth, its connection gone, drops what it holds; a giver's connection ends without its line, an unknown outcome.
Audio on disk
<root>/audio/<boot>/<track>/<n>.pcm, raw frames appended as they arrive. A segment closes, with itssegmentevent, once$RIFT_SEGMENT_MSlong (default 10 s, in whole frames), at a hole, as its device leaves, as the ears close and in the drain;ncounts a track's segments in its boot.- A hole writes nothing; a reader gets silence for it. It is logged when the track's next frame arrives in the same boot, so a device that never returns, or returns after a restart, leaves no hole event: a gap is always derivable from segment starts and samples.
- A kill leaves the open segments without events. The next boot cuts each one to whole frames and closes it with its event, its start where its track's last event of that boot ended: a restart loses at most the frames not yet written.
- The sweep, at each segment's close, each
keep, each boot and every second, so the window holds while nothing streams: a closed segment that ended more than the window ago leavesaudio/, moved by a thread of the daemon's own, so a slow archive disk holds up no request. With an archive it is copied to the same path under it, itssegmentevent as logged is appended to the archive'sindex.ndjson, then it is removed; with none it is deleted. One that fails stays for the next sweep. A kill between the index line and the removal repeats the line at the next sweep: a reader of the index takes the last line perpath. Nothing deletes from the archive.
Readers
- After the
readreply the daemon sends the range as frames,{"pcm":"…","t":1764000000000000}, fromfromin 20 ms steps (the last may be shorter), silence wherever nothing is held,tocapped at now; then the end of stream. It streams from disk a segment at a time, so a read of any length holds a segment or two. A range starting before now less the window isgone; the archive is for other readers. - After the
listenreply the daemon sends each frame placed on the track, the same shape, until it drops the client, as a feed does (1024 frames behind). There is no replay: a client wanting the recent past reads it first.
Client rules
health,feed,quiet,ears,keep,listenandreadare safe to retry;shutdownand aframeonly when the request was provably not sent, since a frame sent twice lands twice.hushandplayare safe to retry: a play opened on a connection that then ended is ended by it (left), so a retry meets at mostbusyuntil that is logged; agivebelongs to its connection and dies with it.- A request whose connection ends before its reply, after it was sent, has an unknown outcome, as does an error code the client does not know.
- A client's own codes, beside the daemon's:
down, the request provably not sent (no connection, or none past hello), andunknown, its outcome unknown. Theriftcommand line prints either as{"code":"<code>","ok":false}, and a refused hello as it came. - An event moves a health read only when it is of that health's
boot: a replay from an earlier position carries earlier boots' events, which the fresher read already supersedes. - A client whose hello is refused
protosays so in one line naming the daemon's protocol and version, its own, and the fix.
Engines
Served, the echo engine's clean track aside, designed
(the slices). An engine is a client that does one kind of work
on one track and reports results, which the daemon checks and logs as events
(the design). Every op, field, event and code here is
additive: proto stays 1, and nothing above changes meaning.
- The connection. After hello,
{"from":null,"kind":"words","name":"transcribe","op":"engine","track":"ear-desk"}.kindisecho(on an ear's track),speech(a mouth's),talkers,turnorwords(an ear's or a clean track's);nameis of a track name's form.from, a talkers, turn or words engine's alone and required, is a time on the stream,nullfor live, or"through": from its kind'sthroughon the track, live when that isnull, so one connection resumes; nevergone, the replay starting at the oldest audio still held, since a resume wants all it can have. The reply,{"ok":true,"seq":20,"through":1764000000600000}, logsengine;through, a talkers, turn or words engine's, is the latest time a logged report of that kind on that track names, any boot, ornull(a turn engine's the later of its voices' starts and its turns' ends, so a resume may replay from a voice on); an echo engine's carriesruledinstead, where its ruling starts (below). The connection is then the engine's: its reports, each answered{"ok":true}(withseqwhen logged), any other opbad_request; every reply, a report's included, echoes the request'sidwhen one is sent, so an engine matches replies to reports. Its end, however it comes, logsengine"on":false. - One per kind per track. A second
enginefor a kind and track held is refusedtaken, as a device is. - Trust. The daemon checks a report's form, never its truth: its times,
order and fields, not whether a word, a turn, a mask or a label is right. Any process of the
socket's user may connect as an engine of any kind no one holds (before a job starts, during
a respawn or a swap) and report what it likes, and
nameis its own word, so every result of every kind is a claim by whichever process held that kind's slot. The boundary is same-user access to the 0700run/directory. A client sees a change of engine in theengineevents, off then on, and theirname, and can verify nothing more. - No clock of its own. An engine is never pinged: every time it sends is one
it read off what it was given, on the daemon's clock. A report naming a time past the end of
the last frame it was given (an engine still replaying: the frames of its replay so far, never
a live one it has not been sent), or starting before the latest time its kind of report names on
that track (logged, any boot: a partial's the last final's end), is
bad_requestand logs nothing. A mask's on or off alone may lie up to 1 s past what was heard (before a frame has come, past where its ruling starts), since a run's echo is known as it sounds, and no earlier than the engine's ruling, which starts where the track's frames passed on reach (any boot) as it connects, or past the latest mask when later, as its reply'sruledsays; so no mask reaches a frame already passed on and none is unbounded. - What a talkers, turn or words engine reads. Its track's frames,
{"pcm":"…","t":1764000000000000}as a reader's, fromfrom(null: where its frames reach as it connects): replayed from disk, a segment the sweep moved read from the archive, until the replay has caught up, then live, one gapless, duplicate-free sequence as a feed's, so an engine slower than its ear is never dropped while it replays; a hole sends nothing, seen as a jump int. Afrombefore now less the window isgone, and so is a replay meeting a segment in neither place:{"code":"gone","ok":false}, then the end of stream. On an ear's track, samples the echo stage marked are zeros and their frame carries"masked":true; while an echo engine is connected, a live frame waits until it has ruled on it. A talkers or words engine also reads each loggedturnon its track,{"turn":{"end":…,"start":…}}, after the frame holding itsend, so it may finish a turn knowing it has all of it, and each loggedvoice,{"voice":{"on":true,"start":…}}, after the frame holding itsstart(an off's, the voice's end, as a turn's, before the turn it closes), so it knows where speech is; replayed alike. A turn line may come long after its end (a turn engine holding a turn it found unfinished), so a words engine keeps its audio past a turn's end until the line or its own rule closes it. Word times are as fine as the engine can give: one without per-word times may spread them within its span. 1024 live lines unsent drop the engine, as a listener. - What a talkers engine reports. Who was speaking, as spans
[
start,end) that never overlap and rise, as finals do, each settled: never revised, so an engine whose labels change for recent audio holds a span until they stop. A span'stalkersare the voices speaking throughout it, each{"id":…,"score":…}: none for nobody, two or more for speech at once, a change in who speaks a new span.idis a string for an enrolled voice, the label of a track name's form starting with a letter (so no label reads as a number) the engine was configured with, the same across connections and boots while its profile stands; or an integer for a voice matching none, numbered from 1 on each connection in the order first reported, never reused on it and meaning nothing past it (theengineevents bracket a connection); one voice may take a new integer within a connection, as after an engine starts its model afresh.scoreis the engine's evidence that the span's audio is that enrolled voice, 0 to 1, higher closer, meaning nothing beyond its order within one engine and release, so no value of it is a cut the protocol promises; evidence, not authentication.nullis an integer id's, and a label's the engine did not identify (a span too short to score, say): never act on a label with a null score. The talkers are ordered strings first, in byte order, then integers rising, each id once. A span is never empty (startbeforeend) and names at most 16 talkers. A span's end is the engine's settled reach: no later span starts before it. Spans need not tile: time no span covers is unknown, never nobody's, and a span with no talkers is the only way to say nobody spoke. The engine cuts a span where the turn line it read ends a turn, once its labels there have settled, so the span covering a turn's end closes with it rather than with the next change; with no turn engine on the track it cuts at changes alone. Audio the echo stage masked is nobody's. - What an echo engine reads. Its ear's frames, live only, and, for every
mouth, each play's open (those open as it connects, with their runs so far, first) (
{"play":3,"rate":24000,"track":"mouth-desk"}), each run as its mouth reports it, on the daemon's clock ({"from":0,"play":3,"samples":960,"start":…,"track":"mouth-desk"}), and its end ({"played":3,"track":"mouth-desk"}). It reportsmaskandruled, and later may stream a clean track (below; not yet served). One 1024 frames behind its ruling is dropped. With none connected, or once one leaves, frames go on unruled at once: the stage fails open, and theengineevents record where. One leaving with its mask on has it put off at its ruling, logged before itsengineoff; a boot after a kill puts a mask left on off as it starts. - What a speech engine reads. Its mouth's says:
{"say":5,"text":"…"}per piece of text in order,{"end":5}(no more text) and{"hush":5}(stop now). It gives the audio through the plays path on a connection of its own,{"op":"play","rate":24000,"say":5,"track":"mouth-desk"}, one play per say, ended only after the say'send(before it, the play'sendisbad_request; after it,{"ok":true}and then the play's last line, as any play's); a play naming a say that is not open on that mouth, or one already played, isbad_request.
| report | kind | line | rule; logged as |
|---|---|---|---|
| done | speech | {"op":"done","say":5} | after the say's end, no play is coming (nothing to sound); the say ends end, spoken 0. Before its end or with its play opened: bad_request |
| frame | echo | {"op":"frame","pcm":"…","t":…} | the clean track's frame for the ear's frame at t, at most one each; streamed to clean-<name> as a device's frames are, segments and window alike |
| mark | speech | {"op":"mark","samples":21600,"say":5,"text":13} | the say's first text characters (Unicode scalar values) have sounded once the play's sample samples has; each past the last on both; not logged, kept for spoken |
| mask | echo | {"on":true,"op":"mask","start":…} | from an on's start to its off's the ear is the machine hearing itself; on and off alternating from on, rising; mask |
| partial | words | {"end":…,"op":"partial","start":…,"words":[…]} | a hypothesis for audio after the last final, superseding the last partial; not logged, sent to partials readers |
| ruled | echo | {"op":"ruled","to":…} | every sample before to is ruled on; rising; releases the frames held for it; not logged |
| talkers | talkers | {"end":…,"op":"talkers","start":…,"talkers":[{"id":"enrolled-1","score":0.82},{"id":2,"score":null}]} | the voices speaking throughout [start, end), settled, never revised; spans never overlap and rise, none empty; at most 16 talkers, each id a string of a track name's form starting with a letter, with a score from 0 to 1 or null (not identified), or an integer from 1 with null, the score always present; strings in byte order, then integers rising, none twice; talkers, each talker's two fields alone |
| turn | turn | {"end":…,"op":"turn","start":…} | a turn from the voice that began it to the voice's end that closed it; turns never overlap and rise; turn |
| voice | turn | {"on":true,"op":"voice","start":…} | speech starts (on) or stops at start, on and off alternating from on; voice |
| words | words | {"end":…,"op":"words","start":…,"words":[{"end":…,"start":…,"text":"hello"}]} | final words for [start, end), never revised; finals never overlap and rise, each word inside its span, the words rising; words |
| op | request | reply |
|---|---|---|
| end | {"op":"end"} | on a say's connection: {"ok":true}; no more text, and what was given is spoken out |
| partials | {"op":"partials","track":"ear-desk"} | {"ok":true}, then each partial as its engine sends it, {"end":…,"engine":"transcribe","start":…,"track":"ear-desk","words":[…]}, no replay, until the engine leaves (end of stream) or the client falls 1024 behind; absent with no words engine on the track |
| say | {"op":"say","track":"mouth-desk"} | {"ok":true,"say":5,"seq":50}, then the connection is that say's: texts and one end, as a play's gives; it ends in one line, the spoken event's fields and seq, then the end of stream |
| text | {"op":"text","text":"Hello there. "} | a say's: {"ok":true,"text":13}, the characters given so far, passed to the speech engine as given; withheld while 8 pieces or more are queued for the engine and not yet written to it, so a client faster than its engine is paced by its replies |
- A say.
saynumbers it from 1 across every boot, never reused, and holds its mouth from that moment: aplayorsayfor the mouth while one is open isbusy, the say's own play alone admitted. No speech engine on the mouth, or no playing device streaming it, isabsent; quiet on,quiet. Ahushof the mouth ends the say with its play, or alone when it has none yet, the engine told{"hush":5}at once, as is it whenever its say ends other than at its end; the hush's reply then carries"say":5beside the play's fields. A say's connection that ends beforeendhushes it (left); after it, it speaks out. A speech engine that leaves ends its open sayengine, its play hushed: either play'splayedsayshush, its say the cause. - What sounded. A say ends with its play's
played(or, with no play, at once).spokenis the say's whole text when the play, given something, endedendhaving played all of it; otherwise the largest mark'stextwhosesamplesis at most the play'splayed, 0 with no such mark or no play. A client reads which text sounded as the firstspokencharacters oftext, never by time. - Reasons. A say's are its play's (
end,hush,left,lost,mouth,quiet,stop), andengine. A kill leaves asaywith nospoken; the next boot logs onelost, itsspokenfrom the marks it cannot know, so 0, and notext. - Health.
"engines":{"ear-desk":{"turn":"endpoint","words":"transcribe"},"mouth-desk":{"speech":"read-aloud"}}: each track's connected engines by kind, their names; a kind not listed is not connected.playinglists a say's play as any. - Retries.
partialsis safe to retry;sayasplay: a say opened on a connection that ended is ended by it, so a retry meets at mostbusy; atextdies with its connection. An engine's reports are not retried: it reconnects and resumes fromthrough. - Who spoke a turn. No event carries a speaker but
talkers: a client joins by time on a feed. For aturn[s, e) it keeps thetalkersevents overlapping it, before or after the turn's own, and over the turn's whole length sums each id's time, nobody's (spans with no talkers) and the unknown (time no span covers). A span counts as a label's only when the label carries a non-null score the client accepts; a label with a null score, or one the client does not accept, counts as unknown. The turn is known once a span ends at or past e. Its tail is unknown when anengineoff for the talkers kind on the track is logged after the turn's last span (before or after the turn's own event) with no span reaching e, or when no talkers engine is on at the turn's event and no span covers it; otherwise it is not yet known. Integer ids are summed per connection, never across anengineon: a new connection's1is another voice. What share counts as mostly, and what score it accepts, are the client's, chosen and validated on its own voices. Four answers stay apart: a label with an accepted score (an enrolled voice), an integer (a voice not enrolled), no talkers (nobody), and no span or no accepted score (unknown). - A talkers engine leaving. Its spans logged stand; the span it held open
is never reported, so its reach stops at its last end and the next engine resumes from
through, its integer ids counted afresh.
| kind | fields | when |
|---|---|---|
| engine | name, on, stage, track | an engine connected (on) or left, stage its request's kind (the event's own kind is engine); a turn engine leaving with its voice on has it logged off at the end of the last frame it was given, before this event, and a boot after a kill logs a voice left on off as it starts, so every voice on is followed by its off, live and in a replay |
| mask | engine, on, start, track | an echo engine's mask of its ear going on or off |
| play | [say,] play, rate, track | as above; say when the play is a say's |
| say | say, track | a say opened on the mouth track |
| spoken | play, reason, say, spoken, text, track | the say is over: text all it was given, spoken how many of its characters sounded, play its play or null |
| talkers | end, engine, start, talkers, track | a talkers engine's span, each talker {"id","score"} |
| turn | end, engine, start, track | a turn engine's turn |
| voice | engine, on, start, track | a turn engine's speech start or stop |
| words | end, engine, start, track, words | a words engine's final words, each {"end","start","text"} |
Engine results are events, kept in the log for good while the audio they name
leaves with the window: a client reads past ones on a feed from a position,
and may find the audio behind a words event gone
or in the archive. Codes beside the table above: absent also for a
say or partials with no engine of its kind on
the track; busy for a say or play while a say is open;
gone for an engine's from;
taken for a kind and track held.
Minimal engines, one per kind, lines as sent (→) and read (←), hello and its reply left out. A words engine reading live:
→ {"from":null,"kind":"words","name":"transcribe","op":"engine","track":"ear-desk"}
← {"ok":true,"seq":20,"through":null}
← {"pcm":"…","t":1764000000000000}
← … a frame every 20 ms
→ {"end":1764000000640000,"op":"partial","start":1764000000000000,"words":[{"end":1764000000640000,"start":1764000000300000,"text":"hel"}]}
← {"ok":true}
← {"turn":{"end":1764000001200000,"start":1764000000300000}}
→ {"end":1764000001200000,"op":"words","start":1764000000000000,"words":[{"end":1764000000700000,"start":1764000000300000,"text":"hello"},{"end":1764000001200000,"start":1764000000760000,"text":"there"}]}
← {"ok":true,"seq":24}
A turn engine:
→ {"from":null,"kind":"turn","name":"endpoint","op":"engine","track":"ear-desk"}
← {"ok":true,"seq":21,"through":null}
← {"pcm":"…","t":1764000000000000}
→ {"on":true,"op":"voice","start":1764000000300000}
← {"ok":true,"seq":22}
→ {"on":false,"op":"voice","start":1764000001200000}
← {"ok":true,"seq":23}
→ {"end":1764000001200000,"op":"turn","start":1764000000300000}
← {"ok":true,"seq":24}
A talkers engine, one voice enrolled as enrolled-1,
reading the turn above; a second voice joins at 1.6 s, the two overlap, the first stops:
→ {"from":"through","kind":"talkers","name":"diarize","op":"engine","track":"ear-desk"}
← {"ok":true,"seq":25,"through":null}
← {"pcm":"…","t":1764000000000000}
← … frames; its labels for a time settle about 1 s after it
← {"turn":{"end":1764000001200000,"start":1764000000300000}}
→ {"end":1764000000300000,"op":"talkers","start":1764000000000000,"talkers":[]}
← {"ok":true,"seq":26}
→ {"end":1764000001200000,"op":"talkers","start":1764000000300000,"talkers":[{"id":"enrolled-1","score":null}]}
← {"ok":true,"seq":27}
→ {"end":1764000001600000,"op":"talkers","start":1764000001200000,"talkers":[]}
← {"ok":true,"seq":30}
→ {"end":1764000002100000,"op":"talkers","start":1764000001600000,"talkers":[{"id":"enrolled-1","score":null},{"id":1,"score":null}]}
← {"ok":true,"seq":31}
→ {"end":1764000002000000,"op":"talkers","start":1764000002100000,"talkers":[{"id":1,"score":null}]}
← {"code":"bad_request","ok":false}
The last ends before it starts and is refused, logging nothing; the engine
holds what it has until it reports it right. Its first span ends at the turn's start and its
second at the turn's end, the cut the turn line asked for, so a client knows at seq 27 that the
engine labelled the whole turn enrolled-1. With its score null (diarize
scores no span under 2 s), that label identifies no one, and the turn counts as unknown: a
client acts only on a label whose non-null score it accepts.
An echo engine masking a play as it sounds, the tail heard out:
→ {"kind":"echo","name":"tail","op":"engine","track":"ear-desk"}
← {"ok":true,"ruled":1764000004980000,"seq":19}
← {"pcm":"…","t":1764000005000000}
← {"play":6,"rate":24000,"track":"mouth-desk"}
← {"from":0,"play":6,"samples":480,"start":1764000005019000,"track":"mouth-desk"}
→ {"on":true,"op":"mask","start":1764000005019000}
← {"ok":true,"seq":53}
→ {"op":"ruled","to":1764000005020000}
← {"ok":true}
← … the play's end, frames until 1764000005239000
→ {"on":false,"op":"mask","start":1764000005239000}
← {"ok":true,"seq":55}
A speech engine, its play on a second connection; the client's side is
say, {"op":"text","text":"Hello there. "},
{"op":"text","text":"How are you?"}, end, then
{"play":6,"reason":"end","say":5,"seq":58,"spoken":25,"text":"Hello there. How are you?","track":"mouth-desk"}:
→ {"kind":"speech","name":"read-aloud","op":"engine","track":"mouth-desk"}
← {"ok":true,"seq":18}
← {"say":5,"text":"Hello there. "}
(second connection) → {"op":"play","rate":24000,"say":5,"track":"mouth-desk"} ← {"ok":true,"play":6,"seq":52}, then gives
→ {"op":"mark","samples":21600,"say":5,"text":13}
← {"ok":true}
← {"say":5,"text":"How are you?"}
← {"end":5}
→ {"op":"mark","samples":45600,"say":5,"text":25}
← {"ok":true}
(second connection) → {"op":"end"}, then the play's last line
- What an engine may rely on. The frames it is given are gapless but for
holes and in order; a live ear frame it is given was already ruled on by the echo stage when
one was connected; a talkers or words engine's
turnlines follow the frames they span;throughis exact; a report refused is not logged; the codes and the fields above. - What is left unspecified, and may change in any release. When the daemon sends a frame relative to its placement, and how frames batch on the socket; how a held frame waits beyond the order stated; the order of lines between engines, beyond each engine's own; which of two engines racing for a kind wins; anything an engine decides: partials' cadence and contents, a final's latency, word boundaries, a mask's tail, when a turn closes, a speech engine's rate and its marks' spacing; a talkers engine's thresholds, how many voices it tells apart, how long a new voice waits for its id and a span to settle, where it cuts beyond the turn ends and changes, which spans it scores, and what a score means beyond its order within one engine and release, so any cut on it is the client's own. A client depends on values and order, never on how soon.