canvist_dictation
The wire protocol for dictation in canvist: the messages a client and a dictation relay exchange over one WebSocket. The relay (canvist_dictation_relay) and every Rust client binding share these types, so they cannot drift apart.
- Client to relay:
start(language, context, polish), audio as binary frames of 16-bit little-endian PCM, mono, at 16 kHz, thenstop. - Relay to client:
ready,partialdrafts that replace a segment’s text, onefinalper segment in segment order,errorwith a code and whether it is fatal, anddone.
It depends only on serde and serde_json.
use canvist_dictation::ClientMessage;
use canvist_dictation::RelayMessage;
let start = ClientMessage::Start {
language: Some("en".to_owned()),
context: None,
polish: true,
};
let json = start.to_json();
match RelayMessage::from_json(r#"{"type":"partial","segment":0,"text":"hello"}"#)? {
RelayMessage::Partial { segment, text } => println!("draft {segment}: {text}"),
_ => {}
}
# Ok::<(), serde_json::Error>(())The protocol and the design behind it are in docs/internal/dictation.md.