voicemate.audio.protocol¶
Control messages between the browser and the server, defined in one place.
Audio itself travels as binary WebSocket frames (see voicemate.audio.codec); everything
else is a small JSON text message. static/audio.js implements the browser side, and a
contract test keeps it in step with the definitions here.
Browser → server: MicOff, PlaybackStarted, PlaybackEnded.
Server → browser: Stop.
Attributes¶
Classes¶
The user turned the microphone off. |
|
The browser started playing assistant audio. |
|
The browser finished (or dropped) all queued assistant audio. |
|
Barge-in: the browser must drop queued speech. |
Functions¶
Module Contents¶
- voicemate.audio.protocol.logger¶
- class voicemate.audio.protocol.MicOff[source]¶
The user turned the microphone off.
- type = 'mic'¶
- state = 'off'¶
- class voicemate.audio.protocol.PlaybackStarted[source]¶
The browser started playing assistant audio.
- type = 'playback'¶
- state = 'started'¶
- class voicemate.audio.protocol.PlaybackEnded[source]¶
The browser finished (or dropped) all queued assistant audio.
- type = 'playback'¶
- state = 'ended'¶
- class voicemate.audio.protocol.Stop[source]¶
Barge-in: the browser must drop queued speech.
- type = 'stop'¶
- state = None¶
- voicemate.audio.protocol.ControlMessage¶
- voicemate.audio.protocol.CONTROL_MESSAGES: tuple[ControlMessage, ...]¶
- voicemate.audio.protocol.dump(message: ControlMessage) str[source]¶
The JSON text sent over the WebSocket for
message.
- voicemate.audio.protocol.parse(text: str) ControlMessage | None[source]¶
Decode a JSON text message.
- Returns:
The message, or
None(and a log line) when the text is malformed or unknown, so a bad client can never break the session.