Skip to main content
Version 0.2.0, Godot 4.3 or newer. Install it as in Godot: introduction. The names match the JavaScript and Python SDKs; the parity table puts the four side by side. Methods marked with await are coroutines. Signals are emitted on the main thread.

LokutorAgent

extends Node3D Makes its parent character a voice agent: it listens through the microphone, answers in its own voice from where it stands (3D audio), moves its mouth, and calls your game’s functions (“actions”) when the conversation calls for it.

LokutorAgent properties

Account (in the Inspector) Character (in the Inspector) Voice (in the Inspector) Microphone (in the Inspector) Lip sync (in the Inspector) Game actions (in the Inspector) From code

LokutorAgent signals

LokutorAgent methods

add_action(action_name: String, description: String, handler: Callable, params: Dictionary = {}) -> void

Lets the character call a game function. params maps each argument to a description ({"item": "Which item"}) or to a JSON-schema dictionary ({"item": {"type": "string", "enum": [...]}}). The handler receives a Dictionary of arguments and returns a short sentence saying what happened; it may await. Works before or during a conversation.

remove_action(action_name: String) -> void

The character can no longer call it.

start_conversation() -> void

Opens the conversation: the character greets the player and starts listening.

stop_conversation() -> void

Ends the conversation and releases the microphone.

set_persona(new_persona: String) -> void

Changes who the character is, mid-conversation.

set_context(key: String, value) -> void

Tells the character something about the game right now ("Time left", "20 seconds"), without rewriting its persona. A value of null takes it out. Changes in the same quarter second are sent together. A dashboard agent needs a persona for this: its own prompt cannot be extended from the game.

set_voice(new_voice: String) -> void

Changes the voice, mid-conversation.

set_language(new_language: String) -> void

Changes the language, mid-conversation. "auto": the character follows the language the player speaks.

set_pitch(new_pitch: float) -> void

Shifts the voice up or down, mid-conversation.

reset_conversation() -> void

Forgets the conversation so far: the character starts fresh.

get_transcript() -> Array

The conversation so far, or the last one: [{role, text, timestamp}].

set_talking(talking: bool) -> void

Push-to-talk from any input: true while the player holds the button.

feed_microphone(samples: PackedFloat32Array, rate: int) -> void

Sends audio you captured yourself (mono floats at rate), e.g. from another source or another character.

heard_seconds() -> float

How much of the current reply has been heard, in seconds: the clock visemes are read against.

voice_level() -> float

Loudness of the character’s voice right now, 0 to 1.

is_echo(heard: String) -> bool

Whether heard is the character’s own recent words coming back through the microphone: three words or more, and three in four of them among what it said in its last replies. guard_against_echo uses it.

LokutorAgent.State

What the conversation is doing. Values: DISCONNECTED, CONNECTING, READY, PLAYER_TALKING, THINKING, SPEAKING.

LokutorAgent.MicMode

When the character hears the player. Values: ALWAYS, PUSH_TO_TALK, OFF.

LokutorAction

extends Resource A game action set up in the Inspector: when the character decides to use it, method is called on the node at target. See Actions.

LokutorAction properties

LokutorLipSync

extends Node Moves a mouth with a voice. Give it a face (blend shapes), a jaw, or a 2D sprite with mouth frames; LokutorAgent and LokutorVoice feed it visemes and the clock of what is being heard. See Lip sync.

LokutorLipSync properties

Blend shapes (in the Inspector) Jaw (in the Inspector) 2D (in the Inspector) Feel (in the Inspector) From code

LokutorLipSync signals

LokutorLipSync methods

bind() -> void

Finds the blend shapes again, after changing faces or mapping at runtime.

rig() -> Rig

Which kind of mouth was found.

push_visemes(list: Array, source: Object = null) -> void

The visemes of the reply being heard, as they arrive: [{v, t, d}]. source is whose voice it is, when several share the mouth.

clear(source: Object = null) -> void

A new reply, or silence: the mouth closes. Without a source, whoever is speaking.

has_visemes() -> bool

Whether the voice being heard has visemes. Without them the mouth follows the loudness.

release(source: Object = null) -> void

This voice is gone: the mouth closes, or follows another.

advance(heard: float, level: float, speaking: bool, delta: float, source: Object = null) -> void

One frame of the mouth. heard is how much of the reply has been heard (LokutorVoicePlayer.heard_seconds()), level its loudness, speaking whether it is playing at all. Called for you by LokutorAgent and LokutorVoice.

LokutorLipSync.Rig

The kinds of mouth it finds in a face. Values: NONE, VISEMES, VRM, ARKIT, MOUTH_OPEN, CUSTOM.

LokutorLipSync constants

LokutorVoice

extends Node3D A character that says written lines (barks, narration, tutorials): text to speech played from its place in the world, with lip sync. Lines are kept on disk, so a line said again costs nothing and starts at once. See Speech.

LokutorVoice properties

Account (in the Inspector) Voice (in the Inspector) Lip sync (in the Inspector) From code

LokutorVoice signals

LokutorVoice methods

say(text: String, options: Dictionary = {}) -> bool

Says a line; with await, returns when it has been heard (true) or could not be said (false). Lines wait for each other. Options override the voice for this line: voice, language, interrupt (say it now, dropping what is being said).

stop() -> void

Stops at once and forgets the lines waiting.

preload_lines(lines: PackedStringArray, options: Dictionary = {}) -> void

Fetches lines before they are needed, so they start at once and, once kept, work without a network. Use it with await.

has_line(text: String, options: Dictionary = {}) -> bool

Whether a line is already on disk.

save_lines_to(folder: String, lines: PackedStringArray, options: Dictionary = {}) -> void

Keeps lines in a project folder (run it from the editor or a tool script): set cache_dir to it and ship the game with its lines recorded. Use it with await.

LokutorVoiceAgentClient

extends Node A voice conversation over /ws/agent, with the same options, methods and events as VoiceAgentClient in the JavaScript and Python SDKs. Add it to the tree and call open(). For a character in a scene use LokutorAgent, which adds the microphone, the 3D voice, lip sync and actions on top of this. Use this one when you want the conversation and nothing else. Two names differ from JavaScript because Godot’s Object already has them: connect() is open() and disconnect() is close().

LokutorVoiceAgentClient properties

LokutorVoiceAgentClient signals

LokutorVoiceAgentClient methods

static create(config: Dictionary) -> LokutorVoiceAgentClient

A client from a dictionary of options, as in JavaScript: LokutorVoiceAgentClient.create({"api_key": key, "prompt": "You are Mira.", "voice": "F2", "visemes": true}). Add it to the tree.

configure(config: Dictionary) -> LokutorVoiceAgentClient

Sets options by name. on_transcription, on_response, on_audio, on_visemes, on_status and on_error connect a callback.

open() -> bool

Opens the session and sends the configuration. Returns true once connected, false if it could not (the reason is emitted as error). Use it with await.

close() -> void

Ends the session and releases the microphone.

start_managed() -> bool

Runs the microphone and the speaker too: a whole conversation in one call. Use it with await.

send_audio(pcm16: PackedByteArray) -> void

Sends microphone audio: 16-bit PCM, 16 kHz, mono. Keep sending it (silence too): the server measures pauses in it.

send_audio_float(samples: PackedFloat32Array, rate: int) -> void

The same from float samples at any rate.

update_prompt(new_prompt: String) -> void

Replaces the prompt, mid-session.

update_voice(new_voice: String) -> void

Changes the voice, mid-session.

update_language(new_language: String) -> void

Changes the language, mid-session.

update_tools(new_tools: Array) -> void

Replaces the tools, mid-session.

update_pitch(new_pitch: float) -> void

Shifts the voice’s pitch for the rest of the session.

update_visemes(enabled: bool) -> void

Asks for visemes, or stops asking, from the next reply on.

reset() -> void

Clears the conversation: the agent starts fresh.

submit_tool_result(call_id: String, result) -> void

Answers a tool_call. result is a String, or anything JSON can carry.

get_transcript() -> Array

The conversation so far: [{role, text, timestamp}], timestamp in milliseconds (Time.get_ticks_msec()).

get_transcript_text() -> String

The same as text, a line each.

toggle_mute() -> bool

Mutes or unmutes the managed microphone; returns whether it is now muted.

get_amplitude() -> float

The managed microphone’s loudness, 0 to 1.

static fetch_voices(base_url: String = Lokutor.VOICE_AGENT_URL) -> Array

As Lokutor.fetch_voices(). Use it with await.

static fetch_languages(base_url: String = Lokutor.VOICE_AGENT_URL) -> Array

As Lokutor.fetch_languages(). Use it with await.

static fetch_models(base_url: String = Lokutor.VOICE_AGENT_URL) -> Array

As Lokutor.fetch_models(). Use it with await.

static fetch_config(base_url: String = Lokutor.VOICE_AGENT_URL) -> Dictionary

As Lokutor.fetch_config(). Use it with await.

static fetch_status(base_url: String = Lokutor.VOICE_AGENT_URL) -> Dictionary

As Lokutor.fetch_status(). Use it with await.

static fetch_health(base_url: String = Lokutor.VOICE_AGENT_URL) -> Dictionary

As Lokutor.fetch_health(). Use it with await.

config_messages() -> Array

The configuration sent on connect, in order. rates is last: it starts the conversation.

handle_message(text: String) -> void

Handles one message from the server. Public so tests can feed it.

static normalize_visemes(payload) -> Array

[{v, c, t, d}] from what the server sends. A missing duration lasts until the next one starts.

LokutorVoiceAgentClient constants

LlmReply

extends RefCounted The reply of your own model to one llm_request. Stop when cancelled turns true: the player spoke over it.

LlmReply properties

LlmReply methods

chunk(text: String) -> void
More text. Lokutor starts speaking at the first sentence.
tool_call(tool_name: String, arguments, id := "") -> void
One of the agent’s tools to call. arguments is a JSON string, or anything JSON can carry.
done() -> void
The reply is complete. Returning from the handler does it for you.
fail(message: String) -> void
The model failed: the agent is told so.

LokutorTTSClient

extends Node Text to speech over /ws/tts, as TTSClient in the JavaScript and Python SDKs. Add it to the tree. For a character that says written lines use LokutorVoice, which plays them and moves the mouth.

LokutorTTSClient properties

LokutorTTSClient signals

LokutorTTSClient methods

synthesize(text: String, options: Dictionary = {}) -> Dictionary

Speaks text and returns {ok, audio, sample_rate, visemes, error} when it is complete; audio and visemes are also emitted as they arrive. Requests run one after another. Options: voice, language, speed, steps, visemes, temperature, dictionary_ids, pronunciations; the callbacks on_audio, on_visemes, on_ttfb, on_error; and ticket, any RefCounted of yours to cancel(ticket) this request alone. Use it with await.

cancel(ticket: RefCounted = null) -> void

Stops the request being spoken and forgets the ones waiting. With the ticket given to synthesize(), only that one.

close() -> void

Cancels, and closes the connection.

handle_message(text: String) -> void

Handles one text frame. Public so tests can feed it.

LokutorTTSClient constants

LokutorSTTClient

extends RefCounted Transcribes one complete recording (POST /stt/transcribe), as STTClient in the JavaScript and Python SDKs. For speech as it happens use LokutorSpeechToTextClient.

LokutorSTTClient properties

LokutorSTTClient methods

transcribe(audio: PackedByteArray, options: Dictionary = {}) -> Dictionary

audio is 16-bit PCM mono (give sample_rate) or a whole WAV file’s bytes. Options: sample_rate, format ("pcm16" or "wav"), language, keyterms. Returns {ok, text, latency_ms, engine, sample_rate, language, duration_seconds, segments, error}. Use it with await.

LokutorSpeechToTextClient

extends Node Speech to text as the player talks, over /ws/stt: voice commands, dictation, captions. No language model and no voice. As SpeechToTextClient in the JavaScript SDK. Add it to the tree and call open().

LokutorSpeechToTextClient properties

LokutorSpeechToTextClient signals

LokutorSpeechToTextClient methods

open() -> bool

Connects and starts listening. True once connected. Use it with await.

close() -> void

Ends the session and releases the microphone.

send_audio(pcm16: PackedByteArray) -> void

16-bit PCM, 16 kHz, mono. Keep sending silence: the end of an utterance is measured in it.

end_utterance() -> void

Finishes whatever is being said now.

handle_message(text: String) -> void

Handles one message. Public so tests can feed it.

LokutorMicrophone

extends Node The player’s microphone as 16 kHz PCM, ready to send. Needs Project Settings > Audio > Driver > Enable Input (enabling the plugin turns it on).

LokutorMicrophone properties

LokutorMicrophone signals

LokutorMicrophone methods

start() -> bool

Starts capturing. false when the project has no audio input.

stop() -> void

Releases it.

static devices() -> PackedStringArray

The microphones of this computer. Choose one with AudioServer.input_device.

LokutorVoicePlayer

extends Node3D Plays a voice as it arrives and knows, to a few milliseconds, how much of it has been heard: lip sync and the microphone’s echo guard run on that clock, not on the network’s.

LokutorVoicePlayer properties

LokutorVoicePlayer signals

LokutorVoicePlayer methods

begin(new_generation: int) -> void

A new reply begins: what was queued of the previous one is dropped, and time counts from 0.

push(pcm16: PackedByteArray, for_generation: int = generation) -> void

Queues voice (16-bit PCM, mono, at rate). Audio of an older reply is ignored.

clear() -> void

Stops at once and forgets what was queued.

is_playing() -> bool

Voice is waiting or playing.

queued_seconds() -> float

Voice waiting to be given to the sound card, in seconds.

is_audible() -> bool

The voice can still reach the microphone: waiting, in the sound card’s buffers, or echoing in the room.

static echo_tail_ms() -> int

How long the room’s echo lasts here: ECHO_TAIL_MOBILE_MS on a phone or in a web browser, ECHO_TAIL_MS anywhere else.

heard_seconds() -> float

How much of the current reply has been heard, in seconds: the clock viseme times are read against.

LokutorVoicePlayer constants

Lokutor

extends RefCounted Constants and helpers shared by the Lokutor nodes: voices, languages, visemes, addresses, and the public discovery endpoints, which need no API key.

Lokutor properties

Lokutor methods

static keyless_allowed() -> bool

Whether a session may open with no key at all: in a web browser, where the server decides. Lokutor’s own pages (lokutor.com) get its bounded demo; every other site is refused with auth.missing_key.

static page_args() -> Dictionary

In a browser, the parameters of the page’s address (?lang=es&level=1 is {"lang": "es", "level": "1"}); elsewhere {}. A web build has no command line: this is where a game’s options come from there.

static tell_page(type: String, data: Dictionary = {}) -> void

In a browser, tells the page the game is embedded in (or its own page) what happened, as a message event with {source: "lokutor", type, ...data}. The SDK sends "session_limit" {seconds, reason} and "demo_limit" {limit, message} by itself. Elsewhere it does nothing.

static language_to_wire(language: String) -> String

The value the protocol carries for a language: "auto" and "" are both "" (follow the player).

static strip_tags(text: String) -> String

A line without the expression tags the voice performs ([laugh], [sad]…), for subtitles.

static viseme_id(viseme_name: String) -> int

The id (0-14) of a viseme name, whatever its case; 0 (closed) for an unknown one.

static http_origin(url: String) -> String

ws://host/path becomes http://host.

static fetch_voices(base_url: String = VOICE_AGENT_URL) -> Array

Voices the API offers: [{id, name, gender, languages}]. Use it with await.

static fetch_languages(base_url: String = VOICE_AGENT_URL) -> Array

Languages the API offers: [{code, name}]. Use it with await.

static fetch_models(base_url: String = VOICE_AGENT_URL) -> Array

Speech models: [{name, description, default}]. Use it with await.

static fetch_config(base_url: String = VOICE_AGENT_URL) -> Dictionary

Request limits and defaults: {max_text_length, min_speed, max_speed, min_steps, max_steps, sample_rate, channels}. Use it with await.

static fetch_status(base_url: String = VOICE_AGENT_URL) -> Dictionary

Runtime status of the service. Use it with await.

static fetch_health(base_url: String = VOICE_AGENT_URL) -> Dictionary

Readiness (GET /ready): {ready, status}. Use it with await.

static request_json(url: String, method := HTTPClient.METHOD_GET, headers := PackedStringArray(), body := "", timeout := 15.0) -> Dictionary

One HTTP request. Returns {ok, status, body, error, result}: body is the parsed JSON, error a LokutorError or null, result what HTTPRequest said (HTTPRequest.RESULT_*). Use it with await.

Lokutor constants

LokutorAudio

extends RefCounted Audio helpers, named as in the JavaScript and Python SDKs.

LokutorAudio methods

static pcm16_to_float32(pcm: PackedByteArray) -> PackedFloat32Array

16-bit PCM to floats, -1 to 1.

static float32_to_pcm16(samples: PackedFloat32Array) -> PackedByteArray

Floats to 16-bit PCM, clipped.

static calculate_rms(samples: PackedFloat32Array) -> float

Loudness (root mean square).

static normalize_audio(samples: PackedFloat32Array, target_peak := 0.95) -> PackedFloat32Array

The same audio, scaled so its loudest sample is target_peak.

static resample(samples: PackedFloat32Array, from_rate: int, to_rate: int) -> PackedFloat32Array

A whole recording at another rate.

static wav_bytes(pcm: PackedByteArray, rate: int) -> PackedByteArray

A whole PCM16 mono recording as a WAV file’s bytes.

StreamResampler

extends RefCounted Streaming mono resampler: audio can be pushed in blocks of any size and its phase is kept across them. Downsampling averages the input over each output step, which is enough anti-aliasing for speech.

StreamResampler properties

StreamResampler methods

reset() -> void
Forgets the phase: the next block starts a new stream.
process(input: PackedFloat32Array) -> PackedFloat32Array
The next block, resampled.

LokutorError

extends RefCounted An error from the API or the SDK. code is one of the error codes, the same as in the JavaScript and Python SDKs.

LokutorError properties

LokutorError methods

static from_server(data) -> LokutorError

From a server’s error payload: {code, message, detail, retryable}, or a plain string.

static demo_limit(reason: String) -> String

Which of the lokutor.com demo’s limits a connection’s close reason names: "call", "daily", "busy", or "" for none.

static from_demo_close(reason: String) -> LokutorError

The demo’s refusal or end as an error: auth.time_limited, with demo_call, demo_daily or demo_busy in detail (only demo_daily is not retryable today). Null when the reason is not one of the demo’s.

LokutorError constants