Class Audio
- All Implemented Interfaces:
ContextProvider, PropertyChangeSource, Rebindable
This toolkit is autonomous: it manages its own state for selected devices and implements self-healing defaults on initialization and session restoration.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate AudioDeviceThe selected audio input device for this session.private AudioDeviceThe selected audio output device for this session.Fields inherited from class AnahataToolkit
childrenProviders, propertyChangeSupportFields inherited from class ToolContext
toolkit -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidPerforms initial setup for a newly created toolkit instance.private voidDiscovers and selects the system's default input hardware.private voidDiscovers and selects the system's default output hardware.Plays an audio file from a URI on the selected output device.voidpopulateMessage(RagMessage ragMessage) Populates the givenRagMessagewith dynamic, just-in-time context parts.voidrebind()Rebinds the toolkit after deserialization.Records audio from the selected input device for a specified duration.selectOutputDevice(String deviceId) Selects a specific device for playback for the current session.selectRecordingDevice(String deviceId) Selects a specific device for recording for the current session.voidsetSelectedInputDevice(AudioDevice device) Sets the selected input device and fires a property change event.voidsetSelectedOutputDevice(AudioDevice device) Sets the selected output device and fires a property change event.Methods inherited from class AnahataToolkit
getChildrenProviders, getDescription, getId, getName, getParentProvider, getPropertyChangeSupport, isEffectivelyProviding, postActivateMethods inherited from class ToolContext
addAttachment, addAttachment, addAttachment, error, error, getAgi, getApplicationMap, getAsiContainer, getAsiContainerMap, getCall, getExecutorService, getModelId, getModelMessage, getResourceManager, getResponse, getSessionMap, getThreadSafeLogger, getTool, getToolContext, getToolkit, getToolManager, getTurnMap, isToolExecution, log, peekResponse, runAsyncMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ContextProvider
getAgi, getContextPosition, getFlattenedHierarchy, getFullyQualifiedId, getHeader, getIconId, getInstructionsTokenCount, getRagTokenCount, getSystemInstructions, isProviding, setParentProvider, setProviding
-
Field Details
-
selectedInputDevice
The selected audio input device for this session. -
selectedOutputDevice
The selected audio output device for this session.
-
-
Constructor Details
-
Audio
public Audio()
-
-
Method Details
-
initialize
public void initialize()Performs initial setup for a newly created toolkit instance.This method is called exactly once by the
ToolManagerafter the toolkit has been instantiated and registered. It provides a clean hook for toolkits to perform one-time initialization logic that requires the tool environment to be fully configured, such as scanning for project instructions or registering default resources.Auto-discovers and selects system hardware defaults on startup.
- Overrides:
initializein classAnahataToolkit
-
rebind
public void rebind()Rebinds the toolkit after deserialization.This method is called by the framework during session activation to restore transient state, reconnect listeners, or refresh cached project instances. It ensures the
propertyChangeSupportis re-initialized.Verifies that restored hardware devices still exist on the host.
- Specified by:
rebindin interfaceRebindable- Overrides:
rebindin classAnahataToolkit
-
initInputLineFromDefault
private void initInputLineFromDefault()Discovers and selects the system's default input hardware. -
initOutputLineFromDefault
private void initOutputLineFromDefault()Discovers and selects the system's default output hardware. -
setSelectedInputDevice
Sets the selected input device and fires a property change event.- Parameters:
device- The device to select.
-
setSelectedOutputDevice
Sets the selected output device and fires a property change event.- Parameters:
device- The device to select.
-
populateMessage
Populates the givenRagMessagewith dynamic, just-in-time context parts. These parts are appended to the end of the user's prompt (RAG).- Parameters:
ragMessage- The message to be augmented with context.- Throws:
Exception- if an error occurs during context generation.
-
selectRecordingDevice
-
selectOutputDevice
-
record
Records audio from the selected input device for a specified duration.- Parameters:
durationSeconds- Duration of the recording in seconds.deviceId- Optional specific device ID (overrides session selection).- Returns:
- A status message.
- Throws:
Exception- if hardware access fails.
-
play
-

