transcription returning ellipsis dots (#2009)
Browse filesFix transcription returning dots for silence/unclear audio
Whisper model returns "..." (or similar dot patterns) when audio is
too short, silent, or unclear. Filter out responses that only contain
dots server-side to prevent them from being inserted into the draft
message or triggering auto-send on mobile.
Co-authored-by: Claude <noreply@anthropic.com>
src/routes/api/transcribe/+server.ts
CHANGED
|
@@ -85,7 +85,10 @@ export async function POST({ request, locals }) {
|
|
| 85 |
const result = await response.json();
|
| 86 |
|
| 87 |
// Whisper API returns { text: "transcribed text" }
|
| 88 |
-
|
|
|
|
|
|
|
|
|
|
| 89 |
} catch (err) {
|
| 90 |
if (err instanceof Error && err.name === "AbortError") {
|
| 91 |
logger.error({ model: transcriptionModel }, "Transcription timeout");
|
|
|
|
| 85 |
const result = await response.json();
|
| 86 |
|
| 87 |
// Whisper API returns { text: "transcribed text" }
|
| 88 |
+
// Filter out responses that only contain dots (e.g. "..." returned for silence/unclear audio)
|
| 89 |
+
const text = (result.text || "").trim();
|
| 90 |
+
const isOnlyDots = /^\.+$/.test(text);
|
| 91 |
+
return json({ text: isOnlyDots ? "" : text });
|
| 92 |
} catch (err) {
|
| 93 |
if (err instanceof Error && err.name === "AbortError") {
|
| 94 |
logger.error({ model: transcriptionModel }, "Transcription timeout");
|