transcribe: refuse to auto-detect very short text

langdetect labels 'ok' as Slovak with high confidence, so the probability gate
alone was not enough. Require 12+ characters before guessing, and document the
translate command in the README.
This commit is contained in:
2026-11-02 16:07:16 -06:00
parent 95b14dc8c1
commit eb4f7139a2
2 changed files with 10 additions and 0 deletions
+3
View File
@@ -1349,6 +1349,7 @@ Transcribe Discord voice messages with Whisper, and optionally translate them wi
- `[p]transcribe` - Transcribe the message and translate it into English.
- `[p]transcribe <language>` - Translate into another language, by English name (`french`) or ISO code (`fr`).
- `[p]translate <language>` - Translate the message you reply to (or text you type), with the source language detected automatically. Add `from <language>` when detection is unsure or you want to be explicit.
- `[p]transcribeset showoriginal <true|false>` - Show the original text under a translation (default: on).
Reply to a voice message, or just run the command and the newest voice message within the last 25 messages is used. Attachments are accepted too, as long as they are audio (`ogg`, `opus`, `wav`, `mp3`, `m4a`, `flac`, `webm`).
@@ -1359,3 +1360,5 @@ The cog talks to two local services:
- `nllb-server` on `127.0.0.1:8200` for translation (NLLB-200, GPU)
English needs only the first one: Whisper's own `translate` task handles it in a single pass. Everything else transcribes first, then translates. If Whisper is less than 50% confident about which language it heard, the cog prints the transcript and skips the translation rather than translating a guess.
`[p]translate` works on text instead of audio: reply to a message and give the target language. Source detection uses `langdetect` (declared in `info.json` requirements), refuses text shorter than 12 characters, and refuses when the top guess is under 70% or is within 15 points of a runner-up. Both refusals name the `from <language>` form rather than guessing.