Download VoiceLib — Minecraft Mods — MetaMods

VoiceLib

Active

Downloads

0

Last update

1 year ago

Versions

1.21 — 1.21.1
Client
Fabric
Neoforge
Libraries

VoiceLib

Minecraft text to speech library

Usage

The VoiceLibApi class provides the main API for working with the library. Here are the key methods you'll need:

VoiceLibApi.registerServerPlayerSpeechListener(Consumer<ServerPlayerTalkEvent> consumer)
This method registers a ServerPlayerTalkEvent handler. The event triggers every time a player speaks. ServerPlayerTalkEvent contains information about the player and the spoken text.

VoiceLibApi.registerClientSpeechListener(Consumer<ClientTalkEvent> consumer)
Registers a ClientTalkEvent handler that works only on the client side. Triggers when the user speaks.

VoiceLibApi.setPrintToChat(boolean printToChat)
Configures output of speech events to chat (client side only). Disabled by default.

VoiceLibApi.setPrintToConsole(boolean printToConsole)
Similar to the previous one, but for console output. Disabled by default.

All methods come with JavaDoc containing detailed usage information.

Example

Here's an example that sets any server player on fire if they say "ouch":

VoiceLibApi.registerServerPlayerSpeechListener((serverPlayerTalkEvent -> {
    if (serverPlayerTalkEvent.getText().contains("ouch"))
        serverPlayerTalkEvent.getPlayer().igniteForSeconds(2);
}));

Additional examples can be found in VoiceLibExample.

Security

Important points to consider:

  • On first launch, the mod automatically downloads a vosk model from the internet (about 40 MB)
  • By default, the mod constantly records and sends all text data to the server. This means a malicious actor could eavesdrop on your conversations (text only, audio is not transmitted)
  • The "push to talk" key is inverted by default - pressing it turns off the microphone
  • Other mods can forcibly enable continuous recording or disable it (see VoiceLibClient)
Project members
modogthedev

modogthedev

Created: 21 Aug 2024

ID: 50786