Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

feat(audio): record voiceovers against the timeline

Ola Adebayoc260113e83de
diff --git a/electron/electron-env.d.ts b/electron/electron-env.d.ts
index f6132b4f6..6de7a3cc4 100644
--- a/electron/electron-env.d.ts
+++ b/electron/electron-env.d.ts
@@ -297,6 +297,14 @@ interface Window {
canceled?: boolean;
message?: string;
}>;
+ // Persist an in-editor voiceover take (raw MediaRecorder bytes) under the
+ // recordings dir, so it outlives the session like every other asset.
+ saveRecordedVoiceover: (data: ArrayBuffer) => Promise<{
+ success: boolean;
+ path?: string;
+ message?: string;
+ error?: string;
+ }>;
setCurrentVideoPath: (path: string) => Promise<{ success: boolean }>;
setCurrentRecordingSession: (
session: import("../src/lib/recordingSession").RecordingSession | null,
diff --git a/electron/ipc/handlers.ts b/electron/ipc/handlers.ts
index b3ad77fab..da90759ee 100644
--- a/electron/ipc/handlers.ts
+++ b/electron/ipc/handlers.ts
@@ -107,6 +107,9 @@ const ALLOWED_IMPORT_VIDEO_EXTENSIONS = new Set([
".ts",
]);
const PREVIEW_AUDIO_DIR = path.join(app.getPath("userData"), "preview-audio");
+// See the save-recorded-voiceover handler: an upper bound on renderer-supplied
+// bytes written to disk, well past any plausible take.
+const MAX_RECORDED_VOICEOVER_BYTES = 512 * 1024 * 1024;
const nativeMacCaptureEvents = new EventEmitter();
// Enumeration walks every display and window and grabs a thumbnail of each, so it
@@ -3741,6 +3744,35 @@ export function registerIpcHandlers(
}
});
+ // In-editor voiceover recording: the renderer hands over the raw MediaRecorder
+ // blob (webm/opus) and gets back the path it landed at, under the recordings
+ // dir so it lives with the project's other media and survives relaunches.
+ ipcMain.handle("save-recorded-voiceover", async (_event, data: ArrayBuffer) => {
+ try {
+ if (!(data instanceof ArrayBuffer) || data.byteLength === 0) {
+ return { success: false, message: "Empty recording" };
+ }
+ // A cap, because this writes renderer-supplied bytes straight to disk. An
+ // hour of Opus is a few tens of MB, so 512 MB is far past any real take
+ // and still refuses a runaway or malformed payload before it is buffered.
+ if (data.byteLength > MAX_RECORDED_VOICEOVER_BYTES) {
+ return { success: false, message: "Recording too large" };
+ }
+ await fs.mkdir(RECORDINGS_DIR, { recursive: true });
+ const fileName = `voiceover-${new Date().toISOString().replace(/[:.]/g, "-")}.webm`;
+ const target = path.join(RECORDINGS_DIR, fileName);
+ await fs.writeFile(target, Buffer.from(data));
+ return { success: true, path: target };
+ } catch (error) {
+ console.error("Failed to save recorded voiceover:", error);
+ return {
+ success: false,
+ message: "Failed to save recorded voiceover",
+ error: String(error),
+ };
+ }
+ });
+
ipcMain.handle("reveal-in-folder", async (_, filePath: string) => {
try {
// showItemInFolder returns nothing, it throws on error
diff --git a/electron/preload.ts b/electron/preload.ts
index 16227f110..7873bef90 100644
--- a/electron/preload.ts
+++ b/electron/preload.ts
@@ -279,6 +279,9 @@ contextBridge.exposeInMainWorld("electronAPI", {
openAudioFilePicker: () => {
return ipcRenderer.invoke("open-audio-file-picker");
},
+ saveRecordedVoiceover: (data: ArrayBuffer) => {
+ return ipcRenderer.invoke("save-recorded-voiceover", data);
+ },
setCurrentVideoPath: (path: string) => {
return ipcRenderer.invoke("set-current-video-path", path);
},
diff --git a/src/components/ai-edition/NewEditorShell.tsx b/src/components/ai-edition/NewEditorShell.tsx
index 7360757d8..217b1ba29 100644
--- a/src/components/ai-edition/NewEditorShell.tsx
+++ b/src/components/ai-edition/NewEditorShell.tsx
@@ -45,6 +45,7 @@ import {
import { Preview } from "./Preview";
import type { TrimTarget } from "./RightPanes";
import { importPendingRecording } from "./recordingImport";
+import { AddAudioLayerDialog } from "./v4/AddAudioLayerDialog";
import v4 from "./v4/EditorShellV4.module.css";
import { type EditorMode, EditorTopBar } from "./v4/EditorTopBar";
import { type Facet, FloatingInspector } from "./v4/FloatingInspector";
@@ -786,6 +787,50 @@ export function NewEditorShell() {
});
}, []);
+ // Voiceover recording (the one audio gesture that is not a file import). The
+ // dialog owns the mic; the shell owns the transport and the placement.
+ const [voiceoverFlow, setVoiceoverFlow] = useState<{ maxDurationSec: number } | null>(null);
+ // The playhead as it was when RECORDING STARTED. Recording plays the video so
+ // the user can narrate what they see, which means the live playhead has moved
+ // on by the take's own length by the time the take ends — reading it then
+ // placed every voiceover one full take-length to the right of where it was
+ // spoken. Captured on the way in, used on the way out.
+ const voiceoverStartSecRef = useRef(0);
+
+ const openVoiceoverFlow = useCallback(() => {
+ const doc = useProjectStore.getState().document;
+ if (!doc) return;
+ const total = doc.timeline.clips.reduce((max, c) => Math.max(max, c.timelineEndSec), 0);
+ const playhead = useProjectStore.getState().currentTimeSec;
+ voiceoverStartSecRef.current = playhead;
+ // Recording stops itself at the end of the timeline: a take can never
+ // outlive the video it was recorded over.
+ setVoiceoverFlow({ maxDurationSec: Math.max(0.5, total - playhead) });
+ }, []);
+
+ const handleVoiceoverRecordingStart = useCallback(() => {
+ // Re-capture: the user may have scrubbed between opening the dialog and
+ // hitting Record, and playback starts from wherever the playhead is now.
+ voiceoverStartSecRef.current = useProjectStore.getState().currentTimeSec;
+ if (videoElement?.paused) void videoElement.play().catch(() => undefined);
+ }, [videoElement]);
+
+ const handleVoiceoverRecordingStop = useCallback(() => {
+ videoElement?.pause();
+ }, [videoElement]);
+
+ const handleVoiceoverReady = useCallback(
+ async (assetId: string, durationSec: number) => {
+ setVoiceoverFlow(null);
+ await tl.addAudioTrack(assetId, voiceoverStartSecRef.current, {
+ kind: "voiceover",
+ durationSec,
+ spanSec: durationSec,
+ });
+ },
+ [tl],
+ );
+
const pasteRegion = useCallback(async () => {
const doc = useProjectStore.getState().document;
if (!doc) return;
@@ -1110,6 +1155,11 @@ export function NewEditorShell() {
void tl.addAudio();
return;
}
+ if (matchesShortcut(e, shortcuts.addVoiceover, isMac)) {
+ e.preventDefault();
+ openVoiceoverFlow();
+ return;
+ }
if (matchesShortcut(e, shortcuts.addSpeed, isMac)) {
e.preventDefault();
void tl.addSpeed(newRegionDurationSec());
@@ -1468,6 +1518,16 @@ export function NewEditorShell() {
onChoose={handleConfirmUnsaved}
/>
<ExportDialog open={exportOpen} onClose={() => setExportOpen(false)} document={document} />
+ <AddAudioLayerDialog
+ open={voiceoverFlow !== null}
+ maxDurationSec={voiceoverFlow?.maxDurationSec ?? 0}
+ onClose={() => setVoiceoverFlow(null)}
+ onComplete={(assetId, durationSec) => {
+ void handleVoiceoverReady(assetId, durationSec);
+ }}
+ onRecordingStart={handleVoiceoverRecordingStart}
+ onRecordingStop={handleVoiceoverRecordingStop}
+ />
</div>
);
}
diff --git a/src/components/ai-edition/v4/AddAudioLayerDialog.test.tsx b/src/components/ai-edition/v4/AddAudioLayerDialog.test.tsx
new file mode 100644
index 000000000..1f255eab9
--- /dev/null
+++ b/src/components/ai-edition/v4/AddAudioLayerDialog.test.tsx
@@ -0,0 +1,110 @@
+// @vitest-environment jsdom
+import "@testing-library/jest-dom";
+import { fireEvent, render, screen } from "@testing-library/react";
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+import { AddAudioLayerDialog } from "./AddAudioLayerDialog";
+
+vi.mock("@/contexts/I18nContext", () => ({
+ useScopedT: () => (key: string) => key,
+ useI18n: () => ({ locale: "en", setLocale: () => undefined }),
+}));
+
+const addAudioAsset = vi.fn();
+vi.mock("@/lib/ai-edition/store/projectStore", () => ({
+ useProjectStore: {
+ getState: () => ({ document: { assets: [] }, addAudioAsset }),
+ },
+}));
+
+vi.mock("@/lib/ai-edition/timeline/duration", () => ({
+ probeAudioDuration: vi.fn(async () => 3),
+}));
+
+/** A MediaRecorder stand-in that records whether it was ever stopped. */
+class FakeRecorder {
+ static instances: FakeRecorder[] = [];
+ state: "inactive" | "recording" = "inactive";
+ stopped = false;
+ ondataavailable: ((e: { data: Blob }) => void) | null = null;
+ onstop: (() => void) | null = null;
+ mimeType = "audio/webm";
+ constructor() {
+ FakeRecorder.instances.push(this);
+ }
+ static isTypeSupported() {
+ return true;
+ }
+ start() {
+ this.state = "recording";
+ }
+ stop() {
+ this.stopped = true;
+ this.state = "inactive";
+ this.onstop?.();
+ }
+}
+
+const stopTrack = vi.fn();
+
+beforeEach(() => {
+ FakeRecorder.instances = [];
+ stopTrack.mockClear();
+ addAudioAsset.mockReset();
+ vi.stubGlobal("MediaRecorder", FakeRecorder);
+ Object.defineProperty(navigator, "mediaDevices", {
+ configurable: true,
+ value: { getUserMedia: vi.fn(async () => ({ getTracks: () => [{ stop: stopTrack }] })) },
+ });
+});
+
+afterEach(() => {
+ vi.unstubAllGlobals();
+});
+
+function renderDialog(over: Partial<Parameters<typeof AddAudioLayerDialog>[0]> = {}) {
+ const props = {
+ open: true,
+ maxDurationSec: 60,
+ onClose: vi.fn(),
+ onComplete: vi.fn(),
+ onRecordingStart: vi.fn(),
+ onRecordingStop: vi.fn(),
+ ...over,
+ };
+ const view = render(<AddAudioLayerDialog {...props} />);
+ return { ...view, props };
+}
+
+describe("AddAudioLayerDialog", () => {
+ it("tells the shell when a take starts, so it can capture the playhead", async () => {
+ // The shell reads the playhead HERE, not when the take ends: recording
+ // plays the video, so by the end the live playhead has advanced by the
+ // take's own length. Every voiceover used to land that far to the right.
+ const { props } = renderDialog();
+ fireEvent.click(screen.getByText("audio.record"));
+ await vi.waitFor(() => expect(props.onRecordingStart).toHaveBeenCalledTimes(1));
+ });
+
+ it("stops the recorder when the dialog is torn down mid-take", async () => {
+ const { unmount, props } = renderDialog();
+ fireEvent.click(screen.getByText("audio.record"));
+ await vi.waitFor(() => expect(FakeRecorder.instances).toHaveLength(1));
+
+ unmount();
+
+ // Without this the take was never flushed, `onRecordingStop` never fired,
+ // and the video element was left playing after the shell went away.
+ expect(FakeRecorder.instances[0].stopped).toBe(true);
+ expect(props.onRecordingStop).toHaveBeenCalled();
+ // The microphone is released too.
+ expect(stopTrack).toHaveBeenCalled();
+ });
+
+ it("does not import a take that was discarded by the teardown", async () => {
+ const { unmount } = renderDialog();
+ fireEvent.click(screen.getByText("audio.record"));
+ await vi.waitFor(() => expect(FakeRecorder.instances).toHaveLength(1));
+ unmount();
+ expect(addAudioAsset).not.toHaveBeenCalled();
+ });
+});
diff --git a/src/components/ai-edition/v4/AddAudioLayerDialog.tsx b/src/components/ai-edition/v4/AddAudioLayerDialog.tsx
new file mode 100644
index 000000000..85f69e3b6
--- /dev/null
+++ b/src/components/ai-edition/v4/AddAudioLayerDialog.tsx
@@ -0,0 +1,333 @@
+// Voiceover dialog: record a narration take against the timeline, live from the
+// microphone (MediaRecorder → webm/opus, written to the recordings dir by the
+// main process), or import a file if the user already has one.
+//
+// Music and other imports do NOT come through here — they are a plain file
+// import on the timeline toolbar (`tl.addAudio`). Recording is the only audio
+// gesture that needs a dialog, because it has a live state to show.
+//
+// The dialog resolves the AUDIO ASSET and its duration, then reports back via
+// `onComplete` — placing the track on the timeline (span, anchor, inspector
+// selection) is the caller's job, exactly like the other add* flows.
+
+import { Mic, StopCircle, Upload } from "lucide-react";
+import { useCallback, useEffect, useRef, useState } from "react";
+import { toast } from "sonner";
+import { toFileUrl } from "@/components/video-editor/projectPersistence";
+import { useScopedT } from "@/contexts/I18nContext";
+import type { AxcutAsset } from "@/lib/ai-edition/schema";
+import { useProjectStore } from "@/lib/ai-edition/store/projectStore";
+import { probeAudioDuration } from "@/lib/ai-edition/timeline/duration";
+import { ModalShell } from "../Modals";
+
+const RECORDER_MIME_PREFERENCES = ["audio/webm;codecs=opus", "audio/webm", "audio/mp4"];
+
+function pickRecorderMimeType(): string {
+ if (typeof MediaRecorder === "undefined") return "";
+ for (const mime of RECORDER_MIME_PREFERENCES) {
+ if (MediaRecorder.isTypeSupported(mime)) return mime;
+ }
+ return "";
+}
+
+/** Reuse an already-imported asset over importing the same file twice. */
+function findExistingAsset(path: string): AxcutAsset | null {
+ const doc = useProjectStore.getState().document;
+ if (!doc) return null;
+ return (
+ doc.assets.find((a) => a.kind === "audio" && a.originalPath === path) ??
+ doc.assets.find((a) => a.originalPath === path) ??
+ null
+ );
+}
+
+export function AddAudioLayerDialog({
+ open,
+ /** Timeline length in seconds — recording stops by itself when reached. */
+ maxDurationSec,
+ onClose,
+ onComplete,
+ onRecordingStart,
+ onRecordingStop,
+}: {
+ open: boolean;
+ maxDurationSec: number;
+ onClose: () => void;
+ onComplete: (assetId: string, durationSec: number) => void;
+ onRecordingStart: () => void;
+ onRecordingStop: () => void;
+}) {
+ const t = useScopedT("timeline");
+ const [busy, setBusy] = useState(false);
+ const [recording, setRecording] = useState(false);
+ const [elapsedSec, setElapsedSec] = useState(0);
+ const recorderRef = useRef<MediaRecorder | null>(null);
+ const streamRef = useRef<MediaStream | null>(null);
+ const chunksRef = useRef<Blob[]>([]);
+ const startedAtRef = useRef(0);
+ const timerRef = useRef<ReturnType<typeof setInterval> | null>(null);
+ // Set when the user cancels (closes the dialog mid-take) — the stop handler
+ // then discards the blob instead of importing it as a layer.
+ const discardRef = useRef(false);
+
+ // Reset whenever the dialog opens again — a cancelled recording must not
+ // leak its stream or timer into the next session.
+ useEffect(() => {
+ if (open) {
+ setBusy(false);
+ setRecording(false);
+ setElapsedSec(0);
+ }
+ return () => {
+ if (timerRef.current) clearInterval(timerRef.current);
+ timerRef.current = null;
+ // Stop the RECORDER, not just the stream. Tearing the dialog down
+ // mid-take (a project close, a shell unmount) used to drop the take on
+ // the floor: `onstop` never fired, so the blob was never flushed and
+ // `onRecordingStop` never ran — leaving the video element playing.
+ // Discard rather than import: nobody is left to place the layer.
+ const recorder = recorderRef.current;
+ if (recorder && recorder.state !== "inactive") {
+ discardRef.current = true;
+ try {
+ recorder.stop();
+ } catch {
+ // already torn down by the browser
+ }
+ }
+ for (const track of streamRef.current?.getTracks() ?? []) track.stop();
+ streamRef.current = null;
+ recorderRef.current = null;
+ };
+ }, [open]);
+
+ const stopRecording = useCallback(() => {
+ if (timerRef.current) {
+ clearInterval(timerRef.current);
+ timerRef.current = null;
+ }
+ const recorder = recorderRef.current;
+ // `recorder.onstop` (registered at start) owns the save path.
+ if (recorder && recorder.state !== "inactive") {
+ recorder.stop();
+ }
+ for (const track of streamRef.current?.getTracks() ?? []) track.stop();
+ streamRef.current = null;
+ }, []);
+
+ const cancelRecording = useCallback(() => {
+ discardRef.current = true;
+ stopRecording();
+ onRecordingStop();
+ setRecording(false);
+ setElapsedSec(0);
+ }, [stopRecording, onRecordingStop]);
+
+ const finishWithPath = useCallback(
+ async (path: string, durationSec: number) => {
+ setBusy(true);
+ try {
+ const existing = findExistingAsset(path);
+ // `addAudioAsset` files it as audio explicitly: a recorded voiceover
+ // lands as `.webm`, the same extension as a screen recording, so
+ // extension guessing would import it as a video asset.
+ const asset = existing ?? (await useProjectStore.getState().addAudioAsset(path));
+ if (!asset) {
+ toast.error(t("audio.importFailed"));
+ return;
+ }
+ onComplete(asset.id, durationSec);
+ } catch (err) {
+ toast.error(t("audio.importFailed"), {
+ description: err instanceof Error ? err.message : String(err),
+ });
+ } finally {
+ setBusy(false);
+ }
+ },
+ [onComplete, t],
+ );
+
+ const startRecording = useCallback(async () => {
+ if (typeof navigator === "undefined" || !navigator.mediaDevices?.getUserMedia) {
+ toast.error(t("audio.recordingUnavailable"));
+ return;
+ }
+ try {
+ const stream = await navigator.mediaDevices.getUserMedia({
+ audio: { echoCancellation: true, noiseSuppression: true },
+ });
+ streamRef.current = stream;
+ const mimeType = pickRecorderMimeType();
+ const recorder = mimeType
+ ? new MediaRecorder(stream, { mimeType })
+ : new MediaRecorder(stream);
+ recorderRef.current = recorder;
+ chunksRef.current = [];
+ recorder.ondataavailable = (event) => {
+ if (event.data.size > 0) chunksRef.current.push(event.data);
+ };
+ recorder.onstop = () => {
+ const blob = new Blob(chunksRef.current, {
+ type: recorder.mimeType || "audio/webm",
+ });
+ const duration = (performance.now() - startedAtRef.current) / 1000;
+ const discarded = discardRef.current;
+ discardRef.current = false;
+ setRecording(false);
+ setElapsedSec(0);
+ onRecordingStop();
+ if (discarded) return;
+ void (async () => {
+ try {
+ const data = await blob.arrayBuffer();
+ const saved = window.electronAPI?.saveRecordedVoiceover
+ ? await window.electronAPI.saveRecordedVoiceover(data)
+ : { success: false as const };
+ if (saved.success && saved.path) {
+ await finishWithPath(saved.path, duration);
+ } else {
+ // Browser-mode fallback: no main process to persist the
+ // blob, so the layer references the in-memory blob URL —
+ // good for the session, gone on reload.
+ const url = URL.createObjectURL(blob);
+ await finishWithPath(url, duration);
+ }
+ } catch (err) {
+ toast.error(t("audio.saveFailed"), {
+ description: err instanceof Error ? err.message : String(err),
+ });
+ }
+ })();
+ };
+ startedAtRef.current = performance.now();
+ discardRef.current = false;
+ recorder.start(250);
+ setRecording(true);
+ setElapsedSec(0);
+ onRecordingStart();
+ timerRef.current = setInterval(() => {
+ setElapsedSec((performance.now() - startedAtRef.current) / 1000);
+ }, 200);
+ } catch {
+ toast.error(t("audio.micDenied"));
+ }
+ }, [finishWithPath, onRecordingStart, onRecordingStop, t]);
+
+ // Stop by itself at the end of the timeline so a layer can never outlive
+ // the video it was recorded over.
+ useEffect(() => {
+ if (!recording || !Number.isFinite(maxDurationSec) || maxDurationSec <= 0) return;
+ if (elapsedSec >= maxDurationSec) {
+ stopRecording();
+ // `onRecordingStop` fires from the recorder's stop handler.
+ }
+ }, [recording, elapsedSec, maxDurationSec, stopRecording]);
+
+ // Re-entrancy guard: the shell passes an inline `onComplete` and re-renders on
+ // every playhead tick during playback, so a dialog left open while the video
+ // plays re-creates this callback constantly. Without the guard a second click
+ // (or any caller that fires on re-render) would stack `showOpenDialog` calls.
+ const pickerOpenRef = useRef(false);
+
+ const importFile = useCallback(async () => {
+ if (pickerOpenRef.current) return;
+ pickerOpenRef.current = true;
+ try {
+ const picker = await window.electronAPI?.openAudioFilePicker?.();
+ if (!picker?.success || !picker.path) return;
+ const url = toFileUrl(picker.path);
+ // The probe needs the real duration to size the layer; when it fails the
+ // caller falls back to the default span.
+ const duration = (await probeAudioDuration(url)) ?? 0;
+ await finishWithPath(picker.path, duration);
+ } finally {
+ pickerOpenRef.current = false;
+ }
+ }, [finishWithPath]);
+
+ const buttonStyle: React.CSSProperties = {
+ display: "flex",
+ alignItems: "center",
+ justifyContent: "center",
+ gap: 8,
+ padding: "10px 14px",
+ borderRadius: 10,
+ border: "1px solid var(--border)",
+ background: "var(--bg-2)",
+ color: "var(--fg-1)",
+ font: "600 13px var(--font-display)",
+ cursor: "pointer",
+ };
+
+ return (
+ <ModalShell
+ open={open}
+ onClose={() => {
+ if (recording) cancelRecording();
+ onClose();
+ }}
+ title={t("audio.addVoiceover")}
+ subtitle={t("audio.subtitle")}
+ >
+ <div style={{ display: "flex", flexDirection: "column", gap: 12 }}>
+ {recording ? (
+ <div
+ style={{
+ display: "flex",
+ flexDirection: "column",
+ alignItems: "center",
+ gap: 12,
+ padding: "18px 0 8px",
+ }}
+ >
+ <span
+ style={{
+ display: "inline-flex",
+ alignItems: "center",
+ gap: 8,
+ color: "var(--danger)",
+ font: "600 13px var(--font-display)",
+ }}
+ >
+ <span
+ className="animate-pulse"
+ style={{
+ width: 10,
+ height: 10,
+ borderRadius: 999,
+ background: "var(--danger)",
+ }}
+ />
+ {t("audio.recording")} {elapsedSec.toFixed(1)}s
+ </span>
+ <button
+ type="button"
+ onClick={stopRecording}
+ style={{ ...buttonStyle, borderColor: "var(--danger)", color: "var(--danger)" }}
+ >
+ <StopCircle size={16} />
+ {t("audio.stop")}
+ </button>
+ </div>
+ ) : (
+ <>
+ <button type="button" onClick={() => void startRecording()} style={buttonStyle}>
+ <Mic size={16} />
+ {t("audio.record")}
+ </button>
+ <button
+ type="button"
+ onClick={() => void importFile()}
+ disabled={busy}
+ style={buttonStyle}
+ >
+ <Upload size={16} />
+ {t("audio.importFile")}
+ </button>
+ </>
+ )}
+ </div>
+ </ModalShell>
+ );
+}
diff --git a/src/i18n/locales/ar/shortcuts.json b/src/i18n/locales/ar/shortcuts.json
index f9a834289..137a0186e 100644
--- a/src/i18n/locales/ar/shortcuts.json
+++ b/src/i18n/locales/ar/shortcuts.json
@@ -21,6 +21,7 @@
"addSpeed": "إضافة سرعة",
"addAnnotation": "إضافة شرح",
"addAudio": "إضافة صوت",
+ "addVoiceover": "تسجيل تعليق صوتي",
"addKeyframe": "إضافة إطار رئيسي",
"addCameraFullscreen": "إضافة كاميرا كاملة الشاشة",
"deleteSelected": "حذف المحدد",
diff --git a/src/i18n/locales/ar/timeline.json b/src/i18n/locales/ar/timeline.json
index 598e9e625..8afd79109 100644
--- a/src/i18n/locales/ar/timeline.json
+++ b/src/i18n/locales/ar/timeline.json
@@ -87,5 +87,17 @@
"smartCutsNoAudio": "لا يحتوي هذا الملف على صوت",
"smartCutsNoSpeech": "لم يتم اكتشاف كلام",
"smartCutsFailed": "فشل النسخ — أعد المحاولة من قسم الوسائط"
+ },
+ "audio": {
+ "addVoiceover": "إضافة تعليق صوتي",
+ "subtitle": "ضع تعليقًا صوتيًا أو موسيقى خلفية على المخطط الزمني",
+ "record": "تسجيل تعليق صوتي",
+ "importFile": "استيراد ملف صوتي",
+ "recording": "جارٍ التسجيل",
+ "stop": "إيقاف",
+ "micDenied": "تم رفض الوصول إلى الميكروفون",
+ "recordingUnavailable": "التسجيل غير متاح هنا",
+ "saveFailed": "تعذر حفظ التسجيل",
+ "importFailed": "تعذر استيراد الملف الصوتي"
}
}
diff --git a/src/i18n/locales/en/shortcuts.json b/src/i18n/locales/en/shortcuts.json
index ab4e9e45d..99f3ce90a 100644
--- a/src/i18n/locales/en/shortcuts.json
+++ b/src/i18n/locales/en/shortcuts.json
@@ -21,6 +21,7 @@
"addSpeed": "Add Speed",
"addAnnotation": "Add Annotation",
"addAudio": "Add Audio",
+ "addVoiceover": "Record Voiceover",
"addKeyframe": "Add Keyframe",
"addCameraFullscreen": "Add Full Camera",
"deleteSelected": "Delete Selected",
diff --git a/src/i18n/locales/en/timeline.json b/src/i18n/locales/en/timeline.json
index d5e11e7e2..32f92a308 100644
--- a/src/i18n/locales/en/timeline.json
+++ b/src/i18n/locales/en/timeline.json
@@ -87,5 +87,17 @@
"smartCutsNoAudio": "This media has no audio",
"smartCutsNoSpeech": "No speech detected",
"smartCutsFailed": "Transcription failed — retry it from Media"
+ },
+ "audio": {
+ "addVoiceover": "Add Voiceover",
+ "subtitle": "Place a voiceover or background music layer on the timeline",
+ "record": "Record voiceover",
+ "importFile": "Import audio file",
+ "recording": "Recording",
+ "stop": "Stop",
+ "micDenied": "Microphone access was denied",
+ "recordingUnavailable": "Recording is not available here",
+ "saveFailed": "Could not save the recording",
+ "importFailed": "Could not import the audio file"
}
}
diff --git a/src/i18n/locales/es/shortcuts.json b/src/i18n/locales/es/shortcuts.json
index 7753389d2..688f218f0 100644
--- a/src/i18n/locales/es/shortcuts.json
+++ b/src/i18n/locales/es/shortcuts.json
@@ -21,6 +21,7 @@
"addSpeed": "Agregar velocidad",
"addAnnotation": "Agregar anotación",
"addAudio": "Añadir audio",
+ "addVoiceover": "Grabar voz en off",
"addKeyframe": "Agregar fotograma clave",
"addCameraFullscreen": "Agregar cámara a pantalla completa",
"deleteSelected": "Eliminar seleccionado",
diff --git a/src/i18n/locales/es/timeline.json b/src/i18n/locales/es/timeline.json
index 2c2e64f4f..9c27f7183 100644
--- a/src/i18n/locales/es/timeline.json
+++ b/src/i18n/locales/es/timeline.json
@@ -87,5 +87,17 @@
"smartCutsNoAudio": "Este medio no tiene audio",
"smartCutsNoSpeech": "No se detectó voz",
"smartCutsFailed": "La transcripción falló: reinténtala desde Medios"
+ },
+ "audio": {
+ "addVoiceover": "Añadir voz en off",
+ "subtitle": "Coloca una capa de voz en off o de música de fondo en la línea de tiempo",
+ "record": "Grabar voz en off",
+ "importFile": "Importar archivo de audio",
+ "recording": "Grabando",
+ "stop": "Detener",
+ "micDenied": "Se denegó el acceso al micrófono",
+ "recordingUnavailable": "La grabación no está disponible aquí",
+ "saveFailed": "No se pudo guardar la grabación",
+ "importFailed": "No se pudo importar el archivo de audio"
}
}
diff --git a/src/i18n/locales/fr/shortcuts.json b/src/i18n/locales/fr/shortcuts.json
index 93ff5af11..3b28fca17 100644
--- a/src/i18n/locales/fr/shortcuts.json
+++ b/src/i18n/locales/fr/shortcuts.json
@@ -21,6 +21,7 @@
"addSpeed": "Ajouter une vitesse",
"addAnnotation": "Ajouter une annotation",
"addAudio": "Ajouter un audio",
+ "addVoiceover": "Enregistrer une voix off",
"addKeyframe": "Ajouter une image-clé",
"addCameraFullscreen": "Ajouter une caméra en plein écran",
"deleteSelected": "Supprimer la sélection",
diff --git a/src/i18n/locales/fr/timeline.json b/src/i18n/locales/fr/timeline.json
index aef72afba..7bd74724e 100644
--- a/src/i18n/locales/fr/timeline.json
+++ b/src/i18n/locales/fr/timeline.json
@@ -87,5 +87,17 @@
"smartCutsNoAudio": "Ce média n'a pas d'audio",
"smartCutsNoSpeech": "Aucune parole détectée",
"smartCutsFailed": "Échec de la transcription — relancez-la depuis Médias"
+ },
+ "audio": {
+ "addVoiceover": "Ajouter une voix off",
+ "subtitle": "Placez une couche de voix off ou de musique de fond sur la timeline",
+ "record": "Enregistrer une voix off",
+ "importFile": "Importer un fichier audio",
+ "recording": "Enregistrement",
+ "stop": "Arrêter",
+ "micDenied": "L'accès au micro a été refusé",
+ "recordingUnavailable": "L'enregistrement n'est pas disponible ici",
+ "saveFailed": "Impossible d'enregistrer la capture",
+ "importFailed": "Impossible d'importer le fichier audio"
}
}
diff --git a/src/i18n/locales/it/shortcuts.json b/src/i18n/locales/it/shortcuts.json
index 5e7eeee42..0940258b2 100644
--- a/src/i18n/locales/it/shortcuts.json
+++ b/src/i18n/locales/it/shortcuts.json
@@ -21,6 +21,7 @@
"addSpeed": "Aggiungi velocità",
"addAnnotation": "Aggiungi annotazione",
"addAudio": "Aggiungi audio",
+ "addVoiceover": "Registra voce fuori campo",
"addKeyframe": "Aggiungi fotogramma chiave",
"addCameraFullscreen": "Aggiungi Camera a schermo intero",
"deleteSelected": "Elimina selezionato",
diff --git a/src/i18n/locales/it/timeline.json b/src/i18n/locales/it/timeline.json
index 1fe62947d..50167bc04 100644
--- a/src/i18n/locales/it/timeline.json
+++ b/src/i18n/locales/it/timeline.json
@@ -87,5 +87,17 @@
"smartCutsNoAudio": "Questo contenuto non ha audio",
"smartCutsNoSpeech": "Nessun parlato rilevato",
"smartCutsFailed": "Trascrizione non riuscita: riprova da Contenuti multimediali"
+ },
+ "audio": {
+ "addVoiceover": "Aggiungi voce fuori campo",
+ "subtitle": "Posiziona un livello di voce fuori campo o di musica di sottofondo sulla timeline",
+ "record": "Registra voce fuori campo",
+ "importFile": "Importa file audio",
+ "recording": "Registrazione",
+ "stop": "Ferma",
+ "micDenied": "Accesso al microfono negato",
+ "recordingUnavailable": "La registrazione non è disponibile qui",
+ "saveFailed": "Impossibile salvare la registrazione",
+ "importFailed": "Impossibile importare il file audio"
}
}
diff --git a/src/i18n/locales/ja-JP/shortcuts.json b/src/i18n/locales/ja-JP/shortcuts.json
index 1d994fb68..82f1c2291 100644
--- a/src/i18n/locales/ja-JP/shortcuts.json
+++ b/src/i18n/locales/ja-JP/shortcuts.json
@@ -21,6 +21,7 @@
"addSpeed": "速度を追加",
"addAnnotation": "注釈を追加",
"addAudio": "音声を追加",
+ "addVoiceover": "ナレーションを録音",
"addKeyframe": "キーフレームを追加",
"addCameraFullscreen": "フルスクリーンカメラを追加",
"deleteSelected": "選択を削除",
diff --git a/src/i18n/locales/ja-JP/timeline.json b/src/i18n/locales/ja-JP/timeline.json
index 7a5f983d8..1360da918 100644
--- a/src/i18n/locales/ja-JP/timeline.json
+++ b/src/i18n/locales/ja-JP/timeline.json
@@ -87,5 +87,17 @@
"smartCutsNoAudio": "このメディアには音声がありません",
"smartCutsNoSpeech": "音声が検出されませんでした",
"smartCutsFailed": "文字起こしに失敗しました — メディアから再試行してください"
+ },
+ "audio": {
+ "addVoiceover": "ナレーションを追加",
+ "subtitle": "タイムラインにナレーションまたは BGM のレイヤーを配置します",
+ "record": "ナレーションを録音",
+ "importFile": "音声ファイルを読み込む",
+ "recording": "録音中",
+ "stop": "停止",
+ "micDenied": "マイクへのアクセスが拒否されました",
+ "recordingUnavailable": "ここでは録音できません",
+ "saveFailed": "録音を保存できませんでした",
+ "importFailed": "音声ファイルを読み込めませんでした"
}
}
diff --git a/src/i18n/locales/ko-KR/shortcuts.json b/src/i18n/locales/ko-KR/shortcuts.json
index 82ec503ed..86f0693ea 100644
--- a/src/i18n/locales/ko-KR/shortcuts.json
+++ b/src/i18n/locales/ko-KR/shortcuts.json
@@ -21,6 +21,7 @@
"addSpeed": "속도 추가",
"addAnnotation": "주석 추가",
"addAudio": "오디오 추가",
+ "addVoiceover": "보이스오버 녹음",
"addKeyframe": "키프레임 추가",
"addCameraFullscreen": "전체 화면 카메라 추가",
"deleteSelected": "선택 항목 삭제",
diff --git a/src/i18n/locales/ko-KR/timeline.json b/src/i18n/locales/ko-KR/timeline.json
index 36daae802..64f39b19d 100644
--- a/src/i18n/locales/ko-KR/timeline.json
+++ b/src/i18n/locales/ko-KR/timeline.json
@@ -87,5 +87,17 @@
"smartCutsNoAudio": "이 미디어에는 오디오가 없습니다",
"smartCutsNoSpeech": "음성이 감지되지 않음",
"smartCutsFailed": "받아쓰기에 실패했습니다 — 미디어에서 다시 시도하세요"
+ },
+ "audio": {
+ "addVoiceover": "내레이션 추가",
+ "subtitle": "타임라인에 내레이션 또는 배경 음악 레이어를 배치합니다",
+ "record": "내레이션 녹음",
+ "importFile": "오디오 파일 가져오기",
+ "recording": "녹음 중",
+ "stop": "중지",
+ "micDenied": "마이크 접근이 거부되었습니다",
+ "recordingUnavailable": "여기에서는 녹음할 수 없습니다",
+ "saveFailed": "녹음을 저장하지 못했습니다",
+ "importFailed": "오디오 파일을 가져오지 못했습니다"
}
}
diff --git a/src/i18n/locales/pt-BR/shortcuts.json b/src/i18n/locales/pt-BR/shortcuts.json
index ea7787c1d..5f5506aec 100644
--- a/src/i18n/locales/pt-BR/shortcuts.json
+++ b/src/i18n/locales/pt-BR/shortcuts.json
@@ -21,6 +21,7 @@
"addSpeed": "Adicionar Velocidade",
"addAnnotation": "Adicionar Anotação",
"addAudio": "Adicionar áudio",
+ "addVoiceover": "Gravar narração",
"addKeyframe": "Adicionar Quadro-chave",
"addCameraFullscreen": "Adicionar Câmera em Tela Cheia",
"deleteSelected": "Excluir Selecionado",
diff --git a/src/i18n/locales/pt-BR/timeline.json b/src/i18n/locales/pt-BR/timeline.json
index 748ac7486..b86c5511b 100644
--- a/src/i18n/locales/pt-BR/timeline.json
+++ b/src/i18n/locales/pt-BR/timeline.json
@@ -87,5 +87,17 @@
"smartCutsNoAudio": "Esta mídia não tem áudio",
"smartCutsNoSpeech": "Nenhuma fala detectada",
"smartCutsFailed": "Falha na transcrição — tente de novo em Mídia"
+ },
+ "audio": {
+ "addVoiceover": "Adicionar narração",
+ "subtitle": "Coloque uma camada de narração ou de música de fundo na linha do tempo",
+ "record": "Gravar narração",
+ "importFile": "Importar arquivo de áudio",
+ "recording": "Gravando",
+ "stop": "Parar",
+ "micDenied": "Acesso ao microfone negado",
+ "recordingUnavailable": "A gravação não está disponível aqui",
+ "saveFailed": "Não foi possível salvar a gravação",
+ "importFailed": "Não foi possível importar o arquivo de áudio"
}
}
diff --git a/src/i18n/locales/ru/shortcuts.json b/src/i18n/locales/ru/shortcuts.json
index ce5747ea4..eb94af5fc 100644
--- a/src/i18n/locales/ru/shortcuts.json
+++ b/src/i18n/locales/ru/shortcuts.json
@@ -21,6 +21,7 @@
"addSpeed": "Изменить скорость",
"addAnnotation": "Добавить аннотацию",
"addAudio": "Добавить аудио",
+ "addVoiceover": "Записать закадровый голос",
"addKeyframe": "Добавить ключевой кадр",
"addCameraFullscreen": "Добавить камеру на весь экран",
"deleteSelected": "Удалить выбранное",
diff --git a/src/i18n/locales/ru/timeline.json b/src/i18n/locales/ru/timeline.json
index 8ee40a66c..c8d6b4ce2 100644
--- a/src/i18n/locales/ru/timeline.json
+++ b/src/i18n/locales/ru/timeline.json
@@ -87,5 +87,17 @@
"smartCutsNoAudio": "В этом медиафайле нет звука",
"smartCutsNoSpeech": "Речь не обнаружена",
"smartCutsFailed": "Не удалось расшифровать — повторите из раздела «Медиа»"
+ },
+ "audio": {
+ "addVoiceover": "Добавить озвучку",
+ "subtitle": "Разместите слой озвучки или фоновой музыки на таймлайне",
+ "record": "Записать озвучку",
+ "importFile": "Импортировать аудиофайл",
+ "recording": "Запись",
+ "stop": "Остановить",
+ "micDenied": "Доступ к микрофону запрещён",
+ "recordingUnavailable": "Запись здесь недоступна",
+ "saveFailed": "Не удалось сохранить запись",
+ "importFailed": "Не удалось импортировать аудиофайл"
}
}
diff --git a/src/i18n/locales/tr/shortcuts.json b/src/i18n/locales/tr/shortcuts.json
index b670fdbc4..2da862f01 100644
--- a/src/i18n/locales/tr/shortcuts.json
+++ b/src/i18n/locales/tr/shortcuts.json
@@ -21,6 +21,7 @@
"addSpeed": "Hız Ekle",
"addAnnotation": "Açıklama Ekle",
"addAudio": "Ses ekle",
+ "addVoiceover": "Seslendirme kaydet",
"addKeyframe": "Anahtar Kare Ekle",
"addCameraFullscreen": "Tam Ekran Kamera Ekle",
"deleteSelected": "Seçileni Sil",
diff --git a/src/i18n/locales/tr/timeline.json b/src/i18n/locales/tr/timeline.json
index 2a6481612..1aaff743a 100644
--- a/src/i18n/locales/tr/timeline.json
+++ b/src/i18n/locales/tr/timeline.json
@@ -87,5 +87,17 @@
"smartCutsNoAudio": "Bu medyada ses yok",
"smartCutsNoSpeech": "Konuşma algılanmadı",
"smartCutsFailed": "Metne dökme başarısız — Medya bölümünden yeniden deneyin"
+ },
+ "audio": {
+ "addVoiceover": "Seslendirme ekle",
+ "subtitle": "Zaman çizelgesine seslendirme veya fon müziği katmanı yerleştirin",
+ "record": "Seslendirme kaydet",
+ "importFile": "Ses dosyası içe aktar",
+ "recording": "Kaydediliyor",
+ "stop": "Durdur",
+ "micDenied": "Mikrofon erişimi reddedildi",
+ "recordingUnavailable": "Burada kayıt kullanılamıyor",
+ "saveFailed": "Kayıt kaydedilemedi",
+ "importFailed": "Ses dosyası içe aktarılamadı"
}
}
diff --git a/src/i18n/locales/vi/shortcuts.json b/src/i18n/locales/vi/shortcuts.json
index 6ffb15e98..448de3cfe 100644
--- a/src/i18n/locales/vi/shortcuts.json
+++ b/src/i18n/locales/vi/shortcuts.json
@@ -21,6 +21,7 @@
"addSpeed": "Thêm Tốc độ",
"addAnnotation": "Thêm Chú thích",
"addAudio": "Thêm âm thanh",
+ "addVoiceover": "Ghi âm lời thuyết minh",
"addKeyframe": "Thêm Khung hình chính",
"addCameraFullscreen": "Thêm Camera Toàn màn hình",
"deleteSelected": "Xóa mục đã chọn",
diff --git a/src/i18n/locales/vi/timeline.json b/src/i18n/locales/vi/timeline.json
index 25f55bd19..2cf0a1d68 100644
--- a/src/i18n/locales/vi/timeline.json
+++ b/src/i18n/locales/vi/timeline.json
@@ -87,5 +87,17 @@
"smartCutsNoAudio": "Media này không có âm thanh",
"smartCutsNoSpeech": "Không phát hiện giọng nói",
"smartCutsFailed": "Phiên âm thất bại — thử lại trong Media"
+ },
+ "audio": {
+ "addVoiceover": "Thêm thuyết minh",
+ "subtitle": "Đặt lớp thuyết minh hoặc nhạc nền lên dòng thời gian",
+ "record": "Ghi âm thuyết minh",
+ "importFile": "Nhập tệp âm thanh",
+ "recording": "Đang ghi",
+ "stop": "Dừng",
+ "micDenied": "Quyền truy cập micrô bị từ chối",
+ "recordingUnavailable": "Không thể ghi âm ở đây",
+ "saveFailed": "Không thể lưu bản ghi",
+ "importFailed": "Không thể nhập tệp âm thanh"
}
}
diff --git a/src/i18n/locales/zh-CN/shortcuts.json b/src/i18n/locales/zh-CN/shortcuts.json
index da2d95a5d..033f80e7d 100644
--- a/src/i18n/locales/zh-CN/shortcuts.json
+++ b/src/i18n/locales/zh-CN/shortcuts.json
@@ -21,6 +21,7 @@
"addSpeed": "添加速度",
"addAnnotation": "添加标注",
"addAudio": "添加音频",
+ "addVoiceover": "录制配音",
"addKeyframe": "添加关键帧",
"addCameraFullscreen": "添加全屏摄像头",
"deleteSelected": "删除所选",
diff --git a/src/i18n/locales/zh-CN/timeline.json b/src/i18n/locales/zh-CN/timeline.json
index 9af9c1f96..bd87fac39 100644
--- a/src/i18n/locales/zh-CN/timeline.json
+++ b/src/i18n/locales/zh-CN/timeline.json
@@ -87,5 +87,17 @@
"smartCutsNoAudio": "此媒体没有音频",
"smartCutsNoSpeech": "未检测到语音",
"smartCutsFailed": "转录失败 — 请在“媒体”中重试"
+ },
+ "audio": {
+ "addVoiceover": "添加配音",
+ "subtitle": "在时间轴上放置配音或背景音乐图层",
+ "record": "录制配音",
+ "importFile": "导入音频文件",
+ "recording": "正在录制",
+ "stop": "停止",
+ "micDenied": "麦克风访问被拒绝",
+ "recordingUnavailable": "此处无法录音",
+ "saveFailed": "无法保存录音",
+ "importFailed": "无法导入音频文件"
}
}
diff --git a/src/i18n/locales/zh-TW/shortcuts.json b/src/i18n/locales/zh-TW/shortcuts.json
index 4819bee87..2daf7eb6d 100644
--- a/src/i18n/locales/zh-TW/shortcuts.json
+++ b/src/i18n/locales/zh-TW/shortcuts.json
@@ -21,6 +21,7 @@
"addSpeed": "新增速度",
"addAnnotation": "新增標註",
"addAudio": "新增音訊",
+ "addVoiceover": "錄製配音",
"addKeyframe": "新增關鍵影格",
"addCameraFullscreen": "新增全螢幕攝影機",
"deleteSelected": "刪除所選",
diff --git a/src/i18n/locales/zh-TW/timeline.json b/src/i18n/locales/zh-TW/timeline.json
index 7a632893e..94c99e882 100644
--- a/src/i18n/locales/zh-TW/timeline.json
+++ b/src/i18n/locales/zh-TW/timeline.json
@@ -87,5 +87,17 @@
"smartCutsNoAudio": "此媒體沒有音訊",
"smartCutsNoSpeech": "未偵測到語音",
"smartCutsFailed": "轉錄失敗 — 請在「媒體」中重試"
+ },
+ "audio": {
+ "addVoiceover": "新增旁白",
+ "subtitle": "在時間軸上放置旁白或背景音樂圖層",
+ "record": "錄製旁白",
+ "importFile": "匯入音訊檔案",
+ "recording": "錄製中",
+ "stop": "停止",
+ "micDenied": "麥克風存取遭拒絕",
+ "recordingUnavailable": "此處無法錄音",
+ "saveFailed": "無法儲存錄音",
+ "importFailed": "無法匯入音訊檔案"
}
}
diff --git a/src/lib/ai-edition/store/useTimeline.test.ts b/src/lib/ai-edition/store/useTimeline.test.ts
index 66b95f8b2..e8b6a0976 100644
--- a/src/lib/ai-edition/store/useTimeline.test.ts
+++ b/src/lib/ai-edition/store/useTimeline.test.ts
@@ -1519,11 +1519,16 @@ describe("useTimeline audio tracks", () => {
{
id: "trk_2",
assetId: "audio_2",
+ kind: "music" as const,
startMs: 0,
endMs: 1,
durationSec: 0,
offsetMs: 0,
gainDb: 0,
+ loop: false,
+ fadeInMs: 0,
+ fadeOutMs: 0,
+ muted: false,
label: "bgm.mp3",
origin: "user" as const,
},
diff --git a/src/lib/shortcuts.ts b/src/lib/shortcuts.ts
index 5617a1a3e..94098a4c0 100644
--- a/src/lib/shortcuts.ts
+++ b/src/lib/shortcuts.ts
@@ -6,6 +6,7 @@ export const SHORTCUT_ACTIONS = [
"addCameraFullscreen",
"addAnnotation",
"addAudio",
+ "addVoiceover",
"deleteSelected",
"playPause",
"copySelected",
@@ -115,6 +116,8 @@ export const DEFAULT_SHORTCUTS: ShortcutsConfig = {
addCameraFullscreen: { key: "c" },
addAnnotation: { key: "a" },
addAudio: { key: "m" },
+ // Record a voiceover over the timeline from the playhead.
+ addVoiceover: { key: "v" },
deleteSelected: { key: "d", ctrl: true },
playPause: { key: " " },
copySelected: { key: "c", ctrl: true },
@@ -129,6 +132,7 @@ export const SHORTCUT_LABELS: Record<ShortcutAction, string> = {
addCameraFullscreen: "Add Full Camera",
addAnnotation: "Add Annotation",
addAudio: "Add Audio",
+ addVoiceover: "Record Voiceover",
deleteSelected: "Delete Selected",
playPause: "Play / Pause",
copySelected: "Copy Selected",