Speakr is a personal, self-hosted web application designed for transcribing audio recordings
Python
Add split-button 'merge with an existing recording' option to the in-app recording upload view, with an in-modal recording picker so merges can be built from scratch
Murtaza Nasirb51c8186b723
diff --git a/static/js/app.modular.js b/static/js/app.modular.jsindex c2c9453a..be6a2b18 100644--- a/static/js/app.modular.js+++ b/static/js/app.modular.js@@ -715,6 +715,9 @@ document.addEventListener('DOMContentLoaded', async () => {const legendExpanded = ref(false);const highlightedSpeaker = ref(null);const showDownloadMenu = ref(false);+ // Split-button menu on the recording-view "Upload Recording & Notes"+ // action (offers "merge with an existing recording").+ const showUploadSplitMenu = ref(false);// Preferred transcript download format ('txt' | 'md'), persisted.const transcriptDownloadFormat = ref(localStorage.getItem('transcriptDownloadFormat') === 'md' ? 'md' : 'txt');watch(transcriptDownloadFormat, (val) => {@@ -1686,7 +1689,7 @@ document.addEventListener('DOMContentLoaded', async () => {// TranscriptiontranscriptionViewMode, legendExpanded, highlightedSpeaker, showDownloadMenu,- transcriptDownloadFormat,+ transcriptDownloadFormat, showUploadSplitMenu,currentPlayingSegmentIndex, followPlayerMode, processingIndicatorMinimized,// Chat@@ -2408,6 +2411,11 @@ document.addEventListener('DOMContentLoaded', async () => {startReprocessingPoll: reprocessComposable.startReprocessingPoll});+ // Bridge merge-modal opener to the audio composable so the+ // "merge this recording with an existing one" split-button action in+ // the recording view can seed and open the merge modal after upload.+ utils.openMergeWith = bulkOperationsComposable.openMergeWith;+// =========================================================================// VIRTUAL SCROLL SETUP (for performance with long transcriptions)// Must be before speakers composable since it uses scrollToSegmentIndexdiff --git a/static/js/modules/composables/audio.js b/static/js/modules/composables/audio.jsindex c8c84e79..255d937c 100644--- a/static/js/modules/composables/audio.js+++ b/static/js/modules/composables/audio.js@@ -1055,6 +1055,67 @@ export function useAudio(state, utils) {}};+ // Poll a recording until its audio is settled and it is mergeable+ // (COMPLETED), then return its full dict. Used by mergeRecordedWithExisting.+ const _pollUntilMergeable = async (recordingId, { timeoutMs = 15 * 60 * 1000, intervalMs = 3000 } = {}) => {+ const start = Date.now();+ while (Date.now() - start < timeoutMs) {+ try {+ const resp = await fetch(`/recording/${recordingId}/status`);+ if (resp.ok) {+ const s = await resp.json();+ if (s.status === 'COMPLETED' && s.audio_ready !== false) {+ const full = await fetch(`/api/recordings/${recordingId}`);+ return full.ok ? await full.json() : null;+ }+ if (s.status === 'FAILED') return null;+ }+ } catch (_) { /* transient; keep polling */ }+ await new Promise(r => setTimeout(r, intervalMs));+ }+ return null;+ };++ // Split-button action: upload the just-recorded clip, then open the merge+ // modal seeded with it so the user can combine it with existing+ // recording(s). The merge service only accepts settled sources, so we upload+ // first and wait for the clip to finish processing before opening the modal.+ const mergeRecordedWithExisting = async () => {+ const t = (k, p) => (utils.t ? utils.t(k, p) : k);+ if (!audioBlobURL.value) {+ setGlobalError(t('mergeRecordings.noClip') || 'No recorded audio to merge.');+ return;+ }++ let result;+ try {+ result = await uploadRecordedAudio();+ } catch (e) {+ setGlobalError(`Upload failed: ${e.message}`);+ return;+ }++ const newId = result && result.recording_id;+ if (!newId) {+ // Legacy single-shot path or a failure — the clip uploaded normally+ // but we can't chain a merge automatically.+ showToast?.(t('mergeRecordings.uploadedMergeManually'), 'fa-info-circle', 6000);+ return;+ }++ showToast?.(t('mergeRecordings.preparingClip'), 'fa-spinner');+ const rec = await _pollUntilMergeable(newId);+ if (!rec) {+ setGlobalError(t('mergeRecordings.clipNotReady'));+ return;+ }++ if (utils.openMergeWith) {+ // Default to replacing the sources (the chosen behavior for this flow).+ utils.openMergeWith([rec], { deleteOriginals: true });+ }+ };+// Upload recorded audio in incognito modeconst uploadRecordedAudioIncognito = async () => {if (!audioBlobURL.value) {@@ -1434,6 +1495,7 @@ export function useAudio(state, utils) {discardRecording,normalizeLiveMediaDuration,uploadRecordedAudio,+ mergeRecordedWithExisting,uploadRecordedAudioIncognito,acceptRecordingDisclaimer,cancelRecordingDisclaimer,diff --git a/static/js/modules/composables/bulk-operations.js b/static/js/modules/composables/bulk-operations.jsindex 728bc2ea..b4554ab9 100644--- a/static/js/modules/composables/bulk-operations.js+++ b/static/js/modules/composables/bulk-operations.js@@ -33,6 +33,23 @@ export function useBulkOperations({const mergeTitle = ref('');const mergeDeleteOriginals = ref(false);const mergeInProgress = ref(false);+ // In-modal "add recording" picker (lets the user append existing recordings+ // to the merge from within the modal — used by the normal merge and by the+ // merge-from-recording flow that seeds the modal with a just-recorded clip).+ const mergeAddPickerOpen = ref(false);+ const mergeAddSearch = ref('');+ // Only completed recordings with settled audio are mergeable, and not ones+ // already in the list. Filtered by the search box.+ const mergeCandidates = computed(() => {+ const inList = new Set(mergeOrderedList.value.map(r => r.id));+ const q = mergeAddSearch.value.trim().toLowerCase();+ return recordings.value.filter(r =>+ !inList.has(r.id) &&+ r.status === 'COMPLETED' &&+ r.audio_ready !== false &&+ (!q || (r.title || '').toLowerCase().includes(q))+ );+ });// Get CSRF tokenconst getCsrfToken = () => {@@ -282,6 +299,34 @@ export function useBulkOperations({const closeBulkMergeModal = () => {showBulkMergeModal.value = false;+ mergeAddPickerOpen.value = false;+ mergeAddSearch.value = '';+ };++ // Open the merge modal seeded with a specific set of recordings and options.+ // Used by the "merge this recording with an existing one" flow (upload view)+ // — it seeds the just-recorded clip and defaults to replacing the sources.+ const openMergeWith = (seedRecordings, { deleteOriginals = false, title = '' } = {}) => {+ mergeOrderedList.value = (seedRecordings || []).slice();+ mergeTitle.value = title || '';+ mergeDeleteOriginals.value = !!deleteOriginals;+ mergeAddPickerOpen.value = false;+ mergeAddSearch.value = '';+ showBulkMergeModal.value = true;+ };++ const addMergeCandidate = (recording) => {+ if (!recording) return;+ if (mergeOrderedList.value.some(r => r.id === recording.id)) return;+ mergeOrderedList.value = [...mergeOrderedList.value, recording];+ mergeAddSearch.value = '';+ mergeAddPickerOpen.value = false;+ };++ const removeMergeItem = (index) => {+ const next = mergeOrderedList.value.slice();+ next.splice(index, 1);+ mergeOrderedList.value = next;};const moveMergeItem = (index, direction) => {@@ -557,6 +602,9 @@ export function useBulkOperations({mergeTitle,mergeDeleteOriginals,mergeInProgress,+ mergeAddPickerOpen,+ mergeAddSearch,+ mergeCandidates,// Bulk DeleteopenBulkDeleteModal,@@ -576,6 +624,9 @@ export function useBulkOperations({// MergeopenBulkMergeModal,closeBulkMergeModal,+ openMergeWith,+ addMergeCandidate,+ removeMergeItem,moveMergeItem,executeBulkMerge,diff --git a/static/locales/de.json b/static/locales/de.jsonindex f6880bf4..830b26ba 100644--- a/static/locales/de.json+++ b/static/locales/de.json@@ -1876,6 +1876,16 @@"merging": "Wird zusammengeführt…","confirm": "Zusammenführen","videoNote": "Diese Aufnahmen enthalten Video. Beim Zusammenführen wird nur der Ton kombiniert; die zusammengeführte Aufnahme enthält kein Video.",- "audioPreparing": "Der Ton wird noch vorbereitet. Er ist in Kürze abspielbar."+ "audioPreparing": "Der Ton wird noch vorbereitet. Er ist in Kürze abspielbar.",+ "remove": "Entfernen",+ "addRecording": "Aufnahme hinzufügen",+ "searchRecordings": "Aufnahmen suchen…",+ "noCandidates": "Keine Aufnahmen zum Hinzufügen verfügbar",+ "moreOptions": "Weitere Optionen",+ "mergeWithExisting": "Mit einer vorhandenen Aufnahme zusammenführen…",+ "noClip": "Keine aufgenommene Audiodatei zum Zusammenführen.",+ "uploadedMergeManually": "Ihr Clip wurde hochgeladen. Wählen Sie ihn und eine weitere Aufnahme in der Liste aus, um sie zusammenzuführen.",+ "preparingClip": "Ihr Clip wird vorbereitet — die Optionen zum Zusammenführen öffnen sich, sobald er bereit ist.",+ "clipNotReady": "Der Clip konnte nicht zum Zusammenführen vorbereitet werden."}}\ No newline at end of filediff --git a/static/locales/en.json b/static/locales/en.jsonindex c0cb8769..88273cdb 100644--- a/static/locales/en.json+++ b/static/locales/en.json@@ -1876,6 +1876,16 @@"merging": "Merging…","confirm": "Merge recordings","videoNote": "These recordings include video. Merging combines the audio only; the merged recording will not have video.",- "audioPreparing": "Audio is still being prepared. It will be playable in a moment."+ "audioPreparing": "Audio is still being prepared. It will be playable in a moment.",+ "remove": "Remove",+ "addRecording": "Add a recording",+ "searchRecordings": "Search recordings…",+ "noCandidates": "No recordings available to add",+ "moreOptions": "More options",+ "mergeWithExisting": "Merge with an existing recording…",+ "noClip": "No recorded audio to merge.",+ "uploadedMergeManually": "Your clip was uploaded. Select it and another recording in the list to merge them.",+ "preparingClip": "Preparing your clip — the merge options will open when it's ready.",+ "clipNotReady": "The clip could not be prepared for merging."}}\ No newline at end of filediff --git a/static/locales/es.json b/static/locales/es.jsonindex 2d971b9e..4a02607f 100644--- a/static/locales/es.json+++ b/static/locales/es.json@@ -1876,6 +1876,16 @@"merging": "Combinando…","confirm": "Combinar","videoNote": "Estas grabaciones incluyen vídeo. La combinación une solo el audio; la grabación combinada no tendrá vídeo.",- "audioPreparing": "El audio aún se está preparando. Podrás reproducirlo en un momento."+ "audioPreparing": "El audio aún se está preparando. Podrás reproducirlo en un momento.",+ "remove": "Quitar",+ "addRecording": "Añadir una grabación",+ "searchRecordings": "Buscar grabaciones…",+ "noCandidates": "No hay grabaciones disponibles para añadir",+ "moreOptions": "Más opciones",+ "mergeWithExisting": "Combinar con una grabación existente…",+ "noClip": "No hay audio grabado para combinar.",+ "uploadedMergeManually": "Tu clip se ha subido. Selecciónalo junto con otra grabación de la lista para combinarlos.",+ "preparingClip": "Preparando tu clip: las opciones de combinación se abrirán cuando esté listo.",+ "clipNotReady": "No se pudo preparar el clip para la combinación."}}\ No newline at end of filediff --git a/static/locales/fr.json b/static/locales/fr.jsonindex 8806a012..8f432e9c 100644--- a/static/locales/fr.json+++ b/static/locales/fr.json@@ -1876,6 +1876,16 @@"merging": "Fusion…","confirm": "Fusionner","videoNote": "Ces enregistrements contiennent de la vidéo. La fusion ne combine que l'audio ; l'enregistrement fusionné n'aura pas de vidéo.",- "audioPreparing": "L'audio est en cours de préparation. Il sera lisible dans un instant."+ "audioPreparing": "L'audio est en cours de préparation. Il sera lisible dans un instant.",+ "remove": "Retirer",+ "addRecording": "Ajouter un enregistrement",+ "searchRecordings": "Rechercher des enregistrements…",+ "noCandidates": "Aucun enregistrement à ajouter",+ "moreOptions": "Plus d'options",+ "mergeWithExisting": "Fusionner avec un enregistrement existant…",+ "noClip": "Aucun audio enregistré à fusionner.",+ "uploadedMergeManually": "Votre extrait a été téléversé. Sélectionnez-le ainsi qu'un autre enregistrement de la liste pour les fusionner.",+ "preparingClip": "Préparation de votre extrait — les options de fusion s'ouvriront dès qu'il sera prêt.",+ "clipNotReady": "Impossible de préparer l'extrait pour la fusion."}}\ No newline at end of filediff --git a/static/locales/pt-BR.json b/static/locales/pt-BR.jsonindex 1c43c665..bd215b62 100644--- a/static/locales/pt-BR.json+++ b/static/locales/pt-BR.json@@ -1876,6 +1876,16 @@"merging": "Mesclando…","confirm": "Mesclar","videoNote": "Estas gravações incluem vídeo. A mesclagem combina apenas o áudio; a gravação mesclada não terá vídeo.",- "audioPreparing": "O áudio ainda está sendo preparado. Poderá ser reproduzido em instantes."+ "audioPreparing": "O áudio ainda está sendo preparado. Poderá ser reproduzido em instantes.",+ "remove": "Remover",+ "addRecording": "Adicionar uma gravação",+ "searchRecordings": "Pesquisar gravações…",+ "noCandidates": "Nenhuma gravação disponível para adicionar",+ "moreOptions": "Mais opções",+ "mergeWithExisting": "Mesclar com uma gravação existente…",+ "noClip": "Nenhum áudio gravado para mesclar.",+ "uploadedMergeManually": "Seu clipe foi enviado. Selecione-o e outra gravação da lista para mesclá-los.",+ "preparingClip": "Preparando seu clipe — as opções de mesclagem abrirão quando estiver pronto.",+ "clipNotReady": "Não foi possível preparar o clipe para a mesclagem."}}\ No newline at end of filediff --git a/static/locales/ru.json b/static/locales/ru.jsonindex 197b4ab9..25c757ae 100644--- a/static/locales/ru.json+++ b/static/locales/ru.json@@ -1876,6 +1876,16 @@"merging": "Объединение…","confirm": "Объединить","videoNote": "Эти записи содержат видео. При объединении сохраняется только звук; в объединённой записи видео не будет.",- "audioPreparing": "Аудио ещё готовится. Оно будет доступно для воспроизведения через мгновение."+ "audioPreparing": "Аудио ещё готовится. Оно будет доступно для воспроизведения через мгновение.",+ "remove": "Удалить",+ "addRecording": "Добавить запись",+ "searchRecordings": "Поиск записей…",+ "noCandidates": "Нет записей для добавления",+ "moreOptions": "Дополнительно",+ "mergeWithExisting": "Объединить с существующей записью…",+ "noClip": "Нет записанного звука для объединения.",+ "uploadedMergeManually": "Ваш фрагмент загружен. Выберите его и другую запись в списке, чтобы объединить их.",+ "preparingClip": "Подготовка фрагмента — параметры объединения откроются, когда он будет готов.",+ "clipNotReady": "Не удалось подготовить фрагмент к объединению."}}\ No newline at end of filediff --git a/static/locales/zh.json b/static/locales/zh.jsonindex 66b1b02f..0de392e3 100644--- a/static/locales/zh.json+++ b/static/locales/zh.json@@ -1876,6 +1876,16 @@"merging": "正在合并…","confirm": "合并","videoNote": "这些录音包含视频。合并仅会合并音频;合并后的录音将不包含视频。",- "audioPreparing": "音频仍在准备中,稍后即可播放。"+ "audioPreparing": "音频仍在准备中,稍后即可播放。",+ "remove": "移除",+ "addRecording": "添加录音",+ "searchRecordings": "搜索录音…",+ "noCandidates": "没有可添加的录音",+ "moreOptions": "更多选项",+ "mergeWithExisting": "与现有录音合并…",+ "noClip": "没有可合并的录音。",+ "uploadedMergeManually": "您的片段已上传。请在列表中选择它和另一条录音以进行合并。",+ "preparingClip": "正在准备您的片段——准备就绪后将打开合并选项。",+ "clipNotReady": "无法准备该片段以进行合并。"}}\ No newline at end of filediff --git a/templates/components/recording-view.html b/templates/components/recording-view.htmlindex 28f492e3..c2b9ac4b 100644--- a/templates/components/recording-view.html+++ b/templates/components/recording-view.html@@ -397,13 +397,31 @@</button></div><div v-if="!isRecording && audioBlobURL" class="flex flex-col sm:flex-row gap-3 justify-center">- <!-- Normal Upload Button -->- <button v-if="!incognitoMode || !enableIncognitoMode"- @click="uploadRecordedAudio"- class="flex-1 px-6 py-3 bg-[var(--bg-button)] text-[var(--text-button)] rounded-lg hover:bg-[var(--bg-button-hover)] transition-colors flex items-center justify-center gap-2">- <i class="fas fa-upload"></i>- <span v-text="t('help.uploadRecordingNotes')"></span>- </button>+ <!-- Normal Upload Button (split: main uploads, caret opens options) -->+ <div v-if="!incognitoMode || !enableIncognitoMode" class="flex-1 flex relative">+ <button @click="uploadRecordedAudio"+ class="flex-1 px-6 py-3 bg-[var(--bg-button)] text-[var(--text-button)] rounded-l-lg hover:bg-[var(--bg-button-hover)] transition-colors flex items-center justify-center gap-2">+ <i class="fas fa-upload"></i>+ <span v-text="t('help.uploadRecordingNotes')"></span>+ </button>+ <button @click="showUploadSplitMenu = !showUploadSplitMenu"+ class="px-3 bg-[var(--bg-button)] text-[var(--text-button)] rounded-r-lg hover:bg-[var(--bg-button-hover)] transition-colors border-l border-white/25 flex items-center justify-center"+ :title="t('mergeRecordings.moreOptions')">+ <i class="fas fa-chevron-down text-xs"></i>+ </button>+ <!-- Click-away backdrop -->+ <div v-if="showUploadSplitMenu" @click="showUploadSplitMenu = false" class="fixed inset-0 z-40"></div>+ <!-- Options menu (opens upward; the bar is pinned to the bottom) -->+ <div v-if="showUploadSplitMenu"+ class="absolute bottom-full right-0 mb-1 surface-raised z-50 overflow-hidden whitespace-nowrap rounded-md"+ style="min-width: 260px;">+ <button @click="showUploadSplitMenu = false; mergeRecordedWithExisting()"+ class="w-full text-left px-3 py-2.5 text-sm hover:bg-[var(--bg-tertiary)] transition-colors flex items-center gap-2">+ <i class="fas fa-object-group text-purple-500"></i>+ <span v-text="t('mergeRecordings.mergeWithExisting')"></span>+ </button>+ </div>+ </div><!-- Incognito Upload Button --><button v-else@click="uploadRecordedAudioIncognito"diff --git a/templates/modals/bulk-merge-modal.html b/templates/modals/bulk-merge-modal.htmlindex c6f57d65..3b5008e7 100644--- a/templates/modals/bulk-merge-modal.html+++ b/templates/modals/bulk-merge-modal.html@@ -33,6 +33,32 @@<i class="fas fa-chevron-down"></i></button></div>+ <button @click="removeMergeItem(index)"+ class="flex-shrink-0 w-7 h-7 flex items-center justify-center rounded text-[var(--text-muted)] hover:text-[var(--color-danger,#ef4444)] hover:bg-[var(--bg-tertiary)] transition-colors"+ :title="t('mergeRecordings.remove')">+ <i class="fas fa-times"></i>+ </button>+ </div>+ </div>++ <!-- Add existing recording -->+ <div class="mb-5">+ <button v-if="!mergeAddPickerOpen" @click="mergeAddPickerOpen = true"+ class="w-full px-3 py-2 text-sm rounded-md border border-dashed border-[var(--border-primary)] text-[var(--text-secondary)] hover:bg-[var(--bg-tertiary)] transition-colors flex items-center justify-center gap-2">+ <i class="fas fa-plus text-xs"></i>+ <span v-text="t('mergeRecordings.addRecording')"></span>+ </button>+ <div v-else class="rounded-md border border-[var(--border-primary)] overflow-hidden">+ <input type="text" v-model="mergeAddSearch" :placeholder="t('mergeRecordings.searchRecordings')"+ class="w-full px-3 py-2 text-sm bg-[var(--bg-input)] text-[var(--text-primary)] border-b border-[var(--border-primary)] focus:outline-none">+ <div class="max-h-40 overflow-y-auto">+ <button v-for="cand in mergeCandidates" :key="cand.id" @click="addMergeCandidate(cand)"+ class="w-full text-left px-3 py-2 text-sm hover:bg-[var(--bg-tertiary)] transition-colors flex items-center gap-2">+ <i class="fas fa-plus text-[10px] text-[var(--text-accent)]"></i>+ <span class="truncate">${ cand.title || t('mergeRecordings.untitled') }</span>+ </button>+ <div v-if="mergeCandidates.length === 0" class="px-3 py-3 t-meta text-center" v-text="t('mergeRecordings.noCandidates')"></div>+ </div></div></div>