Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

feat: add system audio capture to note recording

Gabriel Stein7721ba2149f3
diff --git a/src/components/notes/DictationWidget.tsx b/src/components/notes/DictationWidget.tsx
index f548ecb63..4d7080c5c 100644
--- a/src/components/notes/DictationWidget.tsx
+++ b/src/components/notes/DictationWidget.tsx
@@ -1,6 +1,6 @@
import { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
-import { Mic, Square, Loader2 } from "lucide-react";
+import { Mic, Square, Loader2, Monitor } from "lucide-react";
import { cn } from "../lib/utils";
interface DictationWidgetProps {
@@ -9,6 +9,8 @@ interface DictationWidgetProps {
onStart: () => void;
onStop: () => void;
actionPicker?: React.ReactNode;
+ recordingMode?: "mic-only" | "mic-system";
+ onRecordingModeChange?: (mode: "mic-only" | "mic-system") => void;
}
const BAR_COUNT = 7;
@@ -19,6 +21,8 @@ export default function DictationWidget({
onStart,
onStop,
actionPicker,
+ recordingMode = "mic-system",
+ onRecordingModeChange,
}: DictationWidgetProps) {
const { t } = useTranslation();
const [elapsed, setElapsed] = useState(0);
@@ -35,6 +39,8 @@ export default function DictationWidget({
const minutes = String(Math.floor(elapsed / 60)).padStart(2, "0");
const seconds = String(elapsed % 60).padStart(2, "0");
+ const isSystemAudio = recordingMode === "mic-system";
+
return (
<div className="absolute bottom-5 left-0 right-0 z-10 flex justify-center pointer-events-none">
{isRecording ? (
@@ -50,6 +56,15 @@ export default function DictationWidget({
animation: "grow-to-bar 0.45s cubic-bezier(0.22, 1, 0.36, 1) both",
}}
>
+ {isSystemAudio && (
+ <Monitor
+ size={12}
+ className="text-primary/50 shrink-0"
+ style={{
+ animation: "fade-in-content 0.3s ease-out 0.15s both",
+ }}
+ />
+ )}
<div
className="flex items-end gap-0.75 h-5"
style={{
@@ -111,6 +126,24 @@ export default function DictationWidget({
</div>
) : (
<div className="flex items-center gap-2 pointer-events-auto">
+ {onRecordingModeChange && (
+ <button
+ onClick={() => onRecordingModeChange(isSystemAudio ? "mic-only" : "mic-system")}
+ className={cn(
+ "flex items-center justify-center w-8 h-8 rounded-full",
+ "backdrop-blur-xl",
+ "border transition-all duration-200",
+ "active:scale-[0.95]",
+ isSystemAudio
+ ? "bg-primary/10 dark:bg-primary/15 border-primary/20 dark:border-primary/25 text-primary/70 hover:text-primary hover:bg-primary/16"
+ : "bg-foreground/4 dark:bg-white/5 border-foreground/8 dark:border-white/8 text-foreground/30 hover:text-foreground/50 hover:bg-foreground/8"
+ )}
+ aria-label={isSystemAudio ? t("notes.editor.micSystem") : t("notes.editor.micOnly")}
+ title={isSystemAudio ? t("notes.editor.micSystem") : t("notes.editor.micOnly")}
+ >
+ <Monitor size={12} />
+ </button>
+ )}
<button
onClick={onStart}
className={cn(
diff --git a/src/components/notes/NoteEditor.tsx b/src/components/notes/NoteEditor.tsx
index 90f0e3f0a..0503b6f7d 100644
--- a/src/components/notes/NoteEditor.tsx
+++ b/src/components/notes/NoteEditor.tsx
@@ -67,6 +67,9 @@ interface NoteEditorProps {
meetingTranscript?: string;
onStopMeetingRecording?: () => void;
onGenerateNotes?: () => void;
+ recordingMode?: "mic-only" | "mic-system";
+ onRecordingModeChange?: (mode: "mic-only" | "mic-system") => void;
+ liveTranscript?: string;
}
interface DictationRange {
@@ -163,6 +166,9 @@ export default function NoteEditor({
meetingTranscript,
onStopMeetingRecording,
onGenerateNotes,
+ recordingMode,
+ onRecordingModeChange,
+ liveTranscript,
}: NoteEditorProps) {
const { t } = useTranslation();
const [viewMode, setViewMode] = useState<MeetingViewMode>("raw");
@@ -365,7 +371,7 @@ export default function NoteEditor({
const segmentContainerRef = useRef<HTMLDivElement>(null);
const [indicatorStyle, setIndicatorStyle] = useState<React.CSSProperties>({ opacity: 0 });
- const effectiveTranscript = meetingTranscript || note.transcript || "";
+ const effectiveTranscript = liveTranscript || meetingTranscript || note.transcript || "";
const hasMeetingTranscript = !isMeetingRecording && !!effectiveTranscript;
const updateSegmentIndicator = useCallback(() => {
@@ -457,15 +463,20 @@ export default function NoteEditor({
useEffect(() => {
if (isRecording && !prevRecordingRef.current) {
- const selStart = cursorPosRef.current;
- const selEnd = selectionEndRef.current;
- dictationRef.current = {
- start: selStart,
- partialStart: selStart,
- end: selEnd,
- committedChars: 0,
- };
- if (viewMode === "enhanced") setViewMode("raw");
+ if (recordingMode === "mic-system") {
+ // System audio mode: show transcript tab for live transcription
+ setViewMode("transcript");
+ } else {
+ const selStart = cursorPosRef.current;
+ const selEnd = selectionEndRef.current;
+ dictationRef.current = {
+ start: selStart,
+ partialStart: selStart,
+ end: selEnd,
+ committedChars: 0,
+ };
+ if (viewMode === "enhanced") setViewMode("raw");
+ }
}
if (!isRecording && prevRecordingRef.current) {
// Only clear if no progressive text was inserted (non-streaming case).
@@ -822,6 +833,8 @@ export default function NoteEditor({
isProcessing={isProcessing}
onStart={handleStartRecording}
onStop={isMeetingRecording ? onStopMeetingRecording! : onStopRecording}
+ recordingMode={recordingMode}
+ onRecordingModeChange={onRecordingModeChange}
actionPicker={
isMeetingRecording
? undefined
diff --git a/src/components/notes/PersonalNotesView.tsx b/src/components/notes/PersonalNotesView.tsx
index 65b6b2983..0484a01a1 100644
--- a/src/components/notes/PersonalNotesView.tsx
+++ b/src/components/notes/PersonalNotesView.tsx
@@ -33,9 +33,12 @@ import {
setActiveFolderId,
} from "../../stores/noteStore";
import { useMeetingTranscription } from "../../hooks/useMeetingTranscription";
+import { useScreenRecordingPermission } from "../../hooks/useScreenRecordingPermission";
import { useNotesOnboarding } from "../../hooks/useNotesOnboarding";
import NotesOnboarding from "./NotesOnboarding";
+type NoteRecordingMode = "mic-only" | "mic-system";
+
const FOLDER_INPUT_CLASS =
"w-full h-6 bg-foreground/5 dark:bg-white/5 rounded px-2 text-xs text-foreground outline-none border border-primary/30 focus:border-primary/50";
@@ -78,6 +81,36 @@ export default function PersonalNotesView({
const effectiveModelId = useSettingsStore((s) => s.reasoningModel);
const { isComplete: isOnboardingComplete, complete: completeOnboarding } = useNotesOnboarding();
+ const [noteRecordingMode, setNoteRecordingMode] = useState<NoteRecordingMode>(() => {
+ const saved = localStorage.getItem("noteRecordingMode");
+ return saved === "mic-only" ? "mic-only" : "mic-system";
+ });
+ const [liveTranscript, setLiveTranscript] = useState("");
+ const liveTranscriptRef = useRef("");
+ const { granted: screenRecordingGranted, request: requestScreenRecording } =
+ useScreenRecordingPermission();
+
+ const handleRecordingModeChange = useCallback(
+ async (mode: NoteRecordingMode) => {
+ if (mode === "mic-system" && !screenRecordingGranted) {
+ const granted = await requestScreenRecording();
+ if (!granted) {
+ toast({
+ title: t("notes.editor.systemAudioPermissionRequired"),
+ description: t("notes.editor.systemAudioFallback"),
+ variant: "destructive",
+ });
+ return;
+ }
+ }
+ setNoteRecordingMode(mode);
+ localStorage.setItem("noteRecordingMode", mode);
+ },
+ [screenRecordingGranted, requestScreenRecording, toast, t]
+ );
+
+ const systemAudioEnabled = noteRecordingMode === "mic-system";
+
const {
isRecording: isMeetingRecording,
transcript: meetingTranscript,
@@ -120,9 +153,44 @@ export default function PersonalNotesView({
startRecording,
stopRecording,
} = useNoteRecording({
- onTranscriptionComplete: useCallback((text: string) => {
- setFinalTranscript(text);
- }, []),
+ systemAudioEnabled,
+ onTranscriptionComplete: useCallback(
+ (text: string) => {
+ if (systemAudioEnabled) {
+ // System audio mode: save to transcript field (separate from content).
+ // `text` is the complete final transcript from the provider.
+ const noteId = activeNoteRef.current;
+ if (noteId) {
+ window.electronAPI.updateNote(noteId, { transcript: text });
+ setLiveTranscript(text);
+ liveTranscriptRef.current = text;
+ }
+ } else {
+ setFinalTranscript(text);
+ }
+ },
+ [systemAudioEnabled]
+ ),
+ onPartialTranscript: useCallback(
+ (text: string) => {
+ if (systemAudioEnabled) {
+ // Show partial text in live transcript view
+ setLiveTranscript(
+ liveTranscriptRef.current + (liveTranscriptRef.current ? " " : "") + text
+ );
+ }
+ },
+ [systemAudioEnabled]
+ ),
+ onStreamingCommit: useCallback(
+ (text: string) => {
+ if (systemAudioEnabled) {
+ liveTranscriptRef.current += text;
+ setLiveTranscript(liveTranscriptRef.current);
+ }
+ },
+ [systemAudioEnabled]
+ ),
onError: useCallback(
(error: { title: string; description: string }) => {
toast({ title: error.title, description: error.description, variant: "destructive" });
@@ -133,12 +201,24 @@ export default function PersonalNotesView({
const handleFinalTranscriptConsumed = useCallback(() => setFinalTranscript(null), []);
+ // Reset live transcript when recording starts (system audio mode)
+ const prevIsRecordingRef = useRef(false);
+ useEffect(() => {
+ if (isRecording && !prevIsRecordingRef.current && systemAudioEnabled) {
+ setLiveTranscript("");
+ liveTranscriptRef.current = "";
+ }
+ prevIsRecordingRef.current = isRecording;
+ }, [isRecording, systemAudioEnabled]);
+
useEffect(() => {
if (activeNote && activeNote.id !== activeNoteRef.current) {
activeNoteRef.current = activeNote.id;
setLocalTitle(activeNote.title);
setLocalContent(activeNote.content);
setLocalEnhancedContent(activeNote.enhanced_content ?? null);
+ setLiveTranscript("");
+ liveTranscriptRef.current = "";
}
if (!activeNote) {
activeNoteRef.current = null;
@@ -714,10 +794,10 @@ export default function PersonalNotesView({
isSaving={isSaving}
isRecording={isRecording}
isProcessing={isProcessing}
- partialTranscript={partialTranscript}
- finalTranscript={finalTranscript}
+ partialTranscript={systemAudioEnabled ? "" : partialTranscript}
+ finalTranscript={systemAudioEnabled ? null : finalTranscript}
onFinalTranscriptConsumed={handleFinalTranscriptConsumed}
- streamingCommit={streamingCommit}
+ streamingCommit={systemAudioEnabled ? null : streamingCommit}
onStreamingCommitConsumed={consumeStreamingCommit}
onStartRecording={startRecording}
onStopRecording={stopRecording}
@@ -735,6 +815,9 @@ export default function PersonalNotesView({
meetingTranscript={meetingTranscript}
onStopMeetingRecording={stopMeetingTranscription}
onGenerateNotes={handleGenerateNotes}
+ recordingMode={noteRecordingMode}
+ onRecordingModeChange={handleRecordingModeChange}
+ liveTranscript={liveTranscript}
actionProcessingState={actionProcessingState}
actionName={actionName}
actionPicker={
diff --git a/src/helpers/audioManager.js b/src/helpers/audioManager.js
index e56f22d8a..4d49b91f6 100644
--- a/src/helpers/audioManager.js
+++ b/src/helpers/audioManager.js
@@ -2,6 +2,7 @@ import ReasoningService from "../services/ReasoningService";
import { API_ENDPOINTS, buildApiUrl, normalizeBaseUrl } from "../config/constants";
import logger from "../utils/logger";
import { isBuiltInMicrophone } from "../utils/audioDeviceUtils";
+import { getSystemAudioStream, stopSystemAudioStream } from "../utils/systemAudio";
import { isSecureEndpoint } from "../utils/urlUtils";
import { withSessionRefresh } from "../lib/neonAuth";
import { getBaseLanguageCode, validateLanguageForModel } from "../utils/languageSupport";
@@ -111,6 +112,13 @@ class AudioManager {
this.sttConfig = null;
this.lastAudioBlob = null;
this.lastAudioMetadata = null;
+
+ // System audio capture
+ this.systemAudioEnabled = false;
+ this.systemAudioStream = null;
+ this._mixingContext = null;
+ this._mixingDestination = null;
+ this._systemAudioSource = null;
}
getWorkletBlobUrl() {
@@ -188,6 +196,30 @@ registerProcessor("pcm-streaming-processor", PCMStreamingProcessor);
this.sttConfig = config;
}
+ setSystemAudioEnabled(enabled) {
+ this.systemAudioEnabled = enabled;
+ }
+
+ cleanupSystemAudio() {
+ stopSystemAudioStream(this.systemAudioStream);
+ this.systemAudioStream = null;
+
+ if (this._systemAudioSource) {
+ try {
+ this._systemAudioSource.disconnect();
+ } catch {}
+ this._systemAudioSource = null;
+ }
+
+ if (this._mixingContext) {
+ try {
+ this._mixingContext.close();
+ } catch {}
+ this._mixingContext = null;
+ }
+ this._mixingDestination = null;
+ }
+
getStreamingProvider() {
const { cloudTranscriptionModel } = getSettings();
if (REALTIME_MODELS.has(cloudTranscriptionModel)) {
@@ -275,9 +307,9 @@ registerProcessor("pcm-streaming-processor", PCMStreamingProcessor);
}
const constraints = await this.getAudioConstraints();
- const stream = await navigator.mediaDevices.getUserMedia(constraints);
+ const micStream = await navigator.mediaDevices.getUserMedia(constraints);
- const audioTrack = stream.getAudioTracks()[0];
+ const audioTrack = micStream.getAudioTracks()[0];
if (audioTrack) {
const settings = audioTrack.getSettings();
logger.info(
@@ -292,12 +324,31 @@ registerProcessor("pcm-streaming-processor", PCMStreamingProcessor);
);
}
+ // Mix in system audio if enabled
+ let recordingStream = micStream;
+ if (this.systemAudioEnabled) {
+ const sysStream = await getSystemAudioStream();
+ if (sysStream) {
+ this.systemAudioStream = sysStream;
+ this._mixingContext = new AudioContext();
+ this._mixingDestination = this._mixingContext.createMediaStreamDestination();
+ const micSource = this._mixingContext.createMediaStreamSource(micStream);
+ this._systemAudioSource = this._mixingContext.createMediaStreamSource(sysStream);
+ micSource.connect(this._mixingDestination);
+ this._systemAudioSource.connect(this._mixingDestination);
+ recordingStream = this._mixingDestination.stream;
+ logger.info("System audio mixed into batch recording", {}, "audio");
+ } else {
+ logger.warn("System audio unavailable, recording mic only", {}, "audio");
+ }
+ }
+
// Silence detection: observe audio energy via AnalyserNode
try {
this._silenceCtx = new AudioContext();
this._silenceAnalyser = this._silenceCtx.createAnalyser();
this._silenceAnalyser.fftSize = 2048;
- const sourceNode = this._silenceCtx.createMediaStreamSource(stream);
+ const sourceNode = this._silenceCtx.createMediaStreamSource(recordingStream);
sourceNode.connect(this._silenceAnalyser);
this._peakRms = 0;
const dataArray = new Uint8Array(this._silenceAnalyser.fftSize);
@@ -316,7 +367,7 @@ registerProcessor("pcm-streaming-processor", PCMStreamingProcessor);
this._peakRms = 1; // assume speech if detection fails
}
- this.mediaRecorder = new MediaRecorder(stream);
+ this.mediaRecorder = new MediaRecorder(recordingStream);
this.audioChunks = [];
this.recordingStartTime = Date.now();
this.recordingMimeType = this.mediaRecorder.mimeType || "audio/webm";
@@ -358,7 +409,8 @@ registerProcessor("pcm-streaming-processor", PCMStreamingProcessor);
this.recordingStartTime = null;
await this.processAudio(audioBlob, { durationSeconds });
- stream.getTracks().forEach((track) => track.stop());
+ micStream.getTracks().forEach((track) => track.stop());
+ this.cleanupSystemAudio();
};
this.mediaRecorder.start();
@@ -414,6 +466,7 @@ registerProcessor("pcm-streaming-processor", PCMStreamingProcessor);
if (this.mediaRecorder.stream) {
this.mediaRecorder.stream.getTracks().forEach((track) => track.stop());
}
+ this.cleanupSystemAudio();
return true;
}
@@ -2142,6 +2195,21 @@ registerProcessor("pcm-streaming-processor", PCMStreamingProcessor);
this.isStreaming = true;
this.streamingSource.connect(this.streamingProcessor);
+
+ // Mix in system audio if enabled — connecting a second source to the same
+ // AudioWorkletNode sums the signals automatically via Web Audio API.
+ if (this.systemAudioEnabled) {
+ const sysStream = await getSystemAudioStream();
+ if (sysStream) {
+ this.systemAudioStream = sysStream;
+ this._systemAudioSource = audioContext.createMediaStreamSource(sysStream);
+ this._systemAudioSource.connect(this.streamingProcessor);
+ logger.info("System audio mixed into streaming recording", {}, "audio");
+ } else {
+ logger.warn("System audio unavailable, streaming mic only", {}, "audio");
+ }
+ }
+
const tPipeline = performance.now();
// 3. Register IPC event listeners BEFORE connecting, so no transcript
@@ -2616,6 +2684,8 @@ registerProcessor("pcm-streaming-processor", PCMStreamingProcessor);
this.streamingStream = null;
}
+ this.cleanupSystemAudio();
+
this.isStreaming = false;
}
diff --git a/src/hooks/useMeetingTranscription.ts b/src/hooks/useMeetingTranscription.ts
index 872f4fbd8..4a968f41b 100644
--- a/src/hooks/useMeetingTranscription.ts
+++ b/src/hooks/useMeetingTranscription.ts
@@ -1,6 +1,7 @@
import { useState, useEffect, useRef, useCallback } from "react";
import { getSettings } from "../stores/settingsStore";
import { isBuiltInMicrophone } from "../utils/audioDeviceUtils";
+import { getSystemAudioStream } from "../utils/systemAudio";
import logger from "../utils/logger";
interface UseMeetingTranscriptionReturn {
@@ -185,45 +186,7 @@ const flushAndDisconnectProcessor = async (processor: AudioWorkletNode | null) =
processor.disconnect();
};
-const getSystemAudioStream = async (): Promise<MediaStream | null> => {
- try {
- // Use getDisplayMedia (handled by setDisplayMediaRequestHandler in main process)
- // which properly captures system audio via macOS ScreenCaptureKit loopback.
- const stream = await navigator.mediaDevices.getDisplayMedia({
- audio: true,
- video: true,
- });
-
- const audioTracks = stream.getAudioTracks();
- const videoTracks = stream.getVideoTracks();
- logger.debug(
- "Display media stream obtained",
- {
- audioTracks: audioTracks.length,
- videoTracks: videoTracks.length,
- audioSettings: audioTracks[0]?.getSettings(),
- },
- "meeting"
- );
-
- if (!audioTracks.length) {
- logger.error("No audio track in display media stream", {}, "meeting");
- videoTracks.forEach((t) => t.stop());
- return null;
- }
-
- // Video tracks must stay alive — stopping them kills the ScreenCaptureKit loopback audio
-
- audioTracks[0].addEventListener("ended", () => {
- logger.error("Audio track ended unexpectedly", {}, "meeting");
- });
-
- return stream;
- } catch (err) {
- logger.error("Failed to capture system audio", { error: (err as Error).message }, "meeting");
- return null;
- }
-};
+// getSystemAudioStream imported from ../utils/systemAudio
export function useMeetingTranscription(): UseMeetingTranscriptionReturn {
const [isRecording, setIsRecording] = useState(false);
diff --git a/src/hooks/useNoteRecording.ts b/src/hooks/useNoteRecording.ts
index 5c1180040..f5cfa8378 100644
--- a/src/hooks/useNoteRecording.ts
+++ b/src/hooks/useNoteRecording.ts
@@ -7,7 +7,9 @@ import { getRecordingErrorTitle } from "../utils/recordingErrors";
interface UseNoteRecordingOptions {
onTranscriptionComplete: (text: string) => void;
onPartialTranscript?: (text: string) => void;
+ onStreamingCommit?: (text: string) => void;
onError?: (error: { title: string; description: string }) => void;
+ systemAudioEnabled?: boolean;
}
interface UseNoteRecordingReturn {
@@ -25,7 +27,9 @@ interface UseNoteRecordingReturn {
export function useNoteRecording({
onTranscriptionComplete,
onPartialTranscript,
+ onStreamingCommit: onStreamingCommitCb,
onError,
+ systemAudioEnabled = false,
}: UseNoteRecordingOptions): UseNoteRecordingReturn {
const { t } = useTranslation();
const [isRecording, setIsRecording] = useState(false);
@@ -35,13 +39,24 @@ export function useNoteRecording({
const [streamingCommits, setStreamingCommits] = useState<string[]>([]);
const audioManagerRef = useRef<InstanceType<typeof AudioManager> | null>(null);
- const callbacksRef = useRef({ onTranscriptionComplete, onPartialTranscript, onError });
- callbacksRef.current = { onTranscriptionComplete, onPartialTranscript, onError };
+ const callbacksRef = useRef({
+ onTranscriptionComplete,
+ onPartialTranscript,
+ onStreamingCommitCb,
+ onError,
+ });
+ callbacksRef.current = {
+ onTranscriptionComplete,
+ onPartialTranscript,
+ onStreamingCommitCb,
+ onError,
+ };
useEffect(() => {
const manager = new AudioManager();
audioManagerRef.current = manager;
manager.setSkipReasoning(true);
+ manager.setSystemAudioEnabled(systemAudioEnabled);
manager.setCallbacks({
onStateChange: ({
@@ -71,6 +86,7 @@ export function useNoteRecording({
},
onStreamingCommit: (text: string) => {
setStreamingCommits((pending) => [...pending, text]);
+ callbacksRef.current.onStreamingCommitCb?.(text);
},
onTranscriptionComplete: (result: {
success: boolean;
@@ -105,6 +121,10 @@ export function useNoteRecording({
};
}, []);
+ useEffect(() => {
+ audioManagerRef.current?.setSystemAudioEnabled(systemAudioEnabled);
+ }, [systemAudioEnabled]);
+
const startRecording = useCallback(async () => {
const manager = audioManagerRef.current;
if (!manager) return;
diff --git a/src/locales/de/translation.json b/src/locales/de/translation.json
index 5f4efca55..e2d3270e3 100644
--- a/src/locales/de/translation.json
+++ b/src/locales/de/translation.json
@@ -1447,7 +1447,11 @@
"live": "Live",
"transcript": "Transkript",
"notes": "Notizen",
- "generateNotes": "Notizen generieren"
+ "generateNotes": "Notizen generieren",
+ "micOnly": "Nur Mikrofon",
+ "micSystem": "Mikrofon + Systemaudio",
+ "systemAudioPermissionRequired": "Bildschirmaufnahme-Berechtigung für Systemaudio erforderlich",
+ "systemAudioFallback": "Nur Mikrofon wird verwendet"
},
"upload": {
"title": "Audio hochladen",
diff --git a/src/locales/en/translation.json b/src/locales/en/translation.json
index 78c977de8..0f640b265 100644
--- a/src/locales/en/translation.json
+++ b/src/locales/en/translation.json
@@ -1560,7 +1560,11 @@
"live": "Live",
"transcript": "Transcript",
"notes": "Notes",
- "generateNotes": "Generate notes"
+ "generateNotes": "Generate notes",
+ "micOnly": "Microphone only",
+ "micSystem": "Mic + System Audio",
+ "systemAudioPermissionRequired": "Screen recording permission required for system audio",
+ "systemAudioFallback": "Falling back to microphone only"
},
"upload": {
"title": "Upload Audio",
diff --git a/src/locales/es/translation.json b/src/locales/es/translation.json
index 55785ec43..dbfb33b8b 100644
--- a/src/locales/es/translation.json
+++ b/src/locales/es/translation.json
@@ -1451,7 +1451,11 @@
"live": "En vivo",
"transcript": "Transcripción",
"notes": "Notas",
- "generateNotes": "Generar notas"
+ "generateNotes": "Generar notas",
+ "micOnly": "Solo micrófono",
+ "micSystem": "Micrófono + audio del sistema",
+ "systemAudioPermissionRequired": "Se requiere permiso de grabación de pantalla para el audio del sistema",
+ "systemAudioFallback": "Usando solo el micrófono"
},
"upload": {
"title": "Subir audio",
diff --git a/src/locales/fr/translation.json b/src/locales/fr/translation.json
index 1e5617ab2..47de879ff 100644
--- a/src/locales/fr/translation.json
+++ b/src/locales/fr/translation.json
@@ -1488,7 +1488,11 @@
"live": "En direct",
"transcript": "Transcription",
"notes": "Notes",
- "generateNotes": "Générer des notes"
+ "generateNotes": "Générer des notes",
+ "micOnly": "Microphone uniquement",
+ "micSystem": "Micro + audio système",
+ "systemAudioPermissionRequired": "L'autorisation d'enregistrement d'écran est requise pour l'audio système",
+ "systemAudioFallback": "Utilisation du microphone uniquement"
},
"upload": {
"title": "Téléverser un fichier audio",
diff --git a/src/locales/it/translation.json b/src/locales/it/translation.json
index b748525ca..3db1b8685 100644
--- a/src/locales/it/translation.json
+++ b/src/locales/it/translation.json
@@ -1451,7 +1451,11 @@
"live": "Dal vivo",
"transcript": "Trascrizione",
"notes": "Note",
- "generateNotes": "Genera note"
+ "generateNotes": "Genera note",
+ "micOnly": "Solo microfono",
+ "micSystem": "Microfono + audio di sistema",
+ "systemAudioPermissionRequired": "Autorizzazione registrazione schermo necessaria per l'audio di sistema",
+ "systemAudioFallback": "Utilizzo del solo microfono"
},
"upload": {
"title": "Carica audio",
diff --git a/src/locales/ja/translation.json b/src/locales/ja/translation.json
index 9bdad1099..4d476ecd1 100644
--- a/src/locales/ja/translation.json
+++ b/src/locales/ja/translation.json
@@ -1346,6 +1346,10 @@
"transcript": "文字起こし",
"notes": "ノート",
"generateNotes": "ノートを生成",
+ "micOnly": "マイクのみ",
+ "micSystem": "マイク + システム音声",
+ "systemAudioPermissionRequired": "システム音声には画面収録の許可が必要です",
+ "systemAudioFallback": "マイクのみを使用します",
"untitled": "無題",
"noteTitle": "ノートのタイトル",
"stop": "停止",
diff --git a/src/locales/pt/translation.json b/src/locales/pt/translation.json
index c3ca9aabb..a9d6d3e83 100644
--- a/src/locales/pt/translation.json
+++ b/src/locales/pt/translation.json
@@ -1451,7 +1451,11 @@
"live": "Ao vivo",
"transcript": "Transcrição",
"notes": "Notas",
- "generateNotes": "Gerar notas"
+ "generateNotes": "Gerar notas",
+ "micOnly": "Apenas microfone",
+ "micSystem": "Microfone + áudio do sistema",
+ "systemAudioPermissionRequired": "Permissão de gravação de tela necessária para áudio do sistema",
+ "systemAudioFallback": "Usando apenas o microfone"
},
"upload": {
"title": "Enviar áudio",
diff --git a/src/locales/ru/translation.json b/src/locales/ru/translation.json
index 6d2098981..0f89ded15 100644
--- a/src/locales/ru/translation.json
+++ b/src/locales/ru/translation.json
@@ -1451,7 +1451,11 @@
"live": "Живой",
"transcript": "Транскрипция",
"notes": "Заметки",
- "generateNotes": "Сгенерировать заметки"
+ "generateNotes": "Сгенерировать заметки",
+ "micOnly": "Только микрофон",
+ "micSystem": "Микрофон + системный звук",
+ "systemAudioPermissionRequired": "Для системного звука требуется разрешение на запись экрана",
+ "systemAudioFallback": "Используется только микрофон"
},
"upload": {
"title": "Загрузить аудио",
diff --git a/src/locales/zh-CN/translation.json b/src/locales/zh-CN/translation.json
index ba3b70461..d199f7513 100644
--- a/src/locales/zh-CN/translation.json
+++ b/src/locales/zh-CN/translation.json
@@ -1447,7 +1447,11 @@
"live": "实时",
"transcript": "转录",
"notes": "笔记",
- "generateNotes": "生成笔记"
+ "generateNotes": "生成笔记",
+ "micOnly": "仅麦克风",
+ "micSystem": "麦克风 + 系统音频",
+ "systemAudioPermissionRequired": "系统音频需要屏幕录制权限",
+ "systemAudioFallback": "仅使用麦克风"
},
"upload": {
"title": "上传音频",
diff --git a/src/locales/zh-TW/translation.json b/src/locales/zh-TW/translation.json
index b5c023d63..e85ee9a1e 100644
--- a/src/locales/zh-TW/translation.json
+++ b/src/locales/zh-TW/translation.json
@@ -1447,7 +1447,11 @@
"live": "即時",
"transcript": "轉錄",
"notes": "筆記",
- "generateNotes": "生成筆記"
+ "generateNotes": "生成筆記",
+ "micOnly": "僅麥克風",
+ "micSystem": "麥克風 + 系統音訊",
+ "systemAudioPermissionRequired": "系統音訊需要螢幕錄製權限",
+ "systemAudioFallback": "僅使用麥克風"
},
"upload": {
"title": "上傳音訊",
diff --git a/src/utils/systemAudio.ts b/src/utils/systemAudio.ts
new file mode 100644
index 000000000..8d9387081
--- /dev/null
+++ b/src/utils/systemAudio.ts
@@ -0,0 +1,56 @@
+import logger from "./logger";
+
+/**
+ * Capture system audio via getDisplayMedia (ScreenCaptureKit loopback on macOS).
+ * Returns a MediaStream with audio (and video tracks that must stay alive on macOS).
+ * Returns null if capture fails or no audio tracks are available.
+ */
+export async function getSystemAudioStream(): Promise<MediaStream | null> {
+ try {
+ // Use getDisplayMedia (handled by setDisplayMediaRequestHandler in main process)
+ // which properly captures system audio via macOS ScreenCaptureKit loopback.
+ const stream = await navigator.mediaDevices.getDisplayMedia({
+ audio: true,
+ video: true,
+ });
+
+ const audioTracks = stream.getAudioTracks();
+ const videoTracks = stream.getVideoTracks();
+ logger.debug(
+ "Display media stream obtained",
+ {
+ audioTracks: audioTracks.length,
+ videoTracks: videoTracks.length,
+ audioSettings: audioTracks[0]?.getSettings(),
+ },
+ "audio"
+ );
+
+ if (!audioTracks.length) {
+ logger.error("No audio track in display media stream", {}, "audio");
+ videoTracks.forEach((t) => t.stop());
+ return null;
+ }
+
+ // Video tracks must stay alive — stopping them kills the ScreenCaptureKit loopback audio
+
+ audioTracks[0].addEventListener("ended", () => {
+ logger.error("System audio track ended unexpectedly", {}, "audio");
+ });
+
+ return stream;
+ } catch (err) {
+ logger.error("Failed to capture system audio", { error: (err as Error).message }, "audio");
+ return null;
+ }
+}
+
+/**
+ * Stop all tracks (audio + video) on a system audio stream.
+ */
+export function stopSystemAudioStream(stream: MediaStream | null): void {
+ if (!stream) return;
+ try {
+ stream.getTracks().forEach((t) => t.stop());
+ } catch {}
+}