Speakr is a personal, self-hosted web application designed for transcribing audio recordings
Python
bubble and simple
Murtaza Nasir2d8b31271231
diff --git a/static/css/styles.css b/static/css/styles.cssindex 66001027..121b5688 100644--- a/static/css/styles.css+++ b/static/css/styles.css@@ -41,6 +41,10 @@--scrollbar-track: #f1f1f1;--scrollbar-thumb: #c5c5c5;--scrollbar-thumb-hover: #a8a8a8;++ /* Toast notification colors */+ --bg-success: #10b981;+ --border-success: #059669;}.dark {@@ -736,6 +740,288 @@ body {box-shadow: 0 0 10px var(--bg-accent-hover);}+/* Speaker Legend and Bubble Styles */+.speaker-legend {+ position: sticky;+ top: 0;+ z-index: 10;+ display: flex;+ flex-wrap: wrap;+ gap: 0.375rem;+ margin-bottom: 0.75rem;+ padding: 0.5rem 0.75rem;+ background-color: var(--bg-secondary);+ border: 1px solid var(--border-primary);+ border-radius: 0.5rem;+ box-shadow: 0 2px 4px rgba(0,0,0,0.1);+ max-height: 2.5rem;+ overflow: hidden;+ transition: max-height 0.3s ease;+}++.speaker-legend.expanded {+ max-height: none;+}++.speaker-legend-item {+ display: flex;+ align-items: center;+ gap: 0.25rem;+ padding: 0.25rem 0.5rem;+ background-color: var(--bg-tertiary);+ border: 1px solid var(--border-secondary);+ border-radius: 0.75rem;+ font-size: 0.75rem;+ font-weight: 500;+ transition: all 0.2s ease;+ white-space: nowrap;+}++.speaker-legend-item:hover {+ transform: translateY(-1px);+ box-shadow: 0 1px 3px rgba(0,0,0,0.15);+}++.speaker-color-dot {+ width: 8px;+ height: 8px;+ border-radius: 50%;+ flex-shrink: 0;+ border: 1px solid rgba(255,255,255,0.6);+ box-shadow: 0 1px 2px rgba(0,0,0,0.1);+}++.speaker-name {+ color: var(--text-primary);+ font-weight: 600;+}++.legend-expand-btn {+ margin-left: auto;+ padding: 0.25rem;+ background: none;+ border: none;+ color: var(--text-muted);+ cursor: pointer;+ font-size: 0.75rem;+ opacity: 0.7;+ transition: opacity 0.2s ease;+}++.legend-expand-btn:hover {+ opacity: 1;+}++/* Enhanced transcription display with speaker bubbles */+.transcription-with-speakers {+ line-height: 1.6;+ font-family: inherit;+}++.speaker-bubble {+ display: block;+ margin: 0.375rem 0;+ padding: 0.5rem 0.75rem;+ border-radius: 0.75rem;+ max-width: 80%;+ word-wrap: break-word;+ position: relative;+ box-shadow: 0 1px 2px rgba(0,0,0,0.08);+ transition: all 0.2s ease;+ border: 1px solid rgba(255,255,255,0.3);+}++.speaker-bubble:hover {+ transform: translateY(-1px);+ box-shadow: 0 2px 4px rgba(0,0,0,0.12);+}++.speaker-bubble.speaker-me {+ margin-left: auto;+ margin-right: 0;+ text-align: right;+ border-bottom-right-radius: 0.25rem;+}++.speaker-bubble:not(.speaker-me) {+ margin-left: 0;+ margin-right: auto;+ border-bottom-left-radius: 0.25rem;+}++.speaker-bubble-content {+ margin: 0;+ color: inherit;+ font-size: 0.875rem;+ line-height: 1.4;+}++/* Simple view with speaker tablets */+.transcription-simple-view {+ line-height: 1.6;+ font-family: inherit;+}++.speaker-segment {+ margin-bottom: 1rem;+}++.speaker-tablet {+ display: inline-block;+ padding: 0.25rem 0.5rem;+ border-radius: 0.375rem;+ font-size: 0.75rem;+ font-weight: 600;+ margin-bottom: 0.5rem;+ margin-right: 0.5rem;+ border: 1px solid rgba(255,255,255,0.3);+ box-shadow: 0 1px 2px rgba(0,0,0,0.1);+}++.speaker-text {+ color: var(--text-secondary);+ font-size: 0.875rem;+ line-height: 1.5;+ margin-left: 0;+}++/* View mode toggle */+.view-mode-toggle {+ display: flex;+ align-items: center;+ gap: 0.5rem;+ margin-bottom: 1rem;+ padding: 0.5rem;+ background-color: var(--bg-tertiary);+ border: 1px solid var(--border-primary);+ border-radius: 0.5rem;+}++.toggle-button {+ padding: 0.375rem 0.75rem;+ border: 1px solid var(--border-secondary);+ border-radius: 0.375rem;+ background-color: var(--bg-secondary);+ color: var(--text-muted);+ font-size: 0.75rem;+ font-weight: 500;+ cursor: pointer;+ transition: all 0.2s ease;+}++.toggle-button.active {+ background-color: var(--bg-accent);+ color: var(--text-accent);+ border-color: var(--border-accent);+}++.toggle-button:hover:not(.active) {+ background-color: var(--bg-tertiary);+ color: var(--text-secondary);+}++/* Speaker colors - using a pleasant, accessible color palette */+.speaker-color-1 { background-color: #E3F2FD; color: #1565C0; } /* Light Blue */+.speaker-color-2 { background-color: #F3E5F5; color: #7B1FA2; } /* Light Purple */+.speaker-color-3 { background-color: #E8F5E8; color: #2E7D32; } /* Light Green */+.speaker-color-4 { background-color: #FFF3E0; color: #EF6C00; } /* Light Orange */+.speaker-color-5 { background-color: #FCE4EC; color: #C2185B; } /* Light Pink */+.speaker-color-6 { background-color: #E0F2F1; color: #00695C; } /* Light Teal */+.speaker-color-7 { background-color: #F1F8E9; color: #558B2F; } /* Light Lime */+.speaker-color-8 { background-color: #FFF8E1; color: #F57F17; } /* Light Amber */++/* Dark mode speaker colors */+.dark .speaker-color-1 { background-color: #1E3A8A; color: #BFDBFE; }+.dark .speaker-color-2 { background-color: #581C87; color: #DDD6FE; }+.dark .speaker-color-3 { background-color: #14532D; color: #BBF7D0; }+.dark .speaker-color-4 { background-color: #9A3412; color: #FED7AA; }+.dark .speaker-color-5 { background-color: #9D174D; color: #FBCFE8; }+.dark .speaker-color-6 { background-color: #134E4A; color: #99F6E4; }+.dark .speaker-color-7 { background-color: #365314; color: #D9F99D; }+.dark .speaker-color-8 { background-color: #92400E; color: #FDE68A; }++/* Meeting/Created time styling improvements */+.recording-metadata {+ display: flex;+ flex-wrap: wrap;+ align-items: center;+ gap: 1.5rem;+ margin-top: 0.5rem;+ font-size: 0.875rem;+}++.metadata-item {+ display: flex;+ align-items: center;+ gap: 0.5rem;+ color: var(--text-muted);+ transition: color 0.2s ease;+}++.metadata-item:hover {+ color: var(--text-secondary);+}++.metadata-icon {+ color: var(--text-accent);+ opacity: 0.75;+ font-size: 0.875rem;+ width: 14px;+ text-align: center;+}++.metadata-label {+ font-weight: 500;+ color: var(--text-secondary);+}++.metadata-value {+ color: var(--text-muted);+}++.metadata-value.editable {+ cursor: pointer;+ padding: 0.125rem 0.25rem;+ border-radius: 0.25rem;+ transition: all 0.2s ease;+}++.metadata-value.editable:hover {+ background-color: var(--bg-tertiary);+ color: var(--text-accent);+}++.metadata-edit-input {+ padding: 0.125rem 0.5rem;+ background: transparent;+ border: none;+ border-bottom: 1px solid var(--border-secondary);+ color: var(--text-primary);+ font-size: inherit;+ width: 140px;+}++.metadata-edit-input:focus {+ outline: none;+ border-bottom-color: var(--border-focus);+}++.metadata-edit-button {+ margin-left: 0.25rem;+ padding: 0.125rem;+ background: none;+ border: none;+ color: var(--text-accent);+ cursor: pointer;+ font-size: 0.75rem;+ opacity: 0.7;+ transition: opacity 0.2s ease;+}++.metadata-edit-button:hover {+ opacity: 1;+}+.modal-content {max-height: calc(100vh - 200px);overflow-y: auto;@@ -986,3 +1272,39 @@ body {min-width: 0;flex: 1;}++/* Toast notifications */+.toast-container {+ position: fixed;+ top: 20px;+ right: 20px;+ z-index: 9999;+ pointer-events: none;+}++.toast {+ background: var(--bg-success);+ color: var(--text-success-strong);+ padding: 12px 16px;+ border-radius: 8px;+ margin-bottom: 8px;+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);+ border: 1px solid var(--border-success);+ transform: translateX(100%);+ opacity: 0;+ transition: all 0.3s ease-in-out;+ pointer-events: auto;+ display: flex;+ align-items: center;+ gap: 8px;+ max-width: 300px;+}++.toast.show {+ transform: translateX(0);+ opacity: 1;+}++.toast i {+ flex-shrink: 0;+}diff --git a/static/js/app.js b/static/js/app.jsindex 4b60cf7a..d154f998 100644--- a/static/js/app.js+++ b/static/js/app.js@@ -52,6 +52,7 @@ document.addEventListener('DOMContentLoaded', () => {const speakerMap = ref({});const regenerateSummaryAfterSpeakerUpdate = ref(true);const highlightedSpeaker = ref(null);+ const transcriptionViewMode = ref('simple'); // 'simple' or 'bubble'// const autoSaveTimeout = ref(null); // Autosave not implemented for modalconst isLoadingRecordings = ref(true);const globalError = ref(null);@@ -169,7 +170,8 @@ document.addEventListener('DOMContentLoaded', () => {if (!selectedRecording.value?.transcription) {return [];}- const speakerRegex = /\[(SPEAKER_\d+)\]/g;+ // Match both [SPEAKER_XX] and [Name] patterns+ const speakerRegex = /\[([^\]]+)\]:/g;const speakers = new Set();let match;while ((match = speakerRegex.exec(selectedRecording.value.transcription)) !== null) {@@ -178,6 +180,96 @@ document.addEventListener('DOMContentLoaded', () => {return Array.from(speakers);});+ const processedTranscription = computed(() => {+ if (!selectedRecording.value?.transcription) {+ return { hasDialogue: false, content: '', speakers: [] };+ }++ const transcription = selectedRecording.value.transcription;++ // Check if transcription has speaker labels+ const speakerRegex = /\[([^\]]+)\]:\s*/g;+ const hasDialogue = speakerRegex.test(transcription);++ if (!hasDialogue) {+ return {+ hasDialogue: false,+ content: transcription,+ speakers: []+ };+ }++ // Reset regex for processing+ speakerRegex.lastIndex = 0;++ // Extract speakers and assign colors+ const speakers = new Set();+ let match;+ const tempTranscription = transcription;+ while ((match = speakerRegex.exec(tempTranscription)) !== null) {+ speakers.add(match[1]);+ }++ const speakerList = Array.from(speakers);+ const speakerColors = {};+ speakerList.forEach((speaker, index) => {+ speakerColors[speaker] = `speaker-color-${(index % 8) + 1}`;+ });++ // Process transcription into dialogue segments+ const segments = [];+ const lines = transcription.split('\n');+ let currentSpeaker = null;+ let currentText = '';++ for (const line of lines) {+ const speakerMatch = line.match(/^\[([^\]]+)\]:\s*(.*)$/);++ if (speakerMatch) {+ // Save previous segment if exists+ if (currentSpeaker && currentText.trim()) {+ segments.push({+ speaker: currentSpeaker,+ text: currentText.trim(),+ color: speakerColors[currentSpeaker] || 'speaker-color-1'+ });+ }++ // Start new segment+ currentSpeaker = speakerMatch[1];+ currentText = speakerMatch[2];+ } else if (currentSpeaker && line.trim()) {+ // Continue current speaker's text+ currentText += ' ' + line.trim();+ } else if (!currentSpeaker && line.trim()) {+ // Text without speaker (shouldn't happen in dialogue, but handle gracefully)+ segments.push({+ speaker: null,+ text: line.trim(),+ color: 'speaker-color-1'+ });+ }+ }++ // Don't forget the last segment+ if (currentSpeaker && currentText.trim()) {+ segments.push({+ speaker: currentSpeaker,+ text: currentText.trim(),+ color: speakerColors[currentSpeaker] || 'speaker-color-1'+ });+ }++ return {+ hasDialogue: true,+ segments: segments,+ speakers: speakerList.map(speaker => ({+ name: speaker,+ color: speakerColors[speaker] || 'speaker-color-1'+ }))+ };+ });+const highlightedTranscript = computed(() => {if (!selectedRecording.value?.transcription) return '';let html = selectedRecording.value.transcription;@@ -1797,6 +1889,11 @@ document.addEventListener('DOMContentLoaded', () => {}};+ // Toggle transcription view mode+ const toggleTranscriptionViewMode = () => {+ transcriptionViewMode.value = transcriptionViewMode.value === 'simple' ? 'bubble' : 'simple';+ };+return {// StatecurrentView, dragover, recordings, selectedRecording, // currentRecording removed@@ -1811,6 +1908,7 @@ document.addEventListener('DOMContentLoaded', () => {transcriptionFlex, tabsFlex,// ComputedgroupedRecordings, totalInQueue, completedInQueue, queuedFiles, finishedFilesInQueue, isMobileScreen,+ processedTranscription, // <-- ADDED: Expose processedTranscription computed property// Inline editing stateeditingParticipants, editingMeetingDate, editingSummary, editingNotes,// Methods@@ -1870,6 +1968,8 @@ document.addEventListener('DOMContentLoaded', () => {selectedMobileTab,switchMobileTab,toggleEditMobileMeetingDate, // Expose for mobile+ transcriptionViewMode,+ toggleTranscriptionViewMode,// Main column resizer refs (not needed in template but good practice if they were)// leftMainColumn, rightMainColumn, mainColumnResizer, mainContentColumns}diff --git a/templates/index.html b/templates/index.htmlindex 36e8e80c..b18802b3 100644--- a/templates/index.html+++ b/templates/index.html@@ -401,9 +401,48 @@<!-- Reprocess transcription button moved to main header --></div></div>++ <!-- View Mode Toggle for Mobile -->+ <div v-if="processedTranscription.hasDialogue" class="view-mode-toggle">+ <button @click="toggleTranscriptionViewMode"+ :class="{ active: transcriptionViewMode === 'simple' }"+ class="toggle-button">+ <i class="fas fa-list mr-1"></i> Simple+ </button>+ <button @click="toggleTranscriptionViewMode"+ :class="{ active: transcriptionViewMode === 'bubble' }"+ class="toggle-button">+ <i class="fas fa-comments mr-1"></i> Bubbles+ </button>+ </div><div class="mobile-content-box"><div v-if="selectedRecording.status === 'COMPLETED' || selectedRecording.status === 'SUMMARIZING'">- <pre class="whitespace-pre-wrap font-sans">${ selectedRecording.transcription || 'No transcription available.' }</pre>+ <!-- Speaker Legend (if dialogue detected and bubble view) -->+ <div v-if="processedTranscription.hasDialogue && transcriptionViewMode === 'bubble'" class="speaker-legend">+ <div v-for="speaker in processedTranscription.speakers" :key="speaker.name" class="speaker-legend-item">+ <div :class="speaker.color" class="speaker-color-dot"></div>+ <span class="speaker-name">${ speaker.name }</span>+ </div>+ </div>++ <!-- Transcription Content -->+ <div v-if="processedTranscription.hasDialogue">+ <!-- Simple View -->+ <div v-if="transcriptionViewMode === 'simple'" class="transcription-simple-view">+ <div v-for="(segment, index) in processedTranscription.segments" :key="index" class="speaker-segment">+ <div :class="[segment.color, 'speaker-tablet']">${ segment.speaker }</div>+ <div class="speaker-text">${ segment.text }</div>+ </div>+ </div>+ <!-- Bubble View -->+ <div v-else class="transcription-with-speakers">+ <div v-for="(segment, index) in processedTranscription.segments" :key="index"+ :class="[segment.color, 'speaker-bubble', { 'speaker-me': segment.speaker && segment.speaker.toLowerCase().includes('me') }]">+ <div class="speaker-bubble-content">${ segment.text }</div>+ </div>+ </div>+ </div>+ <pre v-else class="whitespace-pre-wrap font-sans">${ selectedRecording.transcription || 'No transcription available.' }</pre></div><div v-else-if="selectedRecording.status === 'FAILED'" class="text-[var(--text-danger)]"><p class="font-medium mb-2">Processing Failed:</p>@@ -686,34 +725,43 @@<h3 class="text-2xl font-semibold text-[var(--text-primary)] flex items-center"><span class="responsive-title" style="min-width: 0;">${ selectedRecording.title || 'Loading...' }</span></h3>- <p class="text-sm text-[var(--text-muted)] mt-2 flex flex-wrap items-center gap-x-3 gap-y-1">+ <div class="recording-metadata"><!-- Display Meeting Date with edit functionality -->- <span class="inline-flex items-center">- <i class="fas fa-calendar-alt text-[var(--text-accent)] opacity-75 mr-1.5"></i>- <span v-if="!editingMeetingDate">- <span class="font-medium">Meeting:</span>- <span @click="toggleEditMeetingDate" class="cursor-pointer hover:text-[var(--text-accent)] hover:underline transition-colors">- ${ selectedRecording.meeting_date ? formatDisplayDate(selectedRecording.meeting_date) : 'Click to add' }- </span>+ <div class="metadata-item">+ <i class="fas fa-calendar-alt metadata-icon"></i>+ <span class="metadata-label">Meeting:</span>+ <span v-if="!editingMeetingDate"+ @click="toggleEditMeetingDate"+ class="metadata-value editable">+ ${ selectedRecording.meeting_date ? formatDisplayDate(selectedRecording.meeting_date) : 'Click to add' }</span><span v-else class="inline-flex items-center">- <input type="date" v-model="selectedRecording.meeting_date"- @blur="saveInlineEdit('meeting_date')"- class="p-0 w-40 bg-transparent border-b border-[var(--border-secondary)] focus:outline-none focus:border-[var(--border-focus)]" />- <button @click="saveInlineEdit('meeting_date')" class="ml-1 text-xs text-[var(--text-accent)]">+ <input type="date"+ v-model="selectedRecording.meeting_date"+ @blur="saveInlineEdit('meeting_date')"+ class="metadata-edit-input" />+ <button @click="saveInlineEdit('meeting_date')"+ class="metadata-edit-button"><i class="fas fa-check"></i></button></span>- </span>- <span class="inline-flex items-center">- <i class="fas fa-clock text-[var(--text-accent)] opacity-75 mr-1.5"></i>- <span class="font-medium">Created:</span> ${ new Date(selectedRecording.created_at).toLocaleString() }- </span>- <!-- Status Badge Moved Here -->- <span v-if="selectedRecording.status !== 'COMPLETED'" :class="getStatusClass(selectedRecording.status)" class="status-badge">- ${ formatStatus(selectedRecording.status) }- </span>- </p>+ </div>++ <div class="metadata-item">+ <i class="fas fa-clock metadata-icon"></i>+ <span class="metadata-label">Created:</span>+ <span class="metadata-value">${ new Date(selectedRecording.created_at).toLocaleString() }</span>+ </div>++ <!-- Status Badge -->+ <div v-if="selectedRecording.status !== 'COMPLETED'" class="metadata-item">+ <i class="fas fa-info-circle metadata-icon"></i>+ <span class="metadata-label">Status:</span>+ <span :class="getStatusClass(selectedRecording.status)" class="status-badge">+ ${ formatStatus(selectedRecording.status) }+ </span>+ </div>+ </div><!-- Removed Size from here --><!-- Removed separate Status Badge span --></div>@@ -784,9 +832,49 @@</button></div></div>++ <!-- View Mode Toggle for Desktop -->+ <div v-if="processedTranscription.hasDialogue" class="view-mode-toggle mb-2">+ <button @click="toggleTranscriptionViewMode"+ :class="{ active: transcriptionViewMode === 'simple' }"+ class="toggle-button">+ <i class="fas fa-list mr-1"></i> Simple+ </button>+ <button @click="toggleTranscriptionViewMode"+ :class="{ active: transcriptionViewMode === 'bubble' }"+ class="toggle-button">+ <i class="fas fa-comments mr-1"></i> Bubbles+ </button>+ </div>+<div class="transcription-box custom-scrollbar relative"><div v-if="selectedRecording.status === 'COMPLETED' || selectedRecording.status === 'SUMMARIZING'" class="copyable">- <pre class="whitespace-pre-wrap font-sans">${ selectedRecording.transcription || 'No transcription available.' }</pre>+ <!-- Speaker Legend (if dialogue detected and bubble view) -->+ <div v-if="processedTranscription.hasDialogue && transcriptionViewMode === 'bubble'" class="speaker-legend">+ <div v-for="speaker in processedTranscription.speakers" :key="speaker.name" class="speaker-legend-item">+ <div :class="speaker.color" class="speaker-color-dot"></div>+ <span class="speaker-name">${ speaker.name }</span>+ </div>+ </div>++ <!-- Transcription Content -->+ <div v-if="processedTranscription.hasDialogue">+ <!-- Simple View -->+ <div v-if="transcriptionViewMode === 'simple'" class="transcription-simple-view">+ <div v-for="(segment, index) in processedTranscription.segments" :key="index" class="speaker-segment">+ <div :class="[segment.color, 'speaker-tablet']">${ segment.speaker }</div>+ <div class="speaker-text">${ segment.text }</div>+ </div>+ </div>+ <!-- Bubble View -->+ <div v-else class="transcription-with-speakers">+ <div v-for="(segment, index) in processedTranscription.segments" :key="index"+ :class="[segment.color, 'speaker-bubble', { 'speaker-me': segment.speaker && segment.speaker.toLowerCase().includes('me') }]">+ <div class="speaker-bubble-content">${ segment.text }</div>+ </div>+ </div>+ </div>+ <pre v-else class="whitespace-pre-wrap font-sans">${ selectedRecording.transcription || 'No transcription available.' }</pre></div><div v-else-if="selectedRecording.status === 'FAILED'" class="text-[var(--text-danger)]"><p class="font-medium mb-2">Processing Failed:</p>@@ -889,9 +977,9 @@<!-- Resizer Handle for Main Columns --><div id="mainColumnResizer"- class="hidden md:flex items-center justify-center w-2 bg-transparent hover:bg-[var(--border-accent)] cursor-ew-resize flex-shrink-0 mx-1 group"+ class="hidden md:flex items-center justify-center w-2 bg-transparent cursor-ew-resize flex-shrink-0 mx-1 group"title="Drag to resize columns">- <div class="w-1 h-16 bg-[var(--border-primary)] group-hover:bg-[var(--text-accent)] rounded-full transition-colors duration-150"></div>+ <div class="w-1 h-10 bg-[var(--text-light)] group-hover:bg-[var(--border-accent)] rounded-full transition-colors duration-150"></div></div><!-- Right Column: Audio & Chat -->