Package-level declarations
Types
Playback state for AudioPlayer, hoisted so other elements can follow it (e.g. Transcription highlighting the segment being played).
What a voice agent is doing; drives Persona's animation.
An installed speech recognition service.
Where SpeechInput is.
Speech output on the platform text-to-speech engine (Android TextToSpeech): reads a message aloud, or a reply sentence by sentence while it streams (enqueue). One utterance group is active at a time, named by speakingId; stop ends it.
Which of the device's speech engines the voice elements use, and how they speak. Every field defaults to the system's choice, so an app only sets what its user picked (e.g. from recognitionServices and SpeechOutputState.engines in a settings screen).
A timed piece of a transcript.
A text-to-speech voice in VoiceSelector.
Where a VoiceMode conversation is.
Properties
The speech output the elements use: the messages' "Read aloud" and VoiceMode. dev.ai.elements.ui.chat.Conversation creates one when none is provided; provide your own to share one engine across screens.
The speech engines the voice elements (SpeechInput, "Read aloud", VoiceMode) use.
Functions
An audio player for generated speech and recordings (AI Elements <AudioPlayer>): play / pause, ±10 s, a seek bar with times, and speed.
Whether on-device recognition (SpeechSettings.onDeviceRecognition) is offered here.
Pick the microphone (AI Elements <MicSelector>): lists the system's input devices — built-in, wired, Bluetooth, USB — and updates as they are plugged in. null means the system default. Apply the choice with e.g. AudioRecord.setPreferredDevice.
An animated agent presence for voice UIs (AI Elements <Persona>), drawn with Material 3 Expressive shapes instead of a Rive file: it breathes when idle, ripples while listening, morphs through shapes while thinking, pulses with level (0–1, e.g. output loudness) while speaking, and dims asleep. State changes morph from the previous shape.
The speech recognition services installed on the device (needs the <queries> ai-elements-ui declares).
Remembers an AudioPlayerState for source (URL, content:// URI or file path), released with the composition.
Remembers a SpeechInputState on the recognizer of settings; released with the composition.
Remembers a SpeechOutputState on the engine and voice of settings; released with the composition.
markdown as text to read aloud: code blocks, diagrams and math are left out (they are not speakable), links read as their text, and Markdown markers are removed.
Voice input (AI Elements <SpeechInput>): tap to dictate, tap again to stop. onTranscript receives partial text while speaking and the final text (isFinal = true) at the end. With onCancel, dictation shows the input level with cancel (drop what was heard; restore your text in onCancel) and done. Asks for the microphone permission the first time; the host app must declare RECORD_AUDIO in its manifest.
A transcript that follows playback (AI Elements <Transcription>): the segment at currentTimeMs is highlighted, what's already been said stays full-strength, what's ahead is dimmed, and tapping a segment calls onSeek with its start. Consecutive segments from the same TranscriptSegment.speaker form one paragraph.
A hands-free voice conversation over any chat, like the assistant apps' voice mode: it listens (platform speech recognition), sends what the user said to controller, reads the reply aloud sentence by sentence while it streams (platform text-to-speech), then listens again.
Pick a text-to-speech voice (AI Elements <VoiceSelector>): a chip opens a searchable sheet; voices with a VoiceOption.previewUrl can be heard before choosing.