summaryrefslogtreecommitdiff
path: root/apps/web/src/lib/transcription
diff options
context:
space:
mode:
authorMaze Winther <mazewinther@gmail.com>2026-04-20 11:31:17 +0200
committerMaze Winther <mazewinther@gmail.com>2026-04-20 11:31:17 +0200
commit3e89d2998588f8e35c524e523ba2ee853f0f6475 (patch)
tree57221f96c1259b3b07e3ddf8c1adefc502b9d8eb /apps/web/src/lib/transcription
parent729d10592f4e802f91c555c309ff3ba4b119f843 (diff)
downloadopencut-3e89d2998588f8e35c524e523ba2ee853f0f6475.tar.gz
refactor: restructure files to their domains, new preview overlay system, and dep graph
Diffstat (limited to 'apps/web/src/lib/transcription')
-rw-r--r--apps/web/src/lib/transcription/audio.ts4
-rw-r--r--apps/web/src/lib/transcription/caption-defaults.ts2
-rw-r--r--apps/web/src/lib/transcription/caption.ts49
-rw-r--r--apps/web/src/lib/transcription/diagnostics.ts25
-rw-r--r--apps/web/src/lib/transcription/languages.ts14
-rw-r--r--apps/web/src/lib/transcription/models.ts34
-rw-r--r--apps/web/src/lib/transcription/supported-languages.ts1
-rw-r--r--apps/web/src/lib/transcription/types.ts47
8 files changed, 0 insertions, 176 deletions
diff --git a/apps/web/src/lib/transcription/audio.ts b/apps/web/src/lib/transcription/audio.ts
deleted file mode 100644
index e2dc96d9..00000000
--- a/apps/web/src/lib/transcription/audio.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-export const DEFAULT_TRANSCRIPTION_SAMPLE_RATE = 16000;
-
-export const DEFAULT_CHUNK_LENGTH_SECONDS = 30;
-export const DEFAULT_STRIDE_SECONDS = 5;
diff --git a/apps/web/src/lib/transcription/caption-defaults.ts b/apps/web/src/lib/transcription/caption-defaults.ts
deleted file mode 100644
index fc277158..00000000
--- a/apps/web/src/lib/transcription/caption-defaults.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export const DEFAULT_WORDS_PER_CAPTION = 3;
-export const MIN_CAPTION_DURATION_SECONDS = 0.8;
diff --git a/apps/web/src/lib/transcription/caption.ts b/apps/web/src/lib/transcription/caption.ts
deleted file mode 100644
index 5e23bad8..00000000
--- a/apps/web/src/lib/transcription/caption.ts
+++ /dev/null
@@ -1,49 +0,0 @@
-import type { TranscriptionSegment, CaptionChunk } from "@/lib/transcription/types";
-import {
- DEFAULT_WORDS_PER_CAPTION,
- MIN_CAPTION_DURATION_SECONDS,
-} from "@/lib/transcription/caption-defaults";
-
-export function buildCaptionChunks({
- segments,
- wordsPerChunk = DEFAULT_WORDS_PER_CAPTION,
- minDuration = MIN_CAPTION_DURATION_SECONDS,
-}: {
- segments: TranscriptionSegment[];
- wordsPerChunk?: number;
- minDuration?: number;
-}): CaptionChunk[] {
- const captions: CaptionChunk[] = [];
- let globalEndTime = 0;
-
- for (const segment of segments) {
- const words = segment.text.trim().split(/\s+/);
- if (words.length === 0 || (words.length === 1 && words[0] === "")) continue;
-
- const segmentDuration = segment.end - segment.start;
- const wordsPerSecond = words.length / segmentDuration;
-
- const chunks: string[] = [];
- for (let i = 0; i < words.length; i += wordsPerChunk) {
- chunks.push(words.slice(i, i + wordsPerChunk).join(" "));
- }
-
- let chunkStartTime = segment.start;
- for (const chunk of chunks) {
- const chunkWords = chunk.split(/\s+/).length;
- const chunkDuration = Math.max(minDuration, chunkWords / wordsPerSecond);
- const adjustedStartTime = Math.max(chunkStartTime, globalEndTime);
-
- captions.push({
- text: chunk,
- startTime: adjustedStartTime,
- duration: chunkDuration,
- });
-
- globalEndTime = adjustedStartTime + chunkDuration;
- chunkStartTime += chunkDuration;
- }
- }
-
- return captions;
-}
diff --git a/apps/web/src/lib/transcription/diagnostics.ts b/apps/web/src/lib/transcription/diagnostics.ts
deleted file mode 100644
index a1921699..00000000
--- a/apps/web/src/lib/transcription/diagnostics.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-import type { DiagnosticsManager } from "@/core/managers/diagnostics-manager";
-import { timelineHasAudio } from "@/lib/media/audio";
-
-export const TRANSCRIPTION_DIAGNOSTICS_SCOPE = "transcription";
-
-export function registerTranscriptionDiagnostics({
- diagnostics,
-}: {
- diagnostics: DiagnosticsManager;
-}): void {
- diagnostics.register({
- id: "transcription.no_audio",
- scope: TRANSCRIPTION_DIAGNOSTICS_SCOPE,
- severity: "caution",
- message: "No audio detected. Add a clip with audio to the timeline first.",
- check: (editor) => {
- const scene = editor.scenes.getActiveSceneOrNull();
- if (!scene) return false;
- return !timelineHasAudio({
- tracks: scene.tracks,
- mediaAssets: editor.media.getAssets(),
- });
- },
- });
-}
diff --git a/apps/web/src/lib/transcription/languages.ts b/apps/web/src/lib/transcription/languages.ts
deleted file mode 100644
index e5678145..00000000
--- a/apps/web/src/lib/transcription/languages.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-export const LANGUAGES = [
- { code: "en", name: "English" },
- { code: "es", name: "Spanish" },
- { code: "it", name: "Italian" },
- { code: "fr", name: "French" },
- { code: "de", name: "German" },
- { code: "pt", name: "Portuguese" },
- { code: "ru", name: "Russian" },
- { code: "ja", name: "Japanese" },
- { code: "zh", name: "Chinese" },
-] as const;
-
-export type Language = (typeof LANGUAGES)[number];
-export type LanguageCode = Language["code"];
diff --git a/apps/web/src/lib/transcription/models.ts b/apps/web/src/lib/transcription/models.ts
deleted file mode 100644
index ee9047e7..00000000
--- a/apps/web/src/lib/transcription/models.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-import type {
- TranscriptionModel,
- TranscriptionModelId,
-} from "./types";
-
-export const TRANSCRIPTION_MODELS: TranscriptionModel[] = [
- {
- id: "whisper-tiny",
- name: "Tiny",
- huggingFaceId: "onnx-community/whisper-tiny",
- description: "Fastest, lower accuracy",
- },
- {
- id: "whisper-small",
- name: "Small",
- huggingFaceId: "onnx-community/whisper-small",
- description: "Good balance of speed and accuracy",
- },
- {
- id: "whisper-medium",
- name: "Medium",
- huggingFaceId: "onnx-community/whisper-medium",
- description: "Higher accuracy, slower",
- },
- {
- id: "whisper-large-v3-turbo",
- name: "Large v3 Turbo",
- huggingFaceId: "onnx-community/whisper-large-v3-turbo",
- description: "Best accuracy, requires WebGPU for good performance",
- },
-];
-
-export const DEFAULT_TRANSCRIPTION_MODEL: TranscriptionModelId =
- "whisper-small";
diff --git a/apps/web/src/lib/transcription/supported-languages.ts b/apps/web/src/lib/transcription/supported-languages.ts
deleted file mode 100644
index 0adc1332..00000000
--- a/apps/web/src/lib/transcription/supported-languages.ts
+++ /dev/null
@@ -1 +0,0 @@
-export { LANGUAGES as TRANSCRIPTION_LANGUAGES } from "./languages";
diff --git a/apps/web/src/lib/transcription/types.ts b/apps/web/src/lib/transcription/types.ts
deleted file mode 100644
index 7ab0da7f..00000000
--- a/apps/web/src/lib/transcription/types.ts
+++ /dev/null
@@ -1,47 +0,0 @@
-import type { LanguageCode } from "./languages";
-
-export type TranscriptionLanguage = LanguageCode | "auto";
-
-export interface TranscriptionSegment {
- text: string;
- start: number;
- end: number;
-}
-
-export interface TranscriptionResult {
- text: string;
- segments: TranscriptionSegment[];
- language: string;
-}
-
-export type TranscriptionStatus =
- | "idle"
- | "loading-model"
- | "transcribing"
- | "complete"
- | "error";
-
-export interface TranscriptionProgress {
- status: TranscriptionStatus;
- progress: number;
- message?: string;
-}
-
-export type TranscriptionModelId =
- | "whisper-tiny"
- | "whisper-small"
- | "whisper-medium"
- | "whisper-large-v3-turbo";
-
-export interface TranscriptionModel {
- id: TranscriptionModelId;
- name: string;
- huggingFaceId: string;
- description: string;
-}
-
-export interface CaptionChunk {
- text: string;
- startTime: number;
- duration: number;
-}