Surfaces ↓
Audio
client.audio Daemon -> webapp audio events: TTS lifecycle notifications and volume/mute changes.
Commands
fire-and-forget; the promise resolves once the daemon has taken the message
volumeUp(): Promise<void>
await client.audio.volumeUp(); volumeDown(): Promise<void>
await client.audio.volumeDown(); muteToggle(): Promise<void>
await client.audio.muteToggle(); ttsCancelAll(): Promise<void>
await client.audio.ttsCancelAll(); Events
the daemon pushes these unprompted; subscribing returns an unsubscribe function
onTtsStarted(handler: (TtsStarted) => void): () => void
const off = client.audio.onTtsStarted((ttsStarted) => {
console.log(ttsStarted.id);
});
// call off() to unsubscribe onTtsEnded(handler: (TtsEnded) => void): () => void
const off = client.audio.onTtsEnded((ttsEnded) => {
console.log(ttsEnded.id);
});
// call off() to unsubscribe onVolumeChanged(handler: (VolumeChanged) => void): () => void
const off = client.audio.onVolumeChanged((volumeChanged) => {
console.log(volumeChanged.level);
});
// call off() to unsubscribe Types
shapes referenced above, as the SDK types them
Fired when the companion has begun speaking the TTS request with this
id. May arrive after TtsEnded is dropped (e.g. companion preempted
before speech started); webapps should treat both as best-effort.
type TtsStarted = {
id: string;
}; Fired when the TTS request finished. completed is true when the
full text was spoken; false when preempted, cancelled, or the
companion dropped it.
type TtsEnded = {
id: string;
completed: boolean;
}; Volume / mute snapshot. Fired on any change to either; webapps treat
level as the canonical value.
type VolumeChanged = {
level: number;
muted: boolean;
}; type SetVolume = {
level: number;
}; type SetMute = {
muted: boolean;
}; Fire-and-forget TTS request. id is webapp-assigned (no request
round-trip) and used for cancellation + matching back-to-back
TtsStarted/TtsEnded events. voice selects from
AudioCapabilities.voices; None uses the gateway's default.
type Tts = {
id: string;
text: string;
voice?: string;
}; type TtsCancel = {
id: string;
}; Play a named earcon from AudioCapabilities.earcons. Unknown names
surface as AudioError::EarconNotFound.
type Earcon = {
name: string;
};