VoiceCommandsAPI

版本 v1.0.0·更新於 2025-11-11

Provides a framework for other mods to create and manage voice commands. Uses Vosk for offline, high-performance speech recognition.

模組介紹 作者原文

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

安裝與使用 安裝:BepInEx 外掛

  1. 本站下載的壓縮包就是模組本體,通常是 BepInEx 外掛(解壓後得到 .dll 或外掛資料夾)。
  2. 建議流程:用社群模組管理器(如 r2modman)選中本遊戲後匯入該模組,管理器會自動裝好 BepInEx 前置並處理依賴。
  3. 手動流程:先在遊戲目錄裝好 BepInEx 載入器,再把解壓出的 .dll 或外掛資料夾放進 BepInEx/plugins/。
  4. 啟動遊戲,BepInEx 控制台會列印載入日誌;確認這個模組出現在日誌裡即為安裝成功。

帶「前置依賴」的模組需要一併安裝,否則不會載入。功能開關通常在遊戲內或外掛自帶的設定檔裡調整。

前置依賴

下面這些內容需要先安裝,否則該模組不會生效:

BepInEx-BepInExPack

檔案與校驗

檔案名稱
VoiceCommandsAPI-1.0.0.zip
檔案大小
50.9 MiB