An Event-based voice recognition mod that uses WhisperAI to transcript audio to text. Forked from VoskLib.
Mods button.WhisperLib and press Config.Download.Save & Exit.That's it.
Locate build.gradle.
Add the following:
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"))
}
Build the project and check if there's any issues.
If there's, you can contact me via Curseforge PMs or GitHub issues.
// Start Listening
VoiceManager.startListening();
// Stop Listening
VoiceManager.stopListening();
WhisperLib and VoskLib are posting their results in Forge Event Bus at Client-side.
@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...
}
}