A Minecraft speech to text library; detect what your players say!
A speech to text library that can listen to your microphone and understand what you're saying! Using the power of Vosk, you can speak into your microphone and get an output, and even use multiple languages!
repositories {
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
}
}
dependencies {
modImplementation "maven.modrinth:shriek:1.1.01+fabric"
}
ShriekApi is the class for the API.
The following are the methods you will be using
import com.pryzmm.client.event.EventHandler;
EventHandler.setModel();
// This will set the language model, defined in https://alphacephei.com/vosk/models
// Language models vary in size; the default is vosk-model-small-en-us-0.15, which is ~40 MB compressed, while others like vosk-model-ru-0.10 are ~2.5GB compressed
// Changing models will restart a restart to download, or a call from EventHandler.getOrCreatePath();
ShriekApi.registerServerPlayerSpeechListener(Consumer<ServerPlayerTalkEvent> consumer)
// This method registers a ServerPLayerTalkEvent Consumer. Whenever a player speaks,
// This event will be fired. The ServerPlayerTalkEvent provides the player, and a string of what they said.
ShriekApi.registerClientSpeechListener(Consumer<ClientTalkEvent> consumer)
// This method registers a ClientTalkEvent Consumer. This method is only fired on the client.
// Whenever the user speaks, this will be fired.
ShriekApi.setPrintToChat(boolean printToChat)
// This is only on the client. This sets whether or not to
// print client speak events to chat. (Default False)
ShriekApi.setPrintToConsole(boolean printToConsole)
// Same as printToChat but for the console instead. (Default False)
This method makes it so if any player on the server says "ouch" they light on fire
ShriekApi.registerServerPlayerSpeechListener((serverPlayerTalkEvent -> {
if (serverPlayerTalkEvent.getText().contains("ouch"))
serverPlayerTalkEvent.getPlayer().igniteForSeconds(2);
}));
You can also see this in ShriekExample through GitHub
There are a few things to note with this mod: