VoiceCommandsAPI
Provides a framework for other mods to create and manage voice commands. Uses Vosk for offline, high-performance speech recognition.
About this mod Author’s original text
VoiceCommandsAPI for Lethal Company
A powerful, lightweight, and offline voice command framework for Lethal Company modders.
This mod provides a simple yet flexible API that allows other mods to easily implement voice commands using the high-performance Vosk offline speech recognition engine.
Key Features
- 100% Offline: All voice processing happens on your computer. No internet connection is required, ensuring maximum performance and privacy.
- Easy-to-Use API: Designed for developers to integrate in minutes. Register simple commands or complex patterns with minimal code.
- High Performance: Built on the Vosk engine, which is optimized for low-latency, real-time recognition.
- Flexible Matching: Supports both exact phrase matching (e.g., "open door") and flexible pattern matching (e.g., matching any phrase that starts with "tell the ship...").
- Dependency-Based: Acts as a central framework, so multiple mods can use voice commands without conflicting.
For Players
What This Mod Does
This mod is a dependency or framework. On its own, it does nothing. Its purpose is to provide the underlying technology for other mods that want to use voice commands.
You only need to install this mod if another mod lists it as a requirement.
Installation
- Install BepInEx: Make sure you have the BepInExPack installed.
- Install the API: Use a mod manager like r2modman or the Mod Manager to install VoiceCommandsAPI. Alternatively, you can download it from the releases page and place the VoiceCommandsAPI.dll and vosk-model-small-en-us-0.15 folder into your BepInEx/plugins directory.
For Developers
How to Use the API
Integrating voice commands into your mod is straightforward.
- Add the Dependency
First, add VoiceCommandsAPI to your manifest.json dependencies:
{
"name": "YourCoolMod",
"version_number": "1.0.0",
"website_url": "",
"description": "My mod that uses voice commands!",
"dependencies": [
"BepInEx-BepInExPack-5.4.2100",
"DumbassStuff-VoiceCommandsAPI-1.0.0"
]
}
Next, add a reference to the VoiceCommandsAPI.dll in your C# project.
- Access the CommandManager
The API is accessed through the CommandManager singleton instance.
using VoiceCommandsAPI.API;
- Registering Commands
You can register commands in your plugin's Awake() method. There are two primary ways to register a command.
A) Registering an Exact Phrase
Use this for simple commands where the user must say the exact phrase. The matching is case-insensitive.
// In your plugin's Awake() method
// The phrase to listen for (will be converted to lowercase)
string commandPhrase = "open the blast doors";
// The action to execute when the phrase is recognized
Action commandAction = () => {
HangarShipDoor.Instance.PlayDoorAnimation(true);
MyLogger.LogInfo("Voice command 'open the blast doors' executed!");
};
// Register the command
CommandManager.Instance.RegisterCommand(commandPhrase, commandAction);
B) Registering a Pattern
Use this for more complex commands where you want to match a pattern or extract values from the speech. The handler receives the recognized text as a parameter.
// In your plugin's Awake() method
// 1. The matcher function: returns true if the text matches your pattern.
// In this example, we check if the command starts with "scan for ".
Func matcher = (text) => text.StartsWith("scan for ");
// 2. The handler function: contains the logic to execute.
// It receives the full recognized text.
Action handler = (text) => {
// Extract the target from the recognized text
string target = text.Substring("scan for ".Length);
MyLogger.LogInfo($"Executing scan for target: {target}");
// Add your custom logic here, e.g., ping a specific scrap item
};
// Register the pattern
CommandManager.Instance.RegisterPattern(matcher, handler);
- Subscribing to Events (Optional)
The CommandManager also exposes events for more advanced use cases, such as providing UI feedback.
// Get feedback on partially recognized text (e.g., for a "Lis
Install & use Install: BepInEx plugin
- The archive from playbuff is the mod itself — usually a BepInEx plugin (a .dll or a plugin folder once unzipped).
- Recommended: use a community mod manager (such as r2modman) — pick this game, import the mod, and the manager sets up BepInEx and its dependencies for you.
- Manual route: install the BepInEx loader in the game folder, then drop the unzipped .dll or plugin folder into BepInEx/plugins/.
- Launch the game — the BepInEx console logs every plugin it loads; seeing this mod in the log means it is installed.
Mods with listed dependencies need those installed too, or they will not load. Options are usually changed in-game or in the plugin's config file.
Install these first, or the mod will not work: