From c3f1032e80a1d4b68076aaf3ed219c4a6ada5ec9 Mon Sep 17 00:00:00 2001 From: kingston Date: Thu, 5 Nov 2026 12:16:22 -0600 Subject: [PATCH] transcribe: remove the slow request notice The notice could survive beside a finished transcript, leaving a take a moment message under a completed reply. The typing indicator covers the wait, so drop the separate notice and its cleanup task. --- transcribe/transcribe.py | 38 +------------------------------------- wiki/Transcribe.md | 4 ++-- 2 files changed, 3 insertions(+), 39 deletions(-) diff --git a/transcribe/transcribe.py b/transcribe/transcribe.py index 4175bd3..77b5cb4 100644 --- a/transcribe/transcribe.py +++ b/transcribe/transcribe.py @@ -5,7 +5,6 @@ from __future__ import annotations import asyncio import logging import re -from contextlib import asynccontextmanager, suppress from typing import Optional import aiohttp @@ -41,11 +40,6 @@ MEDIA_EXTENSIONS = ( # guessed language produces fluent nonsense, so we show the transcript instead. MIN_LANGUAGE_CONFIDENCE = 0.5 -# Post a progress note when a request is still running after this many seconds. -# Long voice messages and slow CPU inference both cross this line; short clips -# finish before the notice is sent, so they never see it. -SLOW_REQUEST_NOTICE_SECONDS = 3.0 - # English language names -> ISO-639-1, so `[p]transcribe french` works. LANGUAGE_NAMES = { "afrikaans": "af", "albanian": "sq", "amharic": "am", "arabic": "ar", @@ -359,36 +353,6 @@ class Transcribe(commands.Cog): "zh-tw": "zho_Hant", "zh-hant": "zho_Hant", }.get(code, code) - @asynccontextmanager - async def _slow_notice(self, ctx: commands.Context, delay: float = SLOW_REQUEST_NOTICE_SECONDS): - """Tell the channel that a long transcription is still running. - - Waits `delay` seconds before posting, and removes the notice when the - surrounding block exits, whether it succeeded, failed or returned early. - """ - holder: dict[str, Optional[discord.Message]] = {"message": None} - - async def announce(): - await asyncio.sleep(delay) - try: - holder["message"] = await ctx.send( - "Still transcribing. Longer recordings can take a moment." - ) - except discord.HTTPException: - pass - - task = asyncio.create_task(announce()) - try: - yield - finally: - task.cancel() - with suppress(asyncio.CancelledError): - await task - message = holder["message"] - if message is not None: - with suppress(discord.HTTPException): - await message.delete() - # ----------------------------------------------------------------- commands @commands.command(name="transcribe", aliases=["stt"]) @commands.guild_only() @@ -423,7 +387,7 @@ class Transcribe(commands.Cog): return origin = self._origin_note(origin_message, forwarded) - async with ctx.typing(), self._slow_notice(ctx): + async with ctx.typing(): try: data = await self._download(attachment) if not data: diff --git a/wiki/Transcribe.md b/wiki/Transcribe.md index 79e5b32..f18f813 100644 --- a/wiki/Transcribe.md +++ b/wiki/Transcribe.md @@ -66,9 +66,9 @@ The result header names both languages in the form `Source to Target`. When the Replies are clipped near 1900 characters, with the note that the text was cut off. -## Progress and errors +## Errors -The command holds a typing indicator for the whole operation. If a request is still running after three seconds, including the download and any translation, the bot posts a short notice that it is still transcribing. The notice is deleted when the request finishes, whether it succeeds or fails. Short clips complete before the delay and never show it. +The command holds a typing indicator for the whole operation. Service errors are prefixed with a warning symbol and include the specific cause: