# TtsToy Accessibility Accessibility mode reads messages from the text chat attached to the voice channel the bot is in, without requiring a command prefix. It exists so a member who cannot read the side chat can follow it by listening. ## Enabling ``` [p]ttstoy accessibility start [p]ttstoy accessibility engine piper [p]ttstoy accessibility names on ``` Start and stop require the bot owner. Engine and name announcements also require the owner. Members choose their own voice with `[p]ttstoy accessibility voice`, which needs no permission. ## Conditions for a message to be read All of these must hold: 1. Accessibility mode is on. 2. The bot is connected to a voice channel. 3. The message is in that voice channel's text chat, which Discord exposes as a text channel with the same ID as the voice channel. 4. The message is not from a bot. 5. The message does not parse as a command, so `[p]tts` invocations are not read twice. 6. The message does not start with `..`, which is the opt-out prefix for members. ## What gets spoken | Message content | Spoken text | |---|---| | Plain text | The text, with emoji removed | | Attachment that is an image | " sent an image" | | Other attachment | " sent a file" | | A URL anywhere in the text, or any embed | " sent a link" | | Only emoji, or only whitespace | Nothing | | Obvious keyboard mash or spam | Nothing | The nonsense filter is conservative. It drops messages with a single character repeated over most of the text, one short token repeated five or more times, a long alphabetic run with almost no vowels, very low character variety over a long message, or a short unit repeated to fill the message. Short real messages such as "ok", "lol" or "brb" pass through. ## Name announcements The first message from a speaker since anyone else last spoke is prefixed with "Name said:". A speaker who sends several messages in a row is announced once. The tracker resets when the bot joins, leaves or moves voice channels, so a stale state does not carry into a new session. `[p]ttstoy accessibility names off` removes the prefix. Names attached to attachments and links are part of the announcement text itself, so they are spoken regardless of this setting. ## Voice assignment Each speaker gets a distinct voice so listeners can tell them apart. - The engine must be `dectalk` or `piper`. - The DECTalk pool is the nine built-in voices: paul, betty, harry, frank, dennis, kit, ursula, rita, wendy. - The Piper pool is five models chosen to bound GPU memory: `en_US-kristin-medium`, `en_US-hfc_female-medium`, `en_US-hfc_male-medium`, `en_US-john-medium`, `en_US-lessac-high`. - Assignment is round robin over the pool, skipping voices already used in the guild, and wrapping around when the pool is exhausted. - A member can pick a voice explicitly with `[p]ttstoy accessibility voice `. The name may be the short label (`hfc_male`), the label with quality (`hfc_male-medium`), the full id, or an unambiguous prefix. - `[p]ttstoy accessibility voice auto` clears the choice and requests a fresh automatic assignment. - `[p]ttstoy accessibility voice` with no argument lists the pool and marks the current voice. Assignments are stored per member per engine in config as `{engine: {"voice": ..., "explicit": ...}}`. They survive reloads and restarts. Only the active engine's voice is loaded into memory; the other engine's entry waits until that engine is selected. Explicit choices are sticky. They survive a voice channel bounce and engine-neutral resets. Automatic assignments are rebuilt when the engine changes. Changing the engine keeps stored voices. A stored voice that is not valid for the new engine is swapped for a valid one automatically, so switching from DECTalk to Piper does not leave a member with a DECTalk voice. Starting or stopping accessibility mode resets the name tracker and keeps stored voices. The maps are rebuilt from member config when the cog loads. ## Engine behavior In accessibility mode, `[p]tts` also forces the accessibility engine and strips emoji, so a member invoking the command gets the same voice treatment as auto-read messages. Auto-read uses the same rendering path as normal speech and the same per-guild queue. Music pauses for the clip and resumes afterward, using the queue restore logic described in [YTAudio](YTAudio). The generated files are named `access-.mp3` in the cog data directory and are removed by the hourly cleanup. ## Deliberate omissions - No emoji are spoken, including mapped sound effect triggers. - No link contents are fetched. The listener says a link was sent. - No attachment contents are described beyond image or file. - No message edits or deletions are announced. - Direct messages and other channels are ignored. ## Operational notes - The bot must stay in the voice channel. If it is pulled out to show a mute notice, auto-read stops until it returns. - Only one voice channel is served at a time, the one the bot occupies. - The queue is per guild, so a long clip delays subsequent messages. - Voice names are matched case-insensitively. - A member with no stored voice and an exhausted pool shares a voice with another speaker. - `red_delete_data_for_user` does nothing, so a deletion request does not clear stored voice assignments. ## Relevant config Global: | Key | Default | |---|---| | `accessibility_mode` | `false` | | `accessibility_engine` | `dectalk` | | `accessibility_announce_names` | `true` | Member: `access_voice`, a map of engine to `{"voice": str, "explicit": bool}`. The in-memory maps `_access_user_override`, `_access_auto_voice`, `_access_assign_idx` and `_access_last_speaker` are rebuilt at load from stored member config and are never written directly.