Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix(transcription): align Deepgram batch size and worker timeout

Louis Beaumont2d6737066df1
diff --git a/crates/screenpipe-audio/src/audio_manager/reconciliation.rs b/crates/screenpipe-audio/src/audio_manager/reconciliation.rs
index f92696907..6cca2c667 100644
--- a/crates/screenpipe-audio/src/audio_manager/reconciliation.rs
+++ b/crates/screenpipe-audio/src/audio_manager/reconciliation.rs
@@ -62,7 +62,13 @@ struct PendingTranscription {
/// Audio is encoded as MP3 (64 kbps mono 16 kHz) before upload, so durations
/// are bounded by the compressed size, not raw WAV.
///
-/// - Deepgram via Cloudflare: 100 MB upload limit ÷ 64 kbps ≈ 3.5 h → cap at 5000 s (~83 min)
+/// - Deepgram via Cloudflare: cap at 480 s (8 min). Bounded by Deepgram's own
+/// 10-minute hard ceiling — requests exceeding it return 504 Gateway Timeout
+/// on Nova models (https://github.com/orgs/deepgram/discussions/585). Bigger
+/// batches also blow past our worker's AbortSignal because Deepgram's
+/// documented minimum latency isn't sub-20s. Diarization quality plateaus
+/// above ~3 min audio per Deepgram's docs, so 8 min keeps the quality win
+/// without flirting with the 10-min cliff.
/// - OpenAI-compatible: user-configurable (unknown engine limits), default 3000 s (~50 min)
/// - Parakeet: ONNX int8 encoder handles up to ~52s but quality degrades past 30s.
/// Benchmarked: full audio = 33.1% WER, 30s chunks = 33.9% WER (best chunked).
@@ -71,7 +77,7 @@ struct PendingTranscription {
/// - Qwen3-ASR: similar to Whisper architecture → cap at 600 s (10 min)
pub fn default_max_batch_duration_secs(engine: &AudioTranscriptionEngine) -> u64 {
match engine {
- AudioTranscriptionEngine::Deepgram => 5000,
+ AudioTranscriptionEngine::Deepgram => 480,
AudioTranscriptionEngine::OpenAICompatible => 3000,
AudioTranscriptionEngine::Parakeet => 45,
_ => 600,
diff --git a/packages/ai-gateway/src/services/transcription-ab.ts b/packages/ai-gateway/src/services/transcription-ab.ts
index 4c66cfac2..b12b439b6 100644
--- a/packages/ai-gateway/src/services/transcription-ab.ts
+++ b/packages/ai-gateway/src/services/transcription-ab.ts
@@ -151,7 +151,13 @@ export async function callDeepgram(
'Content-Type': req.contentType,
},
body: req.audioBuffer,
- signal: AbortSignal.timeout(30_000),
+ // Deepgram's own docs say prerecorded latency is not expected to be
+ // sub-20s, and a typical 8-min batch takes 20-60s of Deepgram-side
+ // processing. The previous 30s timeout aborted on every non-trivial
+ // batch, surfacing as HTTP 500 "operation aborted due to timeout"
+ // to the Rust client and saturating the retry loop. Cloudflare
+ // Workers comfortably handle 180s subrequests.
+ signal: AbortSignal.timeout(180_000),
});
if (resp.ok) {
@@ -176,7 +182,7 @@ export async function callDeepgram(
break;
} catch (e: any) {
if ((e.name === 'TimeoutError' || e.name === 'AbortError') && attempt < MAX_ATTEMPTS) {
- lastError = 'timeout after 30s';
+ lastError = 'timeout after 180s';
await new Promise((r) => setTimeout(r, 500));
continue;
}