84feec2e2a
Accessibility mode read every message in the voice channel side chat and treated `..` as an opt-out, so ordinary chat was always spoken. Members now trigger speech explicitly with `..`, and messages without the trigger are never read.
107 lines
6.0 KiB
Markdown
107 lines
6.0 KiB
Markdown
# TtsToy Accessibility
|
|
|
|
Accessibility mode speaks messages from the text chat attached to the voice channel the bot is in, but only the ones a member marks with the `..` trigger. Ordinary chat is never spoken. It exists so a member who cannot read the side chat can follow what a speaker deliberately marks for 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.
|
|
|
|
## The `..` trigger
|
|
|
|
A message is spoken only when it starts with `..`. The trigger and the whitespace after it are dropped before speaking, so `..good game` is read as "good game". A message without the trigger is ignored, so normal conversation is never spoken.
|
|
|
|
## 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 starts with `..`.
|
|
|
|
## What gets spoken
|
|
|
|
| Message content | Spoken text |
|
|
|---|---|
|
|
| Plain text | The text, with emoji removed |
|
|
| Attachment that is an image | "<name> sent an image" |
|
|
| Other attachment | "<name> sent a file" |
|
|
| A URL anywhere in the text, or any embed | "<name> sent a link" |
|
|
| `..` alone, only emoji after it, 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 <name>`. 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 `..` triggered messages.
|
|
|
|
Triggered speech 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-<message id>.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, triggered speech 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.
|