Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
fix(web): treat speech-free live chunks as valid empties + e2e speech pass
Richie McIlroy6815ed37f58b
diff --git a/apps/web/__tests__/unit/live-transcribe-core.test.ts b/apps/web/__tests__/unit/live-transcribe-core.test.tsindex ac3d32a34..89ea39ea0 100644--- a/apps/web/__tests__/unit/live-transcribe-core.test.ts+++ b/apps/web/__tests__/unit/live-transcribe-core.test.ts@@ -2,6 +2,7 @@ import { describe, expect, it } from "vitest";import {applyChunkToLiveTranscript,createEmptyLiveTranscript,+ isNoSpokenAudioError,offsetChunkWords,parseLiveTranscript,planNextLiveChunk,@@ -244,3 +245,20 @@ describe("live transcript artifact", () => {expect(parseLiveTranscript(JSON.stringify({ version: 99 }))).toBeNull();});});++describe("isNoSpokenAudioError", () => {+ it("recognizes speech-free chunks as valid empties, not failures", () => {+ // exact message observed from the real API on a silent recording+ expect(+ isNoSpokenAudioError({+ status: "error",+ error:+ "language_detection cannot be performed on files with no spoken audio.",+ }),+ ).toBe(true);+ expect(+ isNoSpokenAudioError({ status: "error", error: "Server error" }),+ ).toBe(false);+ expect(isNoSpokenAudioError({ status: "completed" })).toBe(false);+ });+});diff --git a/apps/web/lib/live-transcribe-core.ts b/apps/web/lib/live-transcribe-core.tsindex bba28632e..fb2e65440 100644--- a/apps/web/lib/live-transcribe-core.ts+++ b/apps/web/lib/live-transcribe-core.ts@@ -161,6 +161,21 @@ export function offsetChunkWords(return result;}+/**+ * AssemblyAI reports speech-free audio as a transcript error when language+ * detection is enabled. For chunked live transcription that's a valid empty+ * chunk (pauses in narration are normal), not a failure to retry.+ */+export function isNoSpokenAudioError(transcript: {+ status: string;+ error?: string | null;+}): boolean {+ return (+ transcript.status === "error" &&+ /no spoken audio/i.test(transcript.error ?? "")+ );+}+export const LIVE_TRANSCRIPT_VERSION = 1;export type LiveTranscriptState = "active" | "complete" | "stopped";diff --git a/apps/web/workflows/live-transcribe.ts b/apps/web/workflows/live-transcribe.tsindex df3b4a45f..9bfe49303 100644--- a/apps/web/workflows/live-transcribe.ts+++ b/apps/web/workflows/live-transcribe.ts@@ -23,6 +23,7 @@ import {applyChunkToLiveTranscript,createEmptyLiveTranscript,getLiveTranscriptObjectKey,+ isNoSpokenAudioError,LIVE_TRANSCRIBE,LIVE_TRANSCRIPT_NO_SEGMENTS,type LiveTranscriptState,@@ -370,15 +371,18 @@ async function processNextLiveChunk(options: {disfluencies: true,});- if (transcript.status === "error") {+ const noSpokenAudio = isNoSpokenAudioError(transcript);+ if (transcript.status === "error" && !noSpokenAudio) {throw new Error(transcript.error ?? "AssemblyAI chunk failed");}- const words = offsetChunkWords(- transcript.words,- decision.startMs,- decision.durationMs,- );+ const words = noSpokenAudio+ ? []+ : offsetChunkWords(+ transcript.words,+ decision.startMs,+ decision.durationMs,+ );const artifactKey = getLiveTranscriptObjectKey(video.ownerId, videoId);const existing = await bucket