The root README carried the full ten cog manual while the wiki held the authoritative pages. Point the repository at the wiki, keep only install and catalog basics in the README, and remove the per cog documents that are now folded into wiki source under wiki/.
8.8 KiB
TtsToy Overview
Text to speech with six interchangeable engines, per-user cloned voices, emoji triggered sound effects, an accessibility mode that reads voice channel text chat aloud, and a companion web UI.
The cog generates an MP3 for every request, posts it in the channel, and plays it in voice chat when the author is connected.
Engines
| Mode | Where it runs | Needs | Notes |
|---|---|---|---|
minimax |
MiniMax cloud API | API key | Best quality, paid, sends text off site, reports detected language |
chatterbox |
Local server on port 8099 | Chatterbox server | Voice cloning from uploaded clips, per-voice tuning |
dectalk |
Local server on port 33001 | DECTalk service | Nine classic voices selected with inline tags |
morshu |
Port 33002, in-process fallback | Optional g2p_en, numpy, pydub |
Always the Morshu voice |
vox |
In process | Bundled word packs | Black Mesa announcer, unknown words skipped |
piper |
Local server on port 5006 | Piper HTTP server | Fast neural voices, optional model id |
[p]ttstoy mode shows the current engine and the relevant address. [p]ttstoy mode <name> changes it for the whole bot; the mode is global, not per guild.
Mode selection is owner only.
Prerequisites
- Red 3.5 or newer.
- YTAudio loaded and a Lavalink node connected, for playback in voice.
ffmpegon the PATH, used for volume offsets and concatenation.requests,pydub,numpy,g2p_enfor the local engines, per the manifest.- The engine service for the selected mode, if any.
Audio playback borrows YTAudio's Lavalink client. Load YTAudio first. Without a connected node, [p]tts still generates and posts the file but cannot play it.
The speak command
[p]tts Hello world
- Joins the author's voice channel through Lavalink if the bot is not already connected.
- Requires the author to be in a voice channel unless the mode is Chatterbox. Outside voice, only Chatterbox is allowed, because the command still returns an audio file.
- Runs a reachability check for the selected engine before synthesis.
- Rejects the request when MiniMax has no key, Morshu failed to import, or VOX is unavailable.
- Generates the audio, sends it as
<mode>-tts-<message id>.mp3with a donation link button, and adds a line naming the detected language for engines that report one. - Queues the file for voice playback when the author is in a channel and the bot is connected, announcing the queue position when something is already playing.
- Reacts to the command message with a speaking emoji.
There is no cooldown and no text length limit. Long text is sent to the engine as is, and very long output can exceed the engine's own limits or the HTTP timeout.
Inline voice switching
Text can switch engine and voice mid-message:
[p]tts [minimax|robotnik] Hands off. [dectalk] [:nh] You have been warned.
The syntax is [mode|voice] or [mode]. Valid modes are the six engine names. An invalid tag is read as literal text. Each segment is rendered separately and concatenated into one MP3, so a single message can mix engines.
When the tag names a voice, it is resolved against the engine: MiniMax labels or raw ids, DECTalk speaker names, a Chatterbox filename or display name, or a Piper model id. An unknown name is passed through to the engine, which may reject it.
The multi-voice path skips the fast single-engine path, so expect a longer generation time and slightly different loudness between segments.
Emoji sound effects
Any emoji in the text with a mapped folder in sfx/ is replaced by a randomly chosen clip from that folder. Folders without audio fall back to speaking the emoji name.
The mapping lives in sfx/emoji_map.json and can be edited, with defaults compiled into the cog. [p]ttstoy sfx lists folders, their emoji triggers and whether they contain audio. [p]ttstoy sfxvolume sets the clip volume from 0 to 100.
Morshu and VOX bypass the SFX splitter because they consume fixed word sets rather than arbitrary speech. Accessibility mode strips emoji so nothing is played as a sound effect.
Chatterbox voice cloning
[p]chatterbox addvoice <name>with an attached.wavor.mp3, or a direct URL.- Clips shorter than six seconds are looped and clips longer than thirty seconds are trimmed at a nearby silence boundary.
- Files are stored on the Chatterbox server as
<user id>_<name>.wavand the filename is recorded in user config. - The new voice becomes the uploader's active voice.
[p]chatterbox myvoiceslists them,[p]ttstoy myvoice <name>switches.[p]chatterbox sharevoice <name> @memberadds the same file to another member's library. The file stays owned by the original uploader, so removing it from the sharer's list does not delete it.[p]chatterbox removevoice <name>removes it from the library and deletes the server file only when the caller owns the file.
Per-voice tuning is stored against the filename: temp for randomness, exag for expressiveness, volume for a dB offset from -20 to +20, speed from 0.25 to 4.0. Each is set per voice per user and cleared with reset. [p]chatterbox reset clears all four for the current voice.
Tuning values for temperature and exaggeration are documented with ranges but are not range checked by the cog; the Chatterbox server decides what it accepts. Volume and speed are validated.
The Chatterbox model can be switched between turbo and original by the owner. The command writes the model id through /save_settings and then triggers a hot swap through /restart_server, which can take a minute or more.
Queue and music handling
Each guild has its own TTS queue and processor. When a clip starts, the processor pauses any music, saves the current track, position and queue, clears the Lavalink queue, plays the clip, then restores the queue and seeks back.
Consequences:
- Music resumes from where it stopped, not from where it would have been.
- Tracks queued in Lavalink during the clip can be lost when the saved queue is restored.
- A guild with a stuck player stalls its own queue only.
- Generated files live in the cog data directory and are deleted by an hourly cleanup loop, which removes the whole directory.
Web UI
[p]ttstoy webui returns the public URL. [p]ttstoy login requests a one-time key from the web UI service and DMs it; the key is valid for five minutes and signs the member in across the Scrapyard sites.
The web UI can change a member's voice, tuning values, and voice library. It cannot run arbitrary bot commands. Changes arrive as queued actions in a shared JSON state file that the cog polls every three seconds.
[p]ttstoy webuichannel sets the channel where web UI generated audio is posted in the current server. Without it, the cog uses the global setting, the TTSTOY_WEBUI_CHANNEL_ID environment variable, or the first channel named tts, ttstoy or tts-toy.
Health endpoint
On load the cog starts an HTTP server on port 8097 answering GET /health with a small JSON status object. Every other path returns 404. It is intended for external monitoring and is not used by the bot.
Limits and known issues
- Mode is global. A guild cannot choose its own engine.
- No cooldowns, so a member can flood the queue and the engine servers.
- No permission checks on
[p]ttsor[p]disconnect. - The accessibility voice pool for Piper is fixed at five models to bound GPU memory.
- Concatenation assumes the same codec parameters across segments. Mixed engines can produce audible seams.
[p]ttstoy infostill describes an older default Chatterbox port and older command names. Trust[p]ttstoy modeand[p]chatterbox url.- Voice assignments and library entries are not removed by Red's user data deletion.
ttstoy/stack.jsonis a deployment specific file of website paths and a shared session secret. The cog does not read it.
Stored data
Global config under identifier 0x0A0A0A0A:
| Key | Default |
|---|---|
minimax_api_key |
null |
minimax_model |
speech-01-turbo |
minimax_voice |
One built-in voice id |
sfx_volume |
100 |
tts_mode |
minimax |
chatterbox_api_url |
http://127.0.0.1:8099 |
dectalk_api_url |
http://127.0.0.1:33001 |
piper_api_url |
http://127.0.0.1:5006 |
piper_voice |
null |
accessibility_mode |
false |
accessibility_engine |
dectalk |
accessibility_announce_names |
true |
vox_pack |
vox |
webui_tts_channel_id |
null |
webui_public_url |
Deployment URL |
Guild config: webui_tts_channel_id.
Member config: access_voice, a map of engine to voice and whether the member chose it explicitly.
User config: minimax_voice, chatterbox_voices, chatterbox_temperature_offsets, chatterbox_exaggeration_offsets, chatterbox_volume_offsets, chatterbox_speed_offsets, plus two deprecated single-value tuning keys kept for migration.