xous_tts_backend/
api.rs

1pub const SERVER_NAME_TTS_EXEC: &str = "_Text To Speech Executable_ / (external C program)";
2pub const MAX_WAV_BUF_SAMPLES: usize = 1024;
3
4/// Back end opcode table
5#[derive(num_derive::FromPrimitive, num_derive::ToPrimitive, Debug)]
6pub enum TtsBeOpcode {
7    /// Take a string and translate it to a WAV file
8    StrToWav,
9    /// Register callback routing for WAV data
10    RegisterCb,
11    /// Exit server
12    Quit,
13}
14
15/// Backend-originated control messages that can be sent to the front end
16#[derive(Debug, Copy, Clone, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
17pub enum TtsBeControl {
18    Abort,
19    End,
20}
21
22/// Messages to the backend. Currently, just the text string can be sent, and it is
23/// limited to 2048 characters in length.
24#[derive(Debug, Clone, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
25pub struct TtsBackendMsg {
26    pub text: String,
27}
28
29/// Configuration data for the backend
30#[derive(Debug, Copy, Clone, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
31pub struct TtsBackendConfig {
32    pub sid: [u32; 4],
33    pub op: u32,
34    pub samples_per_cb: Option<u32>,
35    pub words_per_minute: Option<u32>,
36}
37
38/// Data returned by the backend to the `dedicated_sid`, routed to the opcode
39/// as specified in the callback specifier.
40#[derive(Debug, Copy, Clone, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
41pub struct TtsBackendData {
42    /// the 16-bit wave sample data being passed back.
43    /// Can be no larger than MAX_WAV_BUF_SAMPLES, but is allowed to be smaller or even 0.
44    pub data: [u16; MAX_WAV_BUF_SAMPLES],
45    /// the actual length in the buffer
46    pub len: u32,
47    pub control: Option<TtsBeControl>,
48}