Skip to main content
Preview, version 0.2.0. Tell us what your game needs at [email protected].
The Lokutor addon makes a character of your game a voice agent: it listens through the player’s microphone, answers in its own voice from where it stands, moves its mouth, and calls your game’s functions. It is plain GDScript, so there is nothing to compile.

What you need

  • Godot 4.3 or newer.
  • A Lokutor API key, from app.lokutor.com.
  • A microphone. Headphones while you try it, so the character does not hear itself.
It works on Windows, macOS, Linux, Android, iOS and in web browsers (Games in a web browser). For a web page that is not a Godot game, use the JavaScript SDK.

Install

1

Copy the addon

Copy godot/addons/lokutor into your project’s addons/ folder.
2

Enable it

Project > Project Settings > Plugins > Lokutor Voice Agents > Enable. This turns on Audio > Driver > Enable Input, which Godot leaves off and the microphone needs.
3

Ask for the microphone on export

Android: tick the Internet and Record Audio permissions in the export preset. macOS and iOS: fill in the preset’s microphone usage description.

Your first character

1

Add the node

Select your character and add a child node, LokutorAgent. It is a Node3D and the voice comes from where it is, so the head is a good place.
2

Paste your API key

In Account > Api Key. Leave it empty to read the LOKUTOR_API_KEY environment variable, which keeps the key out of your scene files. Never ship a game with a key inside: see Shipping.
3

Say who it is

Write Character > Persona, and pick a Voice (F1-F5, M1-M5, or a voice from your dashboard) and a Language. auto follows the language the player speaks.
4

Press Play and talk

The character greets the player and listens.
Two demos come with the godot/ folder, which is a project of its own: Brom’s Forge (demo/forge/), a blacksmith you can talk to and buy from, and demo/brom_demo.tscn, the smallest complete example.

Events

character_said carries what the character is about to say, with the expression tags the voice performs ([laugh]); Lokutor.strip_tags() takes them out.

Start and stop

A conversation is billed while it is open (Pricing), so open it when the player engages. Turn off Start On Ready and:
While it is open you can change who the character is and what it knows:
When the connection drops it is opened again by itself (reconnecting, then reconnected). The new session does not remember the old one: set_context is sent again, what was said is not. If it cannot be opened, or the server ends it, conversation_ended says why.

Microphone

Mute Mic While Speaking (on) sends silence while the character’s voice can still reach the microphone, so laptop speakers do not make it interrupt itself, and while another character or a LokutorVoice is heard, so that it does not answer them. Turn it off when players wear headphones and you want them to be able to interrupt. If they do not, and the character hears its own words come back from the speakers, they are not taken for the player’s: guard_against_echo drops them, emits echo_heard and turns mute while speaking back on. muted = true is the player’s own mute button. Godot picks the microphone with AudioServer.input_device; LokutorMicrophone.devices() lists them.

The voice

spatial_voice places it in 3D at the node. voice_bus sends it to an audio bus (put a radio, a cave or a giant’s chest there), and voice_output plays it through your own player, which is how a 2D game uses an AudioStreamPlayer2D. pitch shifts it up or down.

A dashboard agent

To use an agent built in the dashboard (prompt, voice, knowledge, tools), set Agent Id and empty Persona, Voice and Language: whatever you leave in them overrides the dashboard. set_context needs a persona in the game, because a dashboard prompt cannot be extended from it.

Shipping

A key inside a game build can be extracted. Have your server trade it for a ticket that lasts ten minutes (POST /ws-ticket) and give the agent that. ticket_provider is called before every connection, reconnections included:
Return an empty string when there is no ticket: the conversation ends with auth.missing_key instead of waiting. The same property exists on LokutorVoice. A web build is shipped the same way: the browser asks your server for the ticket. Games in a web browser has the rest (export settings, microphone, download size).

Next