- 1
//! Provider-neutral voice contracts and deterministic audio primitives - 2
//! (docs/design/49-live-voice.md). Surfaces never own audio transport, - 3
//! credentials, or conversational policy; this crate owns the vocabulary - 4
//! they share: which providers exist, the socket wire protocol, the speech - 5
//! evidence an utterance must carry before it may cost a provider call, and - 6
//! the offline engines. - 7
- 8
use serde::{Deserialize, Serialize}; - 9
use thiserror::Error; - 10
- 11
pub mod audio; - 12
pub mod local; - 13
pub mod protocol; - 14
pub mod provider; - 15
pub mod vad; - 16
- 17
pub use local::{ - 18
EngineReadiness, LocalTranscriber, LocalTtsSpeaker, TRANSCRIBER_VAR, TTS_VAR, engine_readiness, - 19
}; - 20
pub use provider::{VoiceDescriptor, VoiceProvider, catalogue}; - 21
- 22
#[derive(Debug, Error)] - 23
pub enum VoiceError { - 24
#[error("voice provider unavailable: {0}")] - 25
Unavailable(String), - 26
#[error("voice request rejected: {0}")] - 27
InvalidRequest(String), - 28
#[error("voice operation cancelled")] - 29
Cancelled, - 30
#[error("voice transport failed: {0}")] - 31
Transport(String), - 32
} - 33
- 34
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] - 35
#[serde(rename_all = "snake_case")] - 36
pub enum SpeakFormat { - 37
Pcm16, - 38
OggOpus, - 39
Mp3, - 40
Wav, - 41
} - 42
- 43
impl SpeakFormat { - 44
pub fn parse(value: &str) -> Option<Self> { - 45
match value { - 46
"wav" => Some(Self::Wav), - 47
"pcm16" => Some(Self::Pcm16), - 48
"ogg_opus" => Some(Self::OggOpus), - 49
"mp3" => Some(Self::Mp3), - 50
_ => None, - 51
} - 52
} - 53
- 54
/// The canonical name, as accepted by [`Self::parse`] and passed to a - 55
/// local engine. - 56
pub fn as_arg(self) -> &'static str { - 57
match self { - 58
Self::Pcm16 => "pcm16", - 59
Self::OggOpus => "ogg_opus", - 60
Self::Mp3 => "mp3", - 61
Self::Wav => "wav", - 62
} - 63
} - 64
- 65
pub fn mime(self) -> &'static str { - 66
match self { - 67
Self::Pcm16 => "audio/pcm", - 68
Self::OggOpus => "audio/ogg", - 69
Self::Mp3 => "audio/mpeg", - 70
Self::Wav => "audio/wav", - 71
} - 72
} - 73
} - 74
Indexing the workspace…
Vakyartha documentation is discovering safe artifacts, anchors, and source references.