Speakr is a personal, self-hosted web application designed for transcribing audio recordings
Python
asr diarization off
Murtaza Nasir8ff23983197d
diff --git a/app.py b/app.pyindex e83a3b2a..12deb168 100644--- a/app.py+++ b/app.py@@ -323,8 +323,6 @@ transcription_base_url = os.environ.get("TRANSCRIPTION_BASE_URL", "https://openr# ASR endpoint configurationUSE_ASR_ENDPOINT = os.environ.get('USE_ASR_ENDPOINT', 'false').lower() == 'true'ASR_BASE_URL = os.environ.get('ASR_BASE_URL')-ASR_ENCODE = os.environ.get('ASR_ENCODE', 'true').lower() == 'true'-ASR_TASK = os.environ.get('ASR_TASK', 'transcribe')ASR_DIARIZE = os.environ.get('ASR_DIARIZE', 'true').lower() == 'true'ASR_MIN_SPEAKERS = os.environ.get('ASR_MIN_SPEAKERS')ASR_MAX_SPEAKERS = os.environ.get('ASR_MAX_SPEAKERS')@@ -367,33 +365,27 @@ def generate_summary_task(app_context, recording_id, start_time):user_summary_prompt = recording.owner.summary_promptuser_output_language = recording.owner.output_language- default_summary_prompt = """Analyze the following audio transcription and generate a concise title and a brief summary.+ default_summary_prompt = """Analyze the following audio transcription and generate a concise title and a detailed, well-structured summary in Markdown format.Transcription:\"\"\"{transcription}\"\"\"-Respond STRICTLY with a JSON object containing two keys: "title" (a short, descriptive title, max 6 words without using words introductory words and phrases like brief, "discussion on", "Meeting about" etc.) and "minutes" (a paragraph summarizing the key points, max 150 words). The title should get to the point without inroductory phrases as we have very little space to show the title.-{language_directive}-Example Format:-{{- "title": "Q3 Results for SPERO Program",- "summary": "### Minutes+Respond STRICTLY with a JSON object containing two keys: "title" and "summary".-**Meeting Participants:**-- Bob-- Alice+1. **title**: A short, descriptive title (max 6-8 words). Avoid introductory phrases like "Discussion on" or "Meeting about".+2. **summary**: A detailed summary in Markdown format. It should include the following sections:+ * **Key Issues Discussed**: A bulleted list of the main topics.+ * **Key Decisions Made**: A bulleted list of any decisions reached.+ * **Action Items**: A bulleted list of tasks assigned, including who is responsible if mentioned.----+{language_directive}-**1. Introduction and Overview:**-- Alice expressed interest in understanding the responsibilities at the north division and the potential for technological innovations.-....-### Key Issues Discussed-....-//and so on and so forth. Make sure not to miss any nuance or details.-"+Example Format:+{{+ "title": "Q3 Strategy and Project Phoenix",+ "summary": "### Key Issues Discussed\\n- Review of Q2 performance and its impact on Q3 planning.\\n- Feasibility and timeline for Project Phoenix.\\n- Budget constraints and resource allocation for new initiatives.\\n\\n### Key Decisions Made\\n- Project Phoenix is approved to proceed with a revised timeline.\\n- The marketing budget will be reallocated to support the new launch.\\n\\n### Action Items\\n- **Alice**: Finalize the Project Phoenix roadmap by next Friday.\\n- **Bob**: Present the revised budget to the finance committee."}}JSON Response:"""@@ -481,8 +473,8 @@ def transcribe_audio_asr(app_context, recording_id, filepath, original_filename,with open(filepath, 'rb') as audio_file:url = f"{ASR_BASE_URL}/asr"params = {- 'encode': ASR_ENCODE,- 'task': ASR_TASK,+ 'encode': True,+ 'task': 'transcribe','output': 'json'}if language:diff --git a/static/css/styles.css b/static/css/styles.cssindex 9dcf038b..8979811d 100644--- a/static/css/styles.css+++ b/static/css/styles.css@@ -206,8 +206,22 @@ main {white-space: nowrap;min-width: 0;}- /* Unified style for content boxes (summary, notes, transcription) */-.summary-box, .transcription-box, .notes-box {+.summary-box,+.notes-box {+ flex: 1; /* Take up available space in content-box */+ min-height: 0; /* Critical for flex shrinking */+ max-height: 100%; /* Prevent expansion beyond parent */+ overflow-y: auto; /* Enable scrolling */+ /* Keep existing styling */+ background-color: var(--bg-tertiary);+ padding: 1rem;+ border-radius: 0.75rem;+ border: 1px solid var(--border-primary);+ color: var(--text-secondary);+ box-shadow: 0 1px 2px rgba(0,0,0,0.03);+}++.transcription-box {background-color: var(--bg-tertiary);padding: 1rem; /* p-4 */border-radius: 0.75rem; /* rounded-xl */@@ -248,9 +262,8 @@ div[v-if="!editingNotes"] {display: flex;flex-direction: column;height: 100%;- gap: 1rem;+ min-height: 0; /* Allow flex to work properly */overflow: hidden; /* Prevent this container from scrolling */- min-height: 0; /* Allows flex to work properly */}/* Right column content (audio player, chat) */@@ -271,20 +284,18 @@ div[v-if="!editingNotes"] {/* Transcription section - takes up significant space */.transcription-section {/* flex: 2; */ /* Removed: Let JavaScript control flex values */- min-height: 0; /* Allows flex to work properly */- overflow-y: auto; /* Changed from hidden to auto to enable scrolling */+ min-height: 0; /* Critical for flex shrinking */+ overflow: hidden; /* Contain overflow to enable proper flex behavior */display: flex;flex-direction: column;}/* Tab content section - takes up remaining space and aligns with chat box */.tab-section {- /* flex: 1; */ /* Removed: Let JavaScript control flex values */- min-height: 100px; /* Minimum height to prevent collapsing too much */- overflow-y: auto; /* Changed from hidden to auto to enable scrolling */+ min-height: 0; /* Critical for flex items */+ overflow: hidden; /* Prevent internal overflow from affecting layout */display: flex;flex-direction: column;- /* height: 100%; */ /* Removed: Let flex property control height */}/* Audio player section - small fixed height */@@ -392,10 +403,14 @@ div[v-if="!editingNotes"] {}/* Hover edit button styles */- .content-box {- position: relative;- overflow-y: auto; /* Allow content to scroll */- }+.content-box {+ position: relative;+ height: 100%; /* Fill the available flex space */+ min-height: 0; /* Allow shrinking */+ display: flex;+ flex-direction: column;+ overflow: hidden; /* Prevent overflow from affecting parent layout */+}.hover-edit-btn {position: absolute;diff --git a/static/js/app.js b/static/js/app.jsindex 7e040c6a..67e1e39f 100644--- a/static/js/app.js+++ b/static/js/app.js@@ -227,6 +227,21 @@ document.addEventListener('DOMContentLoaded', () => {// Updated to handle new simplified JSON format (array of segments)if (transcriptionData && Array.isArray(transcriptionData)) {+ // If no segments have a speaker, it wasn't diarized. Treat as plain text.+ const wasDiarized = transcriptionData.some(segment => segment.speaker);++ if (!wasDiarized) {+ const plainText = transcriptionData.map(segment => segment.sentence).join('\n');+ return {+ hasDialogue: false,+ isJson: false, // Treat as plain text for rendering+ content: plainText,+ speakers: [],+ simpleSegments: [],+ bubbleRows: []+ };+ }+const speakerColors = {};const speakerList = identifiedSpeakers.value; // Use computed property which is already sortedspeakerList.forEach((speaker, index) => {@@ -255,7 +270,7 @@ document.addEventListener('DOMContentLoaded', () => {const bubbleRows = [];let lastBubbleSpeaker = null;simpleSegments.forEach(segment => {- if (segment.speaker !== lastBubbleSpeaker) {+ if (bubbleRows.length === 0 || segment.speaker !== lastBubbleSpeaker) {bubbleRows.push({speaker: segment.speaker,color: segment.color,@@ -1456,30 +1471,34 @@ document.addEventListener('DOMContentLoaded', () => {};const handleVerticalResize = (event) => {- if (!isResizingVertical.value || !transcriptionSection.value || !tabSection.value) return;+ if (!isResizingVertical.value) return;- const dy = event.clientY - initialVerticalResizeY;- const totalHeight = initialTranscriptionHeightPx + initialTabHeightPx;-- let newTranscriptionHeight = initialTranscriptionHeightPx + dy;- let newTabHeight = totalHeight - newTranscriptionHeight;-- // Enforce minimum heights- const minHeight = 100; // Minimum height in pixels- if (newTranscriptionHeight < minHeight) {- newTranscriptionHeight = minHeight;- newTabHeight = totalHeight - minHeight;- } else if (newTabHeight < minHeight) {- newTabHeight = minHeight;- newTranscriptionHeight = totalHeight - minHeight;- }-- // Convert to flex values (proportional)- const newTranscriptionFlex = newTranscriptionHeight / totalHeight * 3; // Scale to reasonable flex values- const newTabFlex = newTabHeight / totalHeight * 3;-- transcriptionFlex.value = Math.max(0.5, newTranscriptionFlex);- tabsFlex.value = Math.max(0.5, newTabFlex);+ requestAnimationFrame(() => {+ if (!transcriptionSection.value || !tabSection.value) return;++ const dy = event.clientY - initialVerticalResizeY;+ const totalHeight = initialTranscriptionHeightPx + initialTabHeightPx;++ let newTranscriptionHeight = initialTranscriptionHeightPx + dy;++ // Enforce minimum heights (e.g., 100px)+ const minHeight = 100;+ if (newTranscriptionHeight < minHeight) {+ newTranscriptionHeight = minHeight;+ } else if (totalHeight - newTranscriptionHeight < minHeight) {+ newTranscriptionHeight = totalHeight - minHeight;+ }++ const newTabHeight = totalHeight - newTranscriptionHeight;++ // Convert heights to flex-grow values+ // The sum of flex-grow values will be used for proportioning+ const newTranscriptionFlex = newTranscriptionHeight / totalHeight;+ const newTabFlex = newTabHeight / totalHeight;++ transcriptionFlex.value = newTranscriptionFlex;+ tabsFlex.value = newTabFlex;+ });};const stopVerticalResize = () => {diff --git a/templates/index.html b/templates/index.htmlindex 4f2ccafc..a4284471 100644--- a/templates/index.html+++ b/templates/index.html@@ -555,7 +555,7 @@</div></div></div>- <pre v-else class="whitespace-pre-wrap font-sans">${ selectedRecording.transcription || 'No transcription available.' }</pre>+ <pre v-else class="whitespace-pre-wrap font-sans">${ processedTranscription.content || '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>@@ -1010,7 +1010,7 @@</div></div></div>- <pre v-else class="whitespace-pre-wrap font-sans">${ selectedRecording.transcription || 'No transcription available.' }</pre>+ <pre v-else class="whitespace-pre-wrap font-sans">${ processedTranscription.content || '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>@@ -1070,10 +1070,9 @@<!-- Summary Panel --><div v-show="selectedTab === 'summary'" class="h-full"><div v-if="selectedRecording.status === 'COMPLETED'" class="h-full">- <div v-if="!editingSummary" class="content-box h-full flex flex-col min-h-0">- <div class="summary-box custom-scrollbar bg-[var(--bg-tertiary)] border-[var(--border-primary)] text-[var(--text-secondary)]" v-html="selectedRecording.summary_html || selectedRecording.summary || 'No summary generated.'">+ <div v-if="!editingSummary" class="content-box h-full flex flex-col min-h-0">+ <div class="summary-box custom-scrollbar" v-html="selectedRecording.summary_html || selectedRecording.summary || 'No summary generated.'"></div>-</div><textarea v-else v-model="selectedRecording.summary" @blur="saveInlineEdit('summary')" class="summary-box custom-scrollbar bg-[var(--bg-tertiary)] border-[var(--border-primary)] text-[var(--text-secondary)] w-full focus:ring-[var(--ring-focus)] focus:border-[var(--border-focus)] tab-content-box" placeholder="Enter summary"></textarea></div>