Skip to main content
A Godot game with Lokutor characters runs in a web browser: the engine is WebAssembly, the microphone is the browser’s, and the characters talk to the same API. Most Suspicious and Not Amused are playable on lokutor.com, made exactly as this page says.
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

  1. Install the export templates of your Godot version (Editor > Manage Export Templates).
  2. Project > Export > Add > Web. Leave Thread Support off: the game then needs no special headers on the site and runs inside an iframe.
  3. 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.
  1. Serve the folder over HTTPS (or http://localhost while 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 with auth.missing_key.
With no key, every 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 a message 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).
A web build has no command line. 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. LokutorLipSync drives 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 .wasm shrinks to a quarter with gzip or Brotli. Two games can share one engine file.
The two sample games download 60 and 90 MB the first time, a 40 MB engine included (about 25 and 50 MB compressed), against several hundred MB on the desktop. A browser keeps them in its cache for the next visit.

Next