Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.
JavaScript aianthropiccross-platformgeminigroqlinuxmacosnvidiaopen-sourceopenaiparakeetspeech-to-texttranscribewhisperwindows
feat(note-files): auto-save transcripts alongside notes as files
Gabriel Steinab1fe256d03c
diff --git a/src/helpers/ipcHandlers.js b/src/helpers/ipcHandlers.jsindex 8ec90d438..252d3c45b 100644--- a/src/helpers/ipcHandlers.js+++ b/src/helpers/ipcHandlers.js@@ -173,6 +173,9 @@ class IPCHandlers {const markdownMirror = require("./markdownMirror");const folderName = this._getFolderName(note.folder_id);markdownMirror.writeNote(note, folderName);+ if (note.transcript) {+ markdownMirror.writeTranscript(note, folderName, this._buildSpeakerMappings(note.id));+ }});}@@ -193,10 +196,26 @@ class IPCHandlers {return map;}+ _buildSpeakerMappings(noteId) {+ const arr = this.databaseManager.getSpeakerMappings(noteId);+ const map = {};+ for (const m of arr) {+ map[m.speaker_id] = m.display_name;+ }+ return map;+ }+_rebuildMirror(basePath) {const markdownMirror = require("./markdownMirror");if (basePath) markdownMirror.init(basePath);- markdownMirror.rebuildAll(this.databaseManager.getNotes(null, 99999), this._buildFolderMap());+ const notes = this.databaseManager.getNotes(null, 99999);+ const speakerMappingsMap = {};+ for (const note of notes) {+ if (note.transcript) {+ speakerMappingsMap[note.id] = this._buildSpeakerMappings(note.id);+ }+ }+ markdownMirror.rebuildAll(notes, this._buildFolderMap(), speakerMappingsMap);}_getFolderName(folderId) {@@ -1053,35 +1072,12 @@ class IPCHandlers {const segments = JSON.parse(note.transcript || "[]");if (!segments.length) return { success: false, error: "No transcript available" };- const speakerMappingsArr = this.databaseManager.getSpeakerMappings(noteId);- const speakerMappings = {};- for (const m of speakerMappingsArr) {- speakerMappings[m.speaker_id] = m.display_name;- }-- const title = note.title || "Untitled";- const noteDate = new Date(note.created_at);- const dateStr =- noteDate.toLocaleDateString(undefined, {- year: "numeric",- month: "long",- day: "numeric",- }) +- " " +- noteDate.toLocaleTimeString(undefined, {- hour: "2-digit",- minute: "2-digit",- });- let participants = [];- try {- const parsed = JSON.parse(note.participants || "[]");- participants = parsed.map((p) => p.name).filter(Boolean);- } catch {}+ const speakerMappings = this._buildSpeakerMappings(noteId);const { dialog } = require("electron");const fs = require("fs");const ext = format === "srt" ? "srt" : format === "json" ? "json" : "txt";- const safeName = title.replace(/[/\\?%*:|"<>]/g, "-");+ const safeName = (note.title || "Untitled").replace(/[/\\?%*:|"<>]/g, "-");const result = await dialog.showSaveDialog({defaultPath: `${safeName}.${ext}`,@@ -1094,92 +1090,14 @@ class IPCHandlers {if (result.canceled || !result.filePath) return { success: false };- const resolveSpeaker = (seg) => {- if (seg.speakerName && !seg.speakerIsPlaceholder) return seg.speakerName;- if (seg.speaker && speakerMappings[seg.speaker]) return speakerMappings[seg.speaker];- if (seg.speaker === "you") return "You";- if (seg.speaker) {- const num = parseInt(seg.speaker.replace("speaker_", ""), 10);- return isNaN(num) ? "Unknown Speaker" : `Speaker ${num + 1}`;- }- return "Unknown Speaker";- };-- const formatTs = (seconds) => {- const s = Math.floor(seconds);- const h = Math.floor(s / 3600);- const m = Math.floor((s % 3600) / 60);- const sec = s % 60;- return `${String(h).padStart(2, "0")}:${String(m).padStart(2, "0")}:${String(sec).padStart(2, "0")}`;- };-- const formatSrtTs = (seconds) => {- const s = Math.floor(seconds);- const ms = Math.round((seconds - s) * 1000);- const h = Math.floor(s / 3600);- const m = Math.floor((s % 3600) / 60);- const sec = s % 60;- return `${String(h).padStart(2, "0")}:${String(m).padStart(2, "0")}:${String(sec).padStart(2, "0")},${String(ms).padStart(3, "0")}`;- };-- const merged = [];- for (const seg of segments) {- if (!seg.text?.trim()) continue;- const ts = seg.timestamp || 0;- const last = merged[merged.length - 1];- if (last && last.speaker === (seg.speaker || "") && ts - last.timestamp < 2) {- last.text = last.text + " " + seg.text.trim();- last.timestamp = ts;- } else {- merged.push({ ...seg, timestamp: ts, text: seg.text.trim() });- }- }-+ const transcriptFormatter = require("./transcriptFormatter");let exportContent;if (format === "txt") {- const lines = [title, dateStr];- if (participants.length) lines.push(`Participants: ${participants.join(", ")}`);- lines.push("", "──────────────────────────────────", "");- for (const seg of merged) {- lines.push(`[${formatTs(seg.timestamp)}] ${resolveSpeaker(seg)}:`);- lines.push(seg.text);- lines.push("");- }- exportContent = lines.join("\n");+ exportContent = transcriptFormatter.formatTxt(note, segments, speakerMappings);} else if (format === "srt") {- const entries = [];- for (let i = 0; i < merged.length; i++) {- const seg = merged[i];- const nextTs = i + 1 < merged.length ? merged[i + 1].timestamp : seg.timestamp + 3;- entries.push(`${i + 1}`);- entries.push(`${formatSrtTs(seg.timestamp)} --> ${formatSrtTs(nextTs)}`);- entries.push(`${resolveSpeaker(seg)}: ${seg.text}`);- entries.push("");- }- exportContent = entries.join("\n");+ exportContent = transcriptFormatter.formatSrt(segments, speakerMappings);} else {- const speakersSet = new Set();- for (const seg of merged) speakersSet.add(resolveSpeaker(seg));- const lastSeg = merged[merged.length - 1];- exportContent = JSON.stringify(- {- metadata: {- title,- date: dateStr,- duration_seconds: lastSeg ? Math.round(lastSeg.timestamp) : 0,- speaker_count: speakersSet.size,- segment_count: merged.length,- },- speakers: [...speakersSet],- segments: merged.map((seg) => ({- speaker: resolveSpeaker(seg),- timestamp: seg.timestamp,- text: seg.text,- })),- },- null,- 2- );+ exportContent = transcriptFormatter.formatJson(note, segments, speakerMappings);}fs.writeFileSync(result.filePath, exportContent, "utf-8");diff --git a/src/helpers/markdownMirror.js b/src/helpers/markdownMirror.jsindex 45aad3f12..f93ac731e 100644--- a/src/helpers/markdownMirror.js+++ b/src/helpers/markdownMirror.js@@ -83,10 +83,44 @@ class MarkdownMirror {}}+ writeTranscript(note, folderName, speakerMappings) {+ if (!this._basePath) return;+ try {+ const segments = JSON.parse(note.transcript || "[]");+ if (!segments.length) return;++ const dirName = folderName || "Personal";+ const dirPath = path.join(this._basePath, dirName);+ fs.mkdirSync(dirPath, { recursive: true });++ const slug = this._slugify(note.title);+ const newFileName = `${note.id}-${slug}-transcript.txt`;+ const newFilePath = path.join(dirPath, newFileName);++ const stale = this._globTranscriptFiles(note.id);+ for (const existing of stale) {+ if (existing !== newFilePath) {+ try {+ fs.unlinkSync(existing);+ } catch {}+ }+ }++ const { formatTxt } = require("./transcriptFormatter");+ fs.writeFileSync(newFilePath, formatTxt(note, segments, speakerMappings || {}), "utf-8");+ } catch (err) {+ debugLogger.error(+ "Failed to write transcript file",+ { noteId: note.id, error: err.message },+ "note-files"+ );+ }+ }+deleteNote(noteId) {if (!this._basePath) return;try {- const files = this._globNoteFiles(noteId);+ const files = [...this._globNoteFiles(noteId), ...this._globTranscriptFiles(noteId)];for (const f of files) {fs.unlinkSync(f);}@@ -147,12 +181,15 @@ class MarkdownMirror {}}- rebuildAll(notes, folderMap) {+ rebuildAll(notes, folderMap, speakerMappingsMap) {if (!this._basePath) return;try {for (const note of notes) {const folderName = folderMap[note.folder_id] || "Personal";this.writeNote(note, folderName);+ if (note.transcript) {+ this.writeTranscript(note, folderName, speakerMappingsMap?.[note.id] || {});+ }}debugLogger.info("Markdown mirror rebuild complete", { count: notes.length }, "note-files");} catch (err) {@@ -191,6 +228,27 @@ class MarkdownMirror {} catch {}return results;}++ _globTranscriptFiles(noteId) {+ if (!this._basePath) return [];+ const results = [];+ try {+ const prefix = `${noteId}-`;+ const suffix = "-transcript.txt";+ const dirs = fs.readdirSync(this._basePath, { withFileTypes: true });+ for (const dir of dirs) {+ if (!dir.isDirectory()) continue;+ const dirPath = path.join(this._basePath, dir.name);+ const files = fs.readdirSync(dirPath);+ for (const file of files) {+ if (file.startsWith(prefix) && file.endsWith(suffix)) {+ results.push(path.join(dirPath, file));+ }+ }+ }+ } catch {}+ return results;+ }}module.exports = new MarkdownMirror();diff --git a/src/helpers/transcriptFormatter.js b/src/helpers/transcriptFormatter.jsnew file mode 100644index 000000000..95e35e5da--- /dev/null+++ b/src/helpers/transcriptFormatter.js@@ -0,0 +1,119 @@+function resolveSpeaker(seg, speakerMappings) {+ if (seg.speakerName && !seg.speakerIsPlaceholder) return seg.speakerName;+ if (seg.speaker && speakerMappings[seg.speaker]) return speakerMappings[seg.speaker];+ if (seg.speaker === "you") return "You";+ if (seg.speaker) {+ const num = parseInt(seg.speaker.replace("speaker_", ""), 10);+ return isNaN(num) ? "Unknown Speaker" : `Speaker ${num + 1}`;+ }+ return "Unknown Speaker";+}++function mergeSegments(segments) {+ const merged = [];+ for (const seg of segments) {+ if (!seg.text?.trim()) continue;+ const ts = seg.timestamp || 0;+ const last = merged[merged.length - 1];+ if (last && last.speaker === (seg.speaker || "") && ts - last.timestamp < 2) {+ last.text = last.text + " " + seg.text.trim();+ last.timestamp = ts;+ } else {+ merged.push({ ...seg, timestamp: ts, text: seg.text.trim() });+ }+ }+ return merged;+}++function formatTimestamp(seconds) {+ const s = Math.floor(seconds);+ const h = Math.floor(s / 3600);+ const m = Math.floor((s % 3600) / 60);+ const sec = s % 60;+ return `${String(h).padStart(2, "0")}:${String(m).padStart(2, "0")}:${String(sec).padStart(2, "0")}`;+}++function formatSrtTimestamp(seconds) {+ const s = Math.floor(seconds);+ const ms = Math.round((seconds - s) * 1000);+ const h = Math.floor(s / 3600);+ const m = Math.floor((s % 3600) / 60);+ const sec = s % 60;+ return `${String(h).padStart(2, "0")}:${String(m).padStart(2, "0")}:${String(sec).padStart(2, "0")},${String(ms).padStart(3, "0")}`;+}++function formatTxt(note, segments, speakerMappings) {+ const merged = mergeSegments(segments);+ const title = note.title || "Untitled";+ const noteDate = new Date(note.created_at);+ const dateStr =+ noteDate.toLocaleDateString(undefined, { year: "numeric", month: "long", day: "numeric" }) ++ " " ++ noteDate.toLocaleTimeString(undefined, { hour: "2-digit", minute: "2-digit" });++ let participants = [];+ try {+ const parsed = JSON.parse(note.participants || "[]");+ participants = parsed.map((p) => p.name).filter(Boolean);+ } catch {}++ const lines = [title, dateStr];+ if (participants.length) lines.push(`Participants: ${participants.join(", ")}`);+ lines.push("", "──────────────────────────────────", "");+ for (const seg of merged) {+ lines.push(`[${formatTimestamp(seg.timestamp)}] ${resolveSpeaker(seg, speakerMappings)}:`);+ lines.push(seg.text);+ lines.push("");+ }+ return lines.join("\n");+}++function formatSrt(segments, speakerMappings) {+ const merged = mergeSegments(segments);+ const entries = [];+ for (let i = 0; i < merged.length; i++) {+ const seg = merged[i];+ const nextTs = i + 1 < merged.length ? merged[i + 1].timestamp : seg.timestamp + 3;+ entries.push(`${i + 1}`);+ entries.push(`${formatSrtTimestamp(seg.timestamp)} --> ${formatSrtTimestamp(nextTs)}`);+ entries.push(`${resolveSpeaker(seg, speakerMappings)}: ${seg.text}`);+ entries.push("");+ }+ return entries.join("\n");+}++function formatJson(note, segments, speakerMappings) {+ const merged = mergeSegments(segments);+ const title = note.title || "Untitled";+ const noteDate = new Date(note.created_at);+ const dateStr =+ noteDate.toLocaleDateString(undefined, { year: "numeric", month: "long", day: "numeric" }) ++ " " ++ noteDate.toLocaleTimeString(undefined, { hour: "2-digit", minute: "2-digit" });++ const speakersSet = new Set();+ for (const seg of merged) speakersSet.add(resolveSpeaker(seg, speakerMappings));+ const lastSeg = merged[merged.length - 1];++ return JSON.stringify(+ {+ metadata: {+ title,+ date: dateStr,+ duration_seconds: lastSeg ? Math.round(lastSeg.timestamp) : 0,+ speaker_count: speakersSet.size,+ segment_count: merged.length,+ },+ speakers: [...speakersSet],+ segments: merged.map((seg) => ({+ speaker: resolveSpeaker(seg, speakerMappings),+ timestamp: seg.timestamp,+ text: seg.text,+ })),+ },+ null,+ 2+ );+}++module.exports = { formatTxt, formatSrt, formatJson };diff --git a/src/locales/de/translation.json b/src/locales/de/translation.jsonindex 2ecfb1eb2..92b0772c3 100644--- a/src/locales/de/translation.json+++ b/src/locales/de/translation.json@@ -10,11 +10,11 @@},"noteFiles": {"title": "Notizen als Dateien speichern",- "description": "Notizen automatisch als .md-Dateien auf der Festplatte speichern, nach Ordner sortiert",+ "description": "Notizen und Transkripte automatisch als Dateien auf der Festplatte speichern, nach Ordner sortiert","path": "Speicherort","changePath": "Speicherort ändern","rebuild": "Alle Dateien neu erstellen",- "rebuildDescription": "Alle Notizen erneut auf die Festplatte synchronisieren"+ "rebuildDescription": "Alle Notizen und Transkripte erneut auf die Festplatte synchronisieren"}},"tray": {diff --git a/src/locales/en/translation.json b/src/locales/en/translation.jsonindex cdbce18fb..7cb8c16cc 100644--- a/src/locales/en/translation.json+++ b/src/locales/en/translation.json@@ -10,11 +10,11 @@},"noteFiles": {"title": "Save notes as files",- "description": "Automatically save notes as .md files on disk, organized by folder",+ "description": "Automatically save notes and transcripts as files on disk, organized by folder","path": "Save location","changePath": "Change location","rebuild": "Rebuild all files",- "rebuildDescription": "Re-sync all notes to disk"+ "rebuildDescription": "Re-sync all notes and transcripts to disk"}},"tray": {diff --git a/src/locales/es/translation.json b/src/locales/es/translation.jsonindex f181c8bcb..315bc8be1 100644--- a/src/locales/es/translation.json+++ b/src/locales/es/translation.json@@ -10,11 +10,11 @@},"noteFiles": {"title": "Guardar notas como archivos",- "description": "Guardar notas automáticamente como archivos .md en disco, organizadas por carpeta",+ "description": "Guardar notas y transcripciones automáticamente como archivos en disco, organizados por carpeta","path": "Ubicación de guardado","changePath": "Cambiar ubicación","rebuild": "Reconstruir todos los archivos",- "rebuildDescription": "Resincronizar todas las notas al disco"+ "rebuildDescription": "Resincronizar todas las notas y transcripciones al disco"}},"tray": {diff --git a/src/locales/fr/translation.json b/src/locales/fr/translation.jsonindex f5fac4028..f973d375e 100644--- a/src/locales/fr/translation.json+++ b/src/locales/fr/translation.json@@ -10,11 +10,11 @@},"noteFiles": {"title": "Enregistrer les notes en fichiers",- "description": "Enregistrer automatiquement les notes en fichiers .md sur le disque, organisées par dossier",+ "description": "Enregistrer automatiquement les notes et transcriptions en fichiers sur le disque, organisés par dossier","path": "Emplacement de sauvegarde","changePath": "Changer l'emplacement","rebuild": "Reconstruire tous les fichiers",- "rebuildDescription": "Resynchroniser toutes les notes sur le disque"+ "rebuildDescription": "Resynchroniser toutes les notes et transcriptions sur le disque"}},"tray": {diff --git a/src/locales/it/translation.json b/src/locales/it/translation.jsonindex 5f33df90e..ab8f49446 100644--- a/src/locales/it/translation.json+++ b/src/locales/it/translation.json@@ -10,11 +10,11 @@},"noteFiles": {"title": "Salva note come file",- "description": "Salva automaticamente le note come file .md su disco, organizzate per cartella",+ "description": "Salva automaticamente note e trascrizioni come file su disco, organizzati per cartella","path": "Percorso di salvataggio","changePath": "Cambia percorso","rebuild": "Ricostruisci tutti i file",- "rebuildDescription": "Risincronizza tutte le note su disco"+ "rebuildDescription": "Risincronizza tutte le note e trascrizioni su disco"}},"tray": {diff --git a/src/locales/ja/translation.json b/src/locales/ja/translation.jsonindex 0ee208ea1..1aab2940b 100644--- a/src/locales/ja/translation.json+++ b/src/locales/ja/translation.json@@ -10,11 +10,11 @@},"noteFiles": {"title": "ノートをファイルとして保存",- "description": "ノートを .md ファイルとしてディスクに自動保存し、フォルダごとに整理",+ "description": "ノートと文字起こしをファイルとしてディスクに自動保存し、フォルダごとに整理","path": "保存先","changePath": "保存先を変更","rebuild": "すべてのファイルを再構築",- "rebuildDescription": "すべてのノートをディスクに再同期"+ "rebuildDescription": "すべてのノートと文字起こしをディスクに再同期"}},"tray": {diff --git a/src/locales/pt/translation.json b/src/locales/pt/translation.jsonindex b35902d68..2506a2a40 100644--- a/src/locales/pt/translation.json+++ b/src/locales/pt/translation.json@@ -10,11 +10,11 @@},"noteFiles": {"title": "Salvar notas como arquivos",- "description": "Salvar notas automaticamente como arquivos .md no disco, organizadas por pasta",+ "description": "Salvar notas e transcrições automaticamente como arquivos no disco, organizados por pasta","path": "Local de salvamento","changePath": "Alterar local","rebuild": "Reconstruir todos os arquivos",- "rebuildDescription": "Ressincronizar todas as notas no disco"+ "rebuildDescription": "Ressincronizar todas as notas e transcrições no disco"}},"tray": {diff --git a/src/locales/ru/translation.json b/src/locales/ru/translation.jsonindex 446e79805..64534be5d 100644--- a/src/locales/ru/translation.json+++ b/src/locales/ru/translation.json@@ -10,11 +10,11 @@},"noteFiles": {"title": "Сохранять заметки как файлы",- "description": "Автоматически сохранять заметки как файлы .md на диск с группировкой по папкам",+ "description": "Автоматически сохранять заметки и транскрипции как файлы на диск с группировкой по папкам","path": "Расположение","changePath": "Изменить расположение","rebuild": "Пересоздать все файлы",- "rebuildDescription": "Повторно синхронизировать все заметки на диск"+ "rebuildDescription": "Повторно синхронизировать все заметки и транскрипции на диск"}},"tray": {diff --git a/src/locales/zh-CN/translation.json b/src/locales/zh-CN/translation.jsonindex 1580e2778..d0839a9bd 100644--- a/src/locales/zh-CN/translation.json+++ b/src/locales/zh-CN/translation.json@@ -10,11 +10,11 @@},"noteFiles": {"title": "将笔记保存为文件",- "description": "自动将笔记保存为 .md 文件到磁盘,按文件夹分类",+ "description": "自动将笔记和转录保存为文件���磁盘,按文件夹分类","path": "保存位置","changePath": "更改位置","rebuild": "重建所有文件",- "rebuildDescription": "将所有笔记重新同步到磁盘"+ "rebuildDescription": "将所有笔记和转录重新同步到磁盘"}},"tray": {diff --git a/src/locales/zh-TW/translation.json b/src/locales/zh-TW/translation.jsonindex 6e8c84176..5c460fce6 100644--- a/src/locales/zh-TW/translation.json+++ b/src/locales/zh-TW/translation.json@@ -10,11 +10,11 @@},"noteFiles": {"title": "將筆記儲存為檔案",- "description": "自動將筆記儲存為 .md 檔案到磁碟,按資料夾分類",+ "description": "自動將筆記和逐字稿儲存為檔案到磁碟,按資料夾分類","path": "儲存位置","changePath": "變更位置","rebuild": "重建所有檔案",- "rebuildDescription": "將所有筆記重新同步到磁碟"+ "rebuildDescription": "將所有筆記和逐字稿重新同步到磁碟"}},"tray": {