Which voice speaks a line, which voices there are, and the cache of lines already spoken.
A cached line is keyed by the voice and the exact text. What is kept is the audio and the time of every
character, not the text: a reader of the store sees spans, and the line is put back from the request that
asked for it. Only a line the caller declared fixed is ever kept (see [SpeechCache::keep]).
7use std::fmt;
A voice the account can use: its id and the name a child is told.
Why the list of voices could not be read.
34impl fmt::Display for VoicesError { 35 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 36 match self { 37 VoicesError::NotConfigured => f.write_str("the voice is not configured"), 38 VoicesError::Unreachable(d) | VoicesError::Unreadable(d) | VoicesError::Refused { said: d, .. } => d.fmt(f), 39 } 40 } 41} 42 43impl std::error::Error for VoicesError {}
What the cache holds.
Spoken lines kept so that a fixed line costs voice characters once.
Contract, for every adapter:
- Exact. A line is found only for the voice and the exact text it was kept under.
- Bounded, least recently used out. Over its cap the adapter drops the entries used longest ago, never
the one just kept; a line that alone is over the cap is not kept.
findcounts as a use. - No words. What is kept is audio and spans. The text is the caller's.
- Only what the caller declared fixed. The service calls
keeponly for a line its caller said was the same every time (a page name, a hint, a greeting, a preview). Words that came from a memory are never declared, so a forgotten memory leaves nothing here to forget.
The line as kept for this voice, or None.
67 async fn find(&self, voice: &VoiceId, line: &SpeechLine, now: Millis) -> Result<Option<TimedAudio>, StoreError>;
Keeps the line's speech under (voice, text), replacing an older copy.
70 async fn keep(&self, voice: &VoiceId, line: &SpeechLine, speech: &TimedAudio, now: Millis) -> Result<(), StoreError>;
The bytes one cached line takes against the cap: its audio and eight bytes of timing per character.
The cap of the service's speech cache, in bytes: about two thousand lines of speech.
81pub const SPEECH_CACHE_BYTES: u64 = 64 * 1024 * 1024;
The cap of a device's speech cache, in bytes.
84pub const DEVICE_SPEECH_CACHE_BYTES: u64 = 32 * 1024 * 1024;