BBSMC Logo
模组整合包光影资源包软件汉化插件数据包地图
登录
模组插件数据包光影资源包整合包软件汉化地图
登录
设置
Speaker API

Speaker API

TEXT→HUMAN VOICE in Minecraft.

前置
0015 days ago
Speaker API

Speaker API

TEXT→HUMAN VOICE in Minecraft.

0
0
前置

基本信息

我的世界Java版本

1.21.1
1.20.1–1.20.6
1.19.2–1.19.4

平台

\n \n \n Forge
NeoForge

运行环境

客户端

分类

前置
BBSMC 创作者激励广告

其他链接

反馈问题 查看源码 访问 wiki
ModrinthCurseForge地址

创作者

li2012China
li2012China Member

详情信息

许可证 Apache-2.0
发布于 2026-10-08
更新于 2026-10-07
简介更新日志版本百科反馈讨论

Speaker API 是一款离线、隐私优先的 Minecraft 文字转语音(TTS)中间件。它把游戏内文字——聊天、系统消息、弹窗提示,以及其它模组提交的任何文本——转换为自然、拟人化的语音,通过扬声器播放。一切都在本机本地运行:无网络请求、无云端、无账号。

功能

  • 本地离线 TTS,由 sherpa-onnx 与 Kokoro 语音模型驱动(均为 Apache-2.0)。
  • 中文优先,支持中英混读,内置多种嗓音。
  • 其它模组可注册自己的「来源」并通过简单 API 提交文本以获得语音反馈。
  • 可选:替换系统讲述人(Windows 讲述人 / SAPI),让其它模组与游戏本体都改用本模组发声。
  • 位置感知音频:把语音绑定到实体或方块,使声音仿佛从世界中的该位置传来。

为什么下载

  • 完全离线、隐私安全——你的文本绝不会离开本机。
  • 为 Minecraft 及无障碍类模组提供真实、自然的语音,告别无声文字。
  • 轻量且仅客户端运行,不影响游戏服务器。

下载前须知

  • 仅客户端:请装在 Minecraft 客户端(Forge / NeoForge),不要装到服务器。
  • 首次使用会下载语音模型(约 380 MB)。内置下载镜像以加速;也可执行 /speakerapi download kokoro-multilang。
  • 支持版本:Minecraft 1.19.2(Forge)、1.20.1(Forge)、1.21.1(NeoForge)。
  • Forge 版需 Java 17,NeoForge 版需 Java 21。

指令

  • /speakerapi test — 朗读示例句(必要时加载模型)。
  • /speakerapi status — 在聊天栏显示引擎与模型状态。
  • /speakerapi model <id> — 选择并加载模型。
  • /speakerapi download <id> — 仅下载模型。
  • /speakerapi stop — 停止所有朗读。
  • /speakerapi voices — 列出可用嗓音。

API 使用方法

Speaker API exposes a stable, cross-version API under the package net.speakerapi. All methods are static. The mod is client-side only: API calls made from a dedicated/server environment are safe no-ops (they simply do nothing), so guard with isEnabled() / isEngineReady() if you also run headless.

Adding the dependency

On Forge / NeoForge, add a dependency on speakerapi (any supported version). At runtime the class net.speakerapi.SpeakerAPI is available whenever the mod is loaded.

Basic speech

import net.speakerapi.SpeakerAPI;
import net.speakerapi.SpeakerAPI.Priority;
import net.speakerapi.core.VoiceProfile;
import net.minecraft.network.chat.Component;

// Speak a line from your mod ("mymod" is the source id).
SpeakerAPI.say(Component.literal("Hello, world"), "mymod", VoiceProfile.ZH_FEMALE_NATURAL, Priority.NORMAL);

// Or with a plain string:
SpeakerAPI.say("Watch your step", "mymod", VoiceProfile.ZH_MALE_NATURAL, Priority.HIGH);
  • sourceId — string identifying your mod; used for per-source filtering/registration.
  • voice — a VoiceProfile. Built-ins: VoiceProfile.ZH_FEMALE_NATURAL, VoiceProfile.ZH_MALE_NATURAL. Discover more via availableVoices() / voiceFor("zh_female_natural").
  • priority — Priority.LOW | NORMAL | HIGH | ANNOUNCE.

Cancellation & completion

The say(Component/String, …) overloads return CompletableFuture<Void> (completes when speech finishes). The positioned / builder variants return a SpeakHandle:

SpeakerAPI.SpeakHandle handle = SpeakerAPI.sayForEntity(player, "Follow me");
handle.cancel();                              // stop this utterance early
boolean done = handle.isDone();
handle.future().thenRun(() -> System.out.println("finished"));

Positioned & bound (follow) audio

// One-shot spatialized at a coordinate / entity / block (snapshot at call time):
SpeakerAPI.sayAt("Danger zone", "mymod", null, Priority.HIGH, someBlockPos);
SpeakerAPI.sayAt("Enemy approaching", "mymod", null, Priority.HIGH, someEntity);

// Bound audio: the voice follows a moving entity for the whole utterance:
SpeakerAPI.SpeakHandle h = SpeakerAPI.sayForEntity(player, "Come with me");
SpeakerAPI.SpeakHandle b = SpeakerAPI.sayForBlock(blockPos, "This is the workbench");

For full control, use the builder:

SpeakerAPI.SayOptions opt = SpeakerAPI.SayOptions.builder()
    .text("Quest complete")
    .sourceId("mymod")
    .voice(VoiceProfile.ZH_FEMALE_NATURAL)
    .priority(Priority.ANNOUNCE)
    .volume(0.8f)                                       // optional per-call gain
    .category(net.minecraft.sounds.SoundSource.RECORDS) // optional MC sound category
    .bindTo(targetEntity)                               // follow the entity (eye height)
    .onSentenceStart(s -> { /* per-sentence */ })
    .onSentenceDone(s -> { /* per-sentence */ })
    .onComplete(() -> { /* whole utterance done */ })
    .build();
SpeakerAPI.say(opt);

bindTo(Entity) / bindTo(BlockPos) make the voice track the target; you can also pass a custom PositionProvider (net.speakerapi.core.PositionProvider) for arbitrary moving anchors. Spatialization needs a client-side listener pose; if unavailable it degrades to centered playback (still audible).

Engine readiness

The engine loads the voice model asynchronously on first use. Check or wait before relying on speech:

if (SpeakerAPI.isEngineReady()) {
    // speak now
}
SpeakerAPI.addEngineReadyListener(() -> { /* engine loaded */ });

Models (select / download)

SpeakerAPI.knownModelIds();                 // supported model ids
SpeakerAPI.selectModel("kokoro-multilang"); // set default + download if missing + hot-reload
SpeakerAPI.downloadModel("kokoro-multilang"); // download only (CompletableFuture<Boolean>)
SpeakerAPI.listModels();                    // local readiness snapshot

Other controls

SpeakerAPI.setEnabled(boolean);          // global mute toggle
SpeakerAPI.stopAll();                    // stop every active utterance
SpeakerAPI.setCategory(SoundSource);     // bind output to a MC sound category
SpeakerAPI.setReplaceSystemTts(boolean); // route the system narrator through this mod
SpeakerAPI.registerSource("mymod", text -> true); // register a named source

Notes

  • Client-side only. All speech is local; no text leaves the machine.
  • The API surface is identical across Minecraft 1.19.2 / 1.20.1 (Forge) and 1.21.1 (NeoForge).
BBSMC Logo

中国最活跃的 Minecraft 中文资源社区

QQ 群:1078515449

资源

模组整合包光影资源包地图

社区

汉化软件插件数据包

帮助

服务条款隐私政策社区规则开源代码
设置

"Minecraft"以及"我的世界"为美国微软公司的商标,本站与微软公司没有从属关系。 本站与 Modrinth 无从属关系,网站遵循 LGPL 协议开源。

© 2019-2026 青岛柒兮网络科技有限公司 | 鲁B2-20210590 | 鲁ICP备2021009459号-12 | 公安备案 鲁公网安备37021002001586号