The game runs in the player’s browser. Lokutor runs the voices: recognition, the language model, speech and lip sync are on our servers, so the browser only plays sound and sends the microphone.
Export it
- Install the export templates of your Godot version (Editor > Manage Export Templates).
- Project > Export > Add > Web. Leave Thread Support off: the game then needs no special headers on the site and runs inside an iframe.
- In Project Settings:
Godot draws with WebGL 2 in a browser (the Compatibility renderer), whatever the project uses on the desktop. Check your shaders and lights in a web build early; soft shadows and MSAA cost more there than on a desktop.
- Serve the folder over HTTPS (or
http://localhostwhile you develop): browsers give the microphone only to secure pages. The browser asks the player for it the first time it starts. Start the conversation after a click or a tap, as browsers only play sound after the page has been touched.
Keys: none in the build
Whatever is in a web build can be read by anyone who opens the page. Never put a key in it:- On your site, have your server trade the key for a ticket and give the game a
ticket_provider, exactly as in a shipped game. Limit tickets per player on your server. - On lokutor.com, a game needs nothing: in a browser the SDK may open a session with no key at all (
Lokutor.keyless_allowed()), and the server gives a page of lokutor.com its demo, with its limits. Any other site that tries the same is refused withauth.missing_key.
LokutorVoice of the game speaks through one shared connection, so a game takes few of the demo’s sessions.
The demo’s limits
The demo on lokutor.com is bounded: each conversation lasts a few minutes, each visitor has a few minutes a day, and only a few sessions run at once for everyone. The SDK says which limit was reached:LokutorVoice has the same demo_limit signal. The conversation also ends with error_occurred("auth.time_limited", message); the details are in LokutorError.demo_limit.
Tell the page
A game is usually inside a page that has its own buttons and text. In a browser the SDK tells that page what happened, as amessage event: session_limit ({seconds, reason}) when a conversation starts, and demo_limit ({limit, message}) when the demo stops one. Your game can send its own with Lokutor.tell_page(type, data).
Lokutor.page_args() reads the parameters of the page’s address instead (game.html?lang=es&level=1 is {"lang": "es", "level": "1"}), so the page can say which language to start in.
Echo
A laptop’s or a phone’s speakers are a few centimetres from its microphone. In a browser the SDK waits longer for the room’s echo to fade (LokutorVoicePlayer.echo_tail_ms(), 700 ms instead of 250), and the character’s own words coming back are recognised as its echo and not taken for the player’s (guard_against_echo). Keep mute_mic_while_speaking on unless the player says they wear headphones.
Keep the download small
Players wait for all of the game before the first frame. What usually makes a voice game big is its characters’ faces: a blend shape stores every vertex of the mesh, so fifteen visemes and a dozen expressions on a character whose clothes, hat and shoes are in the same mesh multiply all of them.- Cut each character in parts that carry only the shapes that move them: the face, and the rest with none.
LokutorLipSyncdrives any number of meshes (faces). The game kit does it by itself in its web builds, and its characters weigh a fifth. - Leave out what the web version does not need: fewer characters, fewer places, music at a lower rate.
- Drop tangents if your shaders do not use normal maps.
- Serve compressed: the engine’s
.wasmshrinks to a quarter with gzip or Brotli. Two games can share one engine file.
Next
- Godot SDK: characters, actions, lip sync.
- Sample game: Most Suspicious and Not Amused: how they are built.
- Secure browser setup: tickets from your server.