-
Notifications
You must be signed in to change notification settings - Fork 0
api
These are the commands the Svelte frontend (or any Tauri WebView) can call via invoke().
Source: src-tauri/src/commands.rs
import { invoke } from '@tauri-apps/api/core';Returns the current application state.
const status = await invoke<StatusPayload>('get_status');interface StatusPayload {
recording: boolean;
processing: boolean;
speaking: boolean;
mcp_recording: boolean;
audio_ready: boolean;
word_count: number;
active_target_id: string;
active_target_label: string;
}Sets the recording flag to true. The audio pipeline will start capturing.
await invoke('start_recording');Sets the recording flag to false, signaling the audio pipeline to stop.
await invoke('stop_recording');Toggles recording state. Returns the new recording state.
const nowRecording = await invoke<boolean>('toggle_recording');Returns the full application configuration.
const config = await invoke<AppConfig>('get_config');Persists configuration to ~/.config/voxctrl/config.json and emits a config-changed event to all windows.
await invoke('save_config', { newConfig: myConfig });Note the parameter name is newConfig (camelCase), not config.
Returns all output targets from targets.toml.
const targets = await invoke<OutputTarget[]>('get_targets');Writes updated targets to targets.toml, updates the in-memory cache, hot-reloads the router, and spawns any new FIFO response pipe listeners.
await invoke('save_targets', { targets: myTargets });Returns all hotkey bindings from bindings.toml.
const bindings = await invoke<HotkeyBinding[]>('get_bindings');Writes updated bindings to bindings.toml and sends a hot-reload signal to the hotkey listener thread.
await invoke('save_bindings', { bindings: myBindings });Returns the transcription history (in-memory, current session only).
const history = await invoke<HistoryEntry[]>('get_history');interface HistoryEntry {
text: string;
target_id: string;
timestamp: string; // ISO 8601
inference_ms: number;
}Clears the in-memory history log and resets the word count.
await invoke('clear_history');Queues text for TTS playback.
await invoke('speak_text', { text: 'Hello world', voice: 'en-us-lessac-medium' });voice is optional — omit to use the configured default.
Returns whether a Piper voice pack is available locally.
const downloaded = await invoke<boolean>('check_voice_downloaded', {
voiceName: 'en-us-lessac-medium'
});Downloads a Piper voice pack from GitHub.
await invoke('download_voice', { voiceName: 'en-us-ryan-high' });Returns whether a Whisper model GGUF file is present locally.
const downloaded = await invoke<boolean>('check_model_downloaded', { modelSize: 'base' });Downloads a Whisper GGUF model.
await invoke('download_model', { modelSize: 'small' });Valid sizes: "tiny", "tiny.en", "base", "base.en", "small", "small.en", "medium", "medium.en", "large-v2", "large-v3", "large-v3-turbo"
Enables the monitoring flag so audio-level events are emitted for the VU meter.
await invoke('start_monitoring_audio');Disables monitoring and stops audio-level event streaming.
await invoke('stop_monitoring_audio');Returns all available input devices.
const devices = await invoke<AudioDeviceInfo[]>('list_audio_devices');interface AudioDeviceInfo {
index: number;
name: string;
}Pings an Ollama endpoint and lists available models.
const result = await invoke<OllamaTestResult>('test_ollama', {
endpoint: 'http://localhost:11434',
timeoutSecs: 5
});interface OllamaTestResult {
success: boolean;
message: string;
models: string[];
}Makes the overlay window visible and sets always-on-top.
await invoke('show_overlay');Hides the overlay window.
await invoke('hide_overlay');Subscribe with listen() from @tauri-apps/api/event.
import { listen } from '@tauri-apps/api/event';Emitted every ~250ms with the current application state.
await listen<AppStatus>('status-tick', (event) => {
console.log(event.payload.recording);
});Emitted when the config is saved (from any window or external change).
await listen<AppConfig>('config-changed', (event) => {
config.set(event.payload);
});Emitted during monitoring with the current RMS energy level (0.0–1.0+).
await listen<number>('audio-level', (event) => {
updateVuMeter(event.payload);
});These types are defined in src/stores/config.ts:
interface AppConfig {
engine: EngineConfig;
audio: AudioConfig;
ui: UiConfig;
features: FeaturesConfig;
ollama: OllamaConfig;
tts: TtsConfig;
mcp: McpConfig;
atspi: AtspiConfig;
}
interface EngineConfig {
backend: "auto" | "whisper-cpp" | "moonshine";
inference_mode: "Balanced" | "Aggressive";
whisper_cpp: WhisperCppConfig;
moonshine: MoonshineConfig;
}
interface WhisperCppConfig {
model_dir: string;
model_size: string;
device: string;
threads: number;
}
interface MoonshineConfig {
model_size: string;
language: string;
}
interface AudioConfig {
vad_threshold: number;
min_silence_duration_ms: number;
input_device_index: number | null;
evdev_device: string | null;
noise_suppression: boolean;
gain: number;
dynamic_stream: boolean;
}
interface UiConfig {
show_overlay: boolean;
overlay_style: "voice_card" | "waveform" | "pulse" | "blue_wave" | "none";
auto_show_settings: boolean;
show_notification: boolean;
history_enabled: boolean;
}
interface FeaturesConfig {
remove_fillers: boolean;
custom_vocabulary: string[];
spoken_punctuation: boolean;
auto_format_lists: boolean;
quiet_mode: boolean;
snippets: Record<string, string>;
}
interface OllamaConfig {
enabled: boolean;
model: string;
mode: "clean" | "formal" | "casual" | "bullet" | "concise" | "custom";
custom_prompt: string | null;
endpoint: string;
timeout_secs: number;
}
interface TtsConfig {
enabled: boolean;
engine: "piper" | "espeak";
voice: string;
stop_key: string[]; // singular field name, plural value
response_overlay: boolean;
}
interface McpConfig {
server_enabled: boolean; // not "enabled"
record_timeout: number;
visual_feedback: boolean;
}
interface AtspiConfig {
injection: boolean; // not "enabled"
context_prompt: boolean;
auto_code_mode: boolean;
}
interface OutputTarget {
id: string;
label: string;
delivery: "inject" | "clipboard" | "exec" | "pipe" | "socket" | "file" | "dbus" | "http" | "webhook" | "mcp";
// exec
command?: string;
// pipe
pipe_path?: string;
// socket (unix or TCP)
socket_unix?: string;
socket_host?: string;
socket_port?: number;
// file
file_path?: string;
file_prefix: string;
file_timestamp: boolean;
file_mode: string; // "append" or "write"
// dbus
dbus_signal?: string;
// http
http_url?: string;
http_method: string;
// webhook (note: webhook_url, not http_url)
webhook_url?: string;
webhook_secret?: string;
// mcp
mcp_path?: string;
mcp_tool?: string;
send_on_release: boolean; // default: true
append_newline: boolean; // default: true
strip_newlines: boolean; // default: false
initial_prompt?: string;
processing: TargetProcessingConfig;
tts_engine: string;
tts_voice?: string;
response_pipe?: string;
}
interface TargetProcessingConfig {
noise_suppression?: boolean;
quiet_mode?: boolean;
atspi_context?: boolean;
remove_fillers?: boolean;
spoken_punctuation?: boolean;
auto_format_lists?: boolean;
apply_snippets?: boolean;
code_mode?: boolean;
ollama_enabled?: boolean;
ollama_model?: string;
ollama_mode?: string;
ollama_prompt?: string;
}
interface HotkeyBinding {
id: string;
label: string;
keys: string[];
gesture: "hold" | "toggle" | "double_tap" | "double_tap_hold" | "chord";
target_id: string;
target_ids: string[];
tap_ms: number; // default: 250
hold_threshold_ms: number;// default: 200
subkey?: string; // Optional subkey trigger for chord gesture
disabled: boolean;
}
interface AppStatus {
recording: boolean;
processing: boolean;
speaking: boolean;
mcp_recording: boolean;
audio_ready?: boolean;
word_count: number;
active_target_id?: string;
active_target_label?: string;
}
interface HistoryEntry {
text: string;
target_id: string;
timestamp: string;
inference_ms: number;
}