diff --git a/ttstoy/README.md b/ttstoy/README.md index ad0570e..3862f72 100644 --- a/ttstoy/README.md +++ b/ttstoy/README.md @@ -92,7 +92,9 @@ in the `/voices` listing. Accessibility mode auto-reads the side chat of the voice channel the bot is in (no command prefix needed), using a single engine (dectalk or piper) with emoji SFX disabled. The first message from a user since someone else last spoke is -prefixed `Name said:`; links, images, and files are announced instead of read. +prefixed `Name said:` (this can be turned off with +`[p]ttstoy accessibility names off`); links, images, and files are announced +instead of read. Each speaker is auto-assigned a distinct voice from the active engine's pool so they can be told apart. Users can pick their own voice. Voice assignments are @@ -103,6 +105,7 @@ in-memory only and are NOT saved between sessions. | `[p]ttstoy accessibility start` | Enable accessibility mode (owner) | | `[p]ttstoy accessibility stop` | Disable accessibility mode (owner) | | `[p]ttstoy accessibility engine [dectalk\|piper]` | Choose the engine (owner); clears per-user voices | +| `[p]ttstoy accessibility names [on\|off]` | Show or set whether `Name said:` is read before a message (owner) | | `[p]ttstoy accessibility voice [name]` | Pick your own voice for the current engine (`auto` to be auto-assigned) | ## Emoji SFX diff --git a/ttstoy/ttstoy.py b/ttstoy/ttstoy.py index 347aedd..daded32 100644 --- a/ttstoy/ttstoy.py +++ b/ttstoy/ttstoy.py @@ -426,6 +426,7 @@ class TtsToy(Cog): piper_voice=None, # optional model_id override for the piper server accessibility_mode=False, accessibility_engine="dectalk", # "dectalk" or "piper" for auto-read + forced TTS + accessibility_announce_names=True, # say "Name said:" before a speaker's message vox_pack="vox", webui_tts_channel_id=None, # channel to post web UI TTS transcripts/audio webui_public_url="https://ttstoy.kingstons-scrapyard.net", # public URL shown in login DMs @@ -2072,11 +2073,13 @@ class TtsToy(Cog): if ctx.invoked_subcommand is None: on = await self.config.accessibility_mode() engine = await self.config.accessibility_engine() + names = await self.config.accessibility_announce_names() await ctx.send( f"Accessibility mode is **{'ON' if on else 'OFF'}** (engine: `{engine}`).\n" f"- `{ctx.clean_prefix}ttstoy accessibility start`\n" f"- `{ctx.clean_prefix}ttstoy accessibility stop`\n" f"- `{ctx.clean_prefix}ttstoy accessibility engine `\n" + f"- `{ctx.clean_prefix}ttstoy accessibility names ` (currently **{'ON' if names else 'OFF'}**)\n" f"- `{ctx.clean_prefix}ttstoy accessibility voice [name]`" ) @@ -2131,6 +2134,32 @@ class TtsToy(Cog): # wiped here. await ctx.send(f"Accessibility engine set to `{engine}`. Saved voices are kept (a voice not available on `{engine}` is swapped for a valid one automatically).") + @accessibility_group.command(name="names", aliases=["announcenames"]) + @commands.is_owner() + async def accessibility_names(self, ctx: commands.Context, state: Optional[str] = None): + """ + Show or set whether a speaker's name is read before their message. + + - `[p]ttstoy accessibility names` -> show the current setting + - `[p]ttstoy accessibility names on` -> say "Name said:" before a message + - `[p]ttstoy accessibility names off` -> read messages without the name + """ + if state is None: + current = await self.config.accessibility_announce_names() + return await ctx.send( + f"Announcing speaker names: **{'ON' if current else 'OFF'}**\n" + f"Set with `{ctx.clean_prefix}ttstoy accessibility names `" + ) + + state = state.strip().lower() + if state not in ("on", "off"): + return await ctx.send("Use `on` or `off`.") + enabled = state == "on" + await self.config.accessibility_announce_names.set(enabled) + await ctx.send( + f"**Speaker names {'will' if enabled else 'will not'} be read** before each message." + ) + @accessibility_group.command(name="voice") @commands.guild_only() async def accessibility_voice(self, ctx: commands.Context, *, voice: Optional[str] = None): @@ -2991,9 +3020,10 @@ class TtsToy(Cog): return # Prefix the speaker's name only on their first message since someone - # else last spoke (i.e. they were "interrupted"). + # else last spoke (i.e. they were "interrupted"), unless name + # announcements are turned off. last = self._access_last_speaker.get(guild.id) - if last != message.author.id: + if await self.config.accessibility_announce_names() and last != message.author.id: spoken = f"{message.author.display_name} said: {spoken}" self._access_last_speaker[guild.id] = message.author.id