WhisperLib

WhisperLib

一个VoskLib的分支,使用WhisperAI代替VOSK进行语音识别

基础库

🎤 WhisperLib

一个基于事件的语音识别模组,使用 WhisperAI 将音频转录为文本。从 VoskLib 分叉而来。


✨ 功能

  1. 离线识别:离线使用 WhisperAI。不会向服务器发送任何音频!
  2. 完全客户端侧:该模组不会将 WhisperAI 运行于任何 Minecraft 服务器。
  3. 内置模型管理器:该模组包含一个内置的模型管理器。
  4. 动态加载:显示来自 HuggingFace 的可用模型。
  5. 可调节的麦克风设置:新增了设置界面,用于调整 VoskLib 尚未提供的麦克风相关设置。
  6. 安全功能:当 WhisperLib 正在监听时,会立即通知你。

📦 用户安装说明

  1. 从 Curseforge 下载此模组。
  2. 启动游戏并点击 Mods 按钮。
  3. 找到 WhisperLib 并按下 Config。
  4. 选择你的模型并按下 Download。
  5. 下载完成后,点击你下载的模型。
  6. 按下 Save & Exit。

就是这样。


🔨 开发者安装说明

  1. 找到 build.gradle。

  2. 添加以下内容:

    dependencies {
        // ...your dependencies
        // Make sure it's in our Runtime (Do not shade these libraries)
        implementation 'io.github.givimad:whisper-jni:1.7.1'
        runtimeOnly 'io.github.givimad:whisper-jni:1.7.1'
    
        // Include the dev mod jar
        implementation fg.deobf(files("libs/whisperlib--dev.jar"))
    }
    
  3. 构建项目并检查是否存在任何问题。

  4. 如果有问题,你可以通过 Curseforge 私信或 GitHub issues 联系我。


🔌 WhisperLib API

// Start Listening
VoiceManager.startListening();

// Stop Listening
VoiceManager.stopListening();

WhisperLib 和 VoskLib 在客户端侧的 Forge Event Bus 上发布它们的结果。

@Mod.EventBusSubscriber(modid = "examplemod", bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT)
public class VoiceEvents {
    @SubscribeEvent
    public static void onResult(WhisperVoiceResult event) {
        // Get the full text. 
        String result = event.getText();

        if (result.toLowerCase().contains("hello")) {
            System.out.println("Hi!");
        }

        // Use the following method to exclude messages like:
        // [MUSIC], [upbeat music], etc. (does not exclude *laughing*)

        String filteredText = event.getSpokenText();
        // do more processing...
    }
}

📜 致谢