STTS implements its own custom wire protocol, that uses Bincode to encode and decode messages.
Each message should be raw binary data, with the following header:
Field | Type | Description |
---|---|---|
type |
u8 |
The message type |
Immediately following the header is the message payload.
Strings are encoded as follows:
Field | Type | Description |
---|---|---|
len |
u64 |
The length of the string |
data |
u8 |
The string data (must be valid UTF-8!) |
Booleans are simply u8s, with 0 for false and 1 for true.
This message is sent by the client to initialize the streaming connection.
0x00
Field | Type | Description |
---|---|---|
verbose |
bool |
Should the response include verbose data? |
language |
String |
The language to use for the model. |
This message is sent to feed audio into the STT engine.
Do not send this message until you receive a "Initialization Complete" message. Any packets sent before that will be ignored.
0x01
Field | Type | Description |
---|---|---|
data_len |
u32 |
The length of the audio data. |
data |
i16 |
The audio data. This must be exactly data_len*2 bytes. |
This message is sent to signal the end of audio streaming, and will trigger a "STT Result Packet" to be sent.
0x02
None
This message is sent to close the connection early, and will immediately trigger a close on the server side.
0x03
None
This message is sent when the client would like this connection to monitor the server status.
0x04
None
This message is sent by the server to signal that the streaming state has been initialized.
After this message is sent, you may send audio data packets.
0x00
None
This message is sent by the server to signal that the streaming state has failed to initialize.
Immediately after the message is sent, the server will close the connection.
0x01
Field | Type | Description |
---|---|---|
error |
String |
The error message. |
This message is sent by the server to signal the end of speech to text processing.
Immediately after the message is sent, the server will close the connection.
0x02
Field | Type | Description |
---|---|---|
result |
String |
The STT result. |
This is the same as the normal STT result message, but includes verbose data.
Just like the normal STT result message, the connection will be closed after this message is sent.
0x03
Field | Type | Description |
---|---|---|
num_transcripts |
u32 |
The number of transcripts in the result. If this is 0, this is the only field that is sent. |
main_transcript |
String |
The main transcript. |
confidence |
f64 |
The confidence of the main transcript. |
This message is sent when the STT engine fails to run the final result.
0x04
Field | Type | Description |
---|---|---|
error |
i64 |
The error code. |
This message is sent by the server to signal that the server is shutting down.
Immediately after the message is sent, the server will close the connection.
0x05
None
This message is sent after the client requests switching the connection into a status connection.
0x06
Field | Type | Description |
---|---|---|
max_utilization |
f64 |
The maximum utilization of the server. |
can_overload |
bool |
If true, and required, max_utilization can be ignored. |
This message is sent every 5 seconds after a "Status Connection Open" message.
0x07
Field | Type | Description |
---|---|---|
utilization |
f64 |
The current utilization of the server. |
This message is sent when the server encounters a fatal IO error.
0xFD
Field | Type | Description |
---|---|---|
error |
String |
The Rust formatted error message. |
This message is sent when the sender sends invalid data.
0xFE
None
This message is sent when the server encounters an unknown error.
0xFF
None