Preview, version 0.2.0. Tell us what your game needs at [email protected].
What you need
- Unity 2021.3 or newer, Mono or IL2CPP.
- A Lokutor API key, from app.lokutor.com.
- A microphone. Headphones while you try it, so the character does not hear itself.
System.Net.WebSockets nor the Microphone class): for a web page use the JavaScript SDK.
Install
1
Add the package
Window > Package Manager > + > Add package from git URL:
2
Ask for the microphone on mobile
Add a microphone usage description (iOS: Player Settings > Microphone Usage Description).
Your first character
1
Add the component
Select your character and Add Component > Lokutor > Lokutor Agent. It comes with an AudioSource, and the voice comes from where the GameObject is, so the head is a good place.
2
Paste your API key
In Api Key. Leave it empty to use
LokutorAgent.DefaultApiKey or the LOKUTOR_API_KEY environment variable, which keeps the key out of your scenes. Never ship a game with a key inside: see Shipping.3
Say who it is
Write 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.
Events
onCharacterSaid carries what the character is about to say, with the expression tags the voice performs ([laugh]); LokutorApi.StripTags 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 Awake and:onReconnecting, then onReconnected). The new session does not remember the old one: the facts of SetContext are sent again, what was said is not. If it cannot be opened, or the server ends it, onConversationEnded 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. Muted = true is the player’s own mute button. Microphone Device picks another microphone.
The voice
It plays through the AudioSource: its mixer group, distances and effects are yours. Spatial Voice places it in 3D; 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.SetContext 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. TicketProvider is called on the main thread before every connection, reconnections included:
Next
- Actions: let the character do things in the game.
- Lip sync: blend shapes, jaws, 2D mouths.
- Speech: written lines, text to speech and speech to text.
- API reference: every type and member.
- Game characters: what makes one feel alive.