CUI

Components / AI interfaces

Voice orb

An animated orb for voice modes that shows listening, thinking and speaking.

Functions: cui_voice_orb

Voice orb

Usage

if (cui_voice_orb(ui, "voice", listening ? CUI_VOICE_LISTENING : CUI_VOICE_IDLE, mic_level)) toggle_listening();

It breathes when idle, ripples with the level while listening, sends a ring of dots around while thinking and swells with the voice while speaking. It moves between states smoothly.

Returns true on the frame the orb is clicked. The orb records and plays nothing: you pass the state and the loudness on every frame, and it only draws them. The state is one of CUI_VOICE_IDLE, CUI_VOICE_LISTENING, CUI_VOICE_THINKING and CUI_VOICE_SPEAKING, and is yours to change, for example on the click. The last argument is the loudness of the microphone or of the voice, from 0 to 1; values outside are clamped, and the orb smooths the changes, so raw peaks can be passed as they come. The library keeps the animation under id. Options: size, the diameter in points (160), and color.

Keyboard

  • Tab focuses the orb, and Enter or Space clicks it.

Options of cui_voice_orb

OptionTypeDefaultDescription
.sizefloatSize in points; 0 uses the component's own.
.colorcui_colorA theme color such as CUI_COLOR_ACCENT, or CUI_RGB(0x7747ff); unset uses the theme's.

Related