ttstoy: speak only ..-triggered messages in accessibility mode

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.
This commit is contained in:
2026-11-04 18:33:30 -06:00
parent 5ca8cea1a7
commit 84feec2e2a
4 changed files with 32 additions and 20 deletions
+10 -6
View File
@@ -1,6 +1,6 @@
# 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.
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
@@ -12,6 +12,10 @@ Accessibility mode reads messages from the text chat attached to the voice chann
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:
@@ -21,7 +25,7 @@ All of these must hold:
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.
6. The message starts with `..`.
## What gets spoken
@@ -31,7 +35,7 @@ All of these must hold:
| 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" |
| Only emoji, or only whitespace | Nothing |
| `..` 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.
@@ -64,9 +68,9 @@ Starting or stopping accessibility mode resets the name tracker and keeps stored
## 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.
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.
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).
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.
@@ -80,7 +84,7 @@ The generated files are named `access-<message id>.mp3` in the cog data director
## 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.
- 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.
+2 -2
View File
@@ -125,8 +125,8 @@ Group `[p]ttstoy accessibility`, alias `[p]ttstoy access`.
| Command | Permission | Description |
|---|---|---|
| `[p]ttstoy accessibility` | Any member | Shows mode, engine and name announcement state |
| `[p]ttstoy accessibility start` | Owner | Enables auto-read |
| `[p]ttstoy accessibility stop` | Owner | Disables auto-read |
| `[p]ttstoy accessibility start` | Owner | Enables the `..` speak trigger |
| `[p]ttstoy accessibility stop` | Owner | Disables the `..` speak trigger |
| `[p]ttstoy accessibility engine` | Owner | Shows or sets `dectalk` or `piper`, alias `tts` |
| `[p]ttstoy accessibility names` | Owner | Shows or sets whether names are announced, alias `announcenames` |
| `[p]ttstoy accessibility voice [name]` | Any member, guild only | Shows the voice list or sets your voice, `auto` clears |
+1 -1
View File
@@ -1,6 +1,6 @@
# 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.
Text to speech with six interchangeable engines, per-user cloned voices, emoji triggered sound effects, an accessibility mode that reads `..`-prefixed 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.