Speakr is a personal, self-hosted web application designed for transcribing audio recordings
Python
Add needs filters for recordings
Fran Fitzpatrick60a4cac8ab79
diff --git a/src/api/recordings.py b/src/api/recordings.pyindex 9476a965..dbdef882 100644--- a/src/api/recordings.py+++ b/src/api/recordings.py@@ -93,6 +93,21 @@ from src.utils.file_hash import compute_file_sha256# Create blueprintrecordings_bp = Blueprint('recordings', __name__)+ACTIVE_RECORDING_STATUSES = ['QUEUED', 'PENDING', 'PROCESSING', 'SUMMARIZING']+TRANSCRIPTION_ERROR_PREFIXES = [+ 'ERROR_JSON:',+ 'Transcription failed:',+ 'Processing failed:',+ 'ASR processing failed:',+ 'Audio extraction failed:',+ 'Upload/Processing failed:',+]+SUMMARY_NEEDS_PREFIXES = [+ '[Summary generation failed:',+ '[Summary skipped:',+ '[Summary not generated]',+]+# Configuration from environmentENABLE_INQUIRE_MODE = os.environ.get('ENABLE_INQUIRE_MODE', 'false').lower() == 'true'ENABLE_AUTO_DELETION = os.environ.get('ENABLE_AUTO_DELETION', 'false').lower() == 'true'@@ -104,6 +119,62 @@ VIDEO_PASSTHROUGH_ASR = os.environ.get('VIDEO_PASSTHROUGH_ASR', 'false').lower()USE_ASR_ENDPOINT = os.environ.get('USE_ASR_ENDPOINT', 'false').lower() == 'true'ENABLE_CHUNKING = os.environ.get('ENABLE_CHUNKING', 'true').lower() == 'true'++def _idle_recording_condition():+ """Recordings that are not currently queued or running work."""+ return db.or_(+ Recording.status.is_(None),+ ~Recording.status.in_(ACTIVE_RECORDING_STATUSES),+ )+++def _blank_column_condition(column):+ return db.or_(column.is_(None), db.func.trim(column) == '')+++def _prefixed_column_condition(column, prefixes):+ return db.or_(*[column.like(f'{prefix}%') for prefix in prefixes])+++def _transcription_error_condition():+ return _prefixed_column_condition(Recording.transcription, TRANSCRIPTION_ERROR_PREFIXES)+++def _valid_transcription_condition():+ return db.and_(+ ~_blank_column_condition(Recording.transcription),+ ~_transcription_error_condition(),+ )+++def _needs_transcription_condition():+ return db.and_(+ _idle_recording_condition(),+ db.or_(+ _blank_column_condition(Recording.transcription),+ _transcription_error_condition(),+ ),+ )+++def _needs_summary_condition():+ return db.and_(+ _idle_recording_condition(),+ _valid_transcription_condition(),+ db.or_(+ _blank_column_condition(Recording.summary),+ _prefixed_column_condition(Recording.summary, SUMMARY_NEEDS_PREFIXES),+ ),+ )+++def _needs_speakers_condition():+ return db.and_(+ _idle_recording_condition(),+ _valid_transcription_condition(),+ Recording.transcription.like('%SPEAKER\\_%', escape='\\'),+ )+def reindex_recording_chunks_async(recording_id):"""Rebuild a recording's semantic-search (Inquire) chunks in the background.@@ -1522,6 +1593,9 @@ def get_recordings_paginated():show_shared = request.args.get('shared', '').lower() == 'true'show_starred = request.args.get('starred', '').lower() == 'true'show_inbox = request.args.get('inbox', '').lower() == 'true'+ needs_transcription = request.args.get('needs_transcription', '').lower() == 'true'+ needs_summary = request.args.get('needs_summary', '').lower() == 'true'+ needs_speakers = request.args.get('needs_speakers', '').lower() == 'true'sort_by = request.args.get('sort_by', 'created_at') # 'created_at' or 'meeting_date'folder_filter = request.args.get('folder', '').strip() # folder_id or 'none' for no folder@@ -1604,6 +1678,15 @@ def get_recordings_paginated():except ValueError:pass # Invalid folder_id, ignore filter+ if needs_transcription:+ stmt = stmt.where(_needs_transcription_condition())++ if needs_summary:+ stmt = stmt.where(_needs_summary_condition())++ if needs_speakers:+ stmt = stmt.where(_needs_speakers_condition())+# Apply search filters if providedif search_query:# Extract date filtersdiff --git a/static/js/app.modular.js b/static/js/app.modular.jsindex 88236b92..da6a5686 100644--- a/static/js/app.modular.js+++ b/static/js/app.modular.js@@ -277,6 +277,9 @@ document.addEventListener('DOMContentLoaded', async () => {const filterTextQuery = ref('');const filterStarred = ref(false);const filterInbox = ref(false);+ const filterNeedsTranscription = ref(false);+ const filterNeedsSummary = ref(false);+ const filterNeedsSpeakers = ref(false);const showArchivedRecordings = ref(false);const showSharedWithMe = ref(false);@@ -1575,6 +1578,7 @@ document.addEventListener('DOMContentLoaded', async () => {// FiltersshowAdvancedFilters, filterTags, filterSpeakers, filterTagSearch, filterSpeakerSearch,filterDateRange, filterDatePreset, filterTextQuery, filterStarred, filterInbox,+ filterNeedsTranscription, filterNeedsSummary, filterNeedsSpeakers,showArchivedRecordings, showSharedWithMe, sortBy, selectedTagFilter,// Pagination@@ -3277,6 +3281,18 @@ document.addEventListener('DOMContentLoaded', async () => {recordingsComposable.loadRecordings(1, false, searchQuery.value);});+ watch(filterNeedsTranscription, () => {+ recordingsComposable.loadRecordings(1, false, searchQuery.value);+ });++ watch(filterNeedsSummary, () => {+ recordingsComposable.loadRecordings(1, false, searchQuery.value);+ });++ watch(filterNeedsSpeakers, () => {+ recordingsComposable.loadRecordings(1, false, searchQuery.value);+ });+watch(filterFolder, (newValue) => {// Persist folder selection to localStorageif (newValue) {diff --git a/static/js/modules/composables/recordings.js b/static/js/modules/composables/recordings.jsindex 57658b3f..15c549f3 100644--- a/static/js/modules/composables/recordings.js+++ b/static/js/modules/composables/recordings.js@@ -11,7 +11,8 @@ export function useRecordings(state, utils, reprocessComposable) {currentPage, perPage, totalRecordings, totalPages, hasNextPage, hasPrevPage,showSharedWithMe, showArchivedRecordings, searchQuery, searchDebounceTimer,filterTags, filterSpeakers, filterDatePreset, filterDateRange, filterTextQuery,- filterStarred, filterInbox, filterFolder, sortBy,+ filterStarred, filterInbox, filterNeedsTranscription, filterNeedsSummary, filterNeedsSpeakers,+ filterFolder, sortBy,availableTags, availableSpeakers, availableFolders, selectedTagIds, uploadLanguage, uploadMinSpeakers, uploadMaxSpeakers, uploadHotwords, uploadInitialPrompt,useAsrEndpoint, connectorSupportsDiarization, globalError, uploadQueue, isProcessingActive, currentView, showUploadModal, uploadDeepLinkPending,isMobileScreen, isSidebarCollapsed, isRecording, audioBlobURL,@@ -61,6 +62,15 @@ export function useRecordings(state, utils, reprocessComposable) {if (filterInbox.value) {params.set('inbox', 'true');}+ if (filterNeedsTranscription.value) {+ params.set('needs_transcription', 'true');+ }+ if (filterNeedsSummary.value) {+ params.set('needs_summary', 'true');+ }+ if (filterNeedsSpeakers.value) {+ params.set('needs_speakers', 'true');+ }// Add folder filterif (filterFolder && filterFolder.value) {@@ -439,6 +449,9 @@ export function useRecordings(state, utils, reprocessComposable) {filterTextQuery.value = '';filterStarred.value = false;filterInbox.value = false;+ filterNeedsTranscription.value = false;+ filterNeedsSummary.value = false;+ filterNeedsSpeakers.value = false;// Note: filterFolder is NOT cleared here - it's a navigation element, not a filtersearchQuery.value = '';};diff --git a/static/locales/en.json b/static/locales/en.jsonindex e7d13eae..96d57e4a 100644--- a/static/locales/en.json+++ b/static/locales/en.json@@ -1409,6 +1409,9 @@"loadMore": "Load More","markAsRead": "Mark as read","moveToInbox": "Move to Inbox",+ "needsSpeakers": "Needs Speakers",+ "needsSummary": "Needs Summary",+ "needsTranscription": "Needs Transcription","noRecordings": "No recordings found","older": "Older","removeFromHighlighted": "Remove from starred",diff --git a/templates/components/sidebar.html b/templates/components/sidebar.htmlindex d5b30246..cc793151 100644--- a/templates/components/sidebar.html+++ b/templates/components/sidebar.html@@ -62,16 +62,16 @@class="flex-1 h-7 flex items-center justify-between pl-2 pr-2 bg-[var(--bg-input)] border border-[var(--border-secondary)] rounded text-xs hover:bg-[var(--bg-tertiary)] transition-colors"><span class="flex items-center"><i class="fas fa-filter mr-1.5 text-[var(--text-muted)] text-[10px]"></i>- <span v-if="!searchQuery && filterTags.length === 0 && filterSpeakers.length === 0 && !filterDatePreset && !filterDateRange.start && !filterDateRange.end && !filterTextQuery && !filterStarred && !filterInbox"+ <span v-if="!searchQuery && filterTags.length === 0 && filterSpeakers.length === 0 && !filterDatePreset && !filterDateRange.start && !filterDateRange.end && !filterTextQuery && !filterStarred && !filterInbox && !filterNeedsTranscription && !filterNeedsSummary && !filterNeedsSpeakers"v-text="t('sidebar.searchRecordings')"></span><span v-else class="text-[var(--text-accent)]">- Active filters (${ (filterTags.length > 0 ? 1 : 0) + (filterSpeakers.length > 0 ? 1 : 0) + (filterDatePreset || filterDateRange.start || filterDateRange.end ? 1 : 0) + (filterTextQuery ? 1 : 0) + (filterStarred ? 1 : 0) + (filterInbox ? 1 : 0) })+ Active filters (${ (filterTags.length > 0 ? 1 : 0) + (filterSpeakers.length > 0 ? 1 : 0) + (filterDatePreset || filterDateRange.start || filterDateRange.end ? 1 : 0) + (filterTextQuery ? 1 : 0) + (filterStarred ? 1 : 0) + (filterInbox ? 1 : 0) + (filterNeedsTranscription ? 1 : 0) + (filterNeedsSummary ? 1 : 0) + (filterNeedsSpeakers ? 1 : 0) })</span></span><i :class="['fas fa-chevron-down transition-transform text-[var(--text-muted)] text-[10px]', showAdvancedFilters ? 'rotate-180' : '']"></i></button>- <button v-if="searchQuery || filterTags.length > 0 || filterSpeakers.length > 0 || filterDatePreset || filterDateRange.start || filterDateRange.end || filterTextQuery || filterStarred || filterInbox"+ <button v-if="searchQuery || filterTags.length > 0 || filterSpeakers.length > 0 || filterDatePreset || filterDateRange.start || filterDateRange.end || filterTextQuery || filterStarred || filterInbox || filterNeedsTranscription || filterNeedsSummary || filterNeedsSpeakers"@click="clearAllFilters"class="w-7 h-7 flex items-center justify-center bg-[var(--bg-input)] border border-[var(--border-secondary)] rounded text-xs hover:bg-[var(--bg-tertiary)] hover:text-[var(--text-primary)] transition-colors":title="t('buttons.clearAllFilters')">@@ -123,6 +123,46 @@</button></div>+ <!-- Needs Filters -->+ <div class="grid grid-cols-3 gap-2">+ <button @click="filterNeedsTranscription = !filterNeedsTranscription"+ :aria-pressed="filterNeedsTranscription"+ :aria-label="t('sidebar.needsTranscription')"+ :class="[+ 'min-h-[3.75rem] min-w-0 flex flex-col items-center justify-center gap-1 px-1 py-2 rounded-md text-[11px] font-medium leading-[1.15] text-center transition-all border overflow-hidden',+ filterNeedsTranscription+ ? 'bg-red-500/20 border-red-500/50 text-red-400'+ : 'bg-[var(--bg-input)] border-[var(--border-secondary)] text-[var(--text-muted)] hover:border-red-500/30 hover:text-red-400'+ ]">+ <i class="fas fa-keyboard text-[11px] leading-none"></i>+ <span class="block max-w-full text-[10px] leading-[1.15] whitespace-normal break-normal" v-text="t('sidebar.needsTranscription')"></span>+ </button>+ <button @click="filterNeedsSummary = !filterNeedsSummary"+ :aria-pressed="filterNeedsSummary"+ :aria-label="t('sidebar.needsSummary')"+ :class="[+ 'min-h-[3.75rem] min-w-0 flex flex-col items-center justify-center gap-1 px-1 py-2 rounded-md text-[11px] font-medium leading-[1.15] text-center transition-all border overflow-hidden',+ filterNeedsSummary+ ? 'bg-emerald-500/20 border-emerald-500/50 text-emerald-400'+ : 'bg-[var(--bg-input)] border-[var(--border-secondary)] text-[var(--text-muted)] hover:border-emerald-500/30 hover:text-emerald-400'+ ]">+ <i class="fas fa-list-alt text-[11px] leading-none"></i>+ <span class="block max-w-full whitespace-normal break-normal" v-text="t('sidebar.needsSummary')"></span>+ </button>+ <button @click="filterNeedsSpeakers = !filterNeedsSpeakers"+ :aria-pressed="filterNeedsSpeakers"+ :aria-label="t('sidebar.needsSpeakers')"+ :class="[+ 'min-h-[3.75rem] min-w-0 flex flex-col items-center justify-center gap-1 px-1 py-2 rounded-md text-[11px] font-medium leading-[1.15] text-center transition-all border overflow-hidden',+ filterNeedsSpeakers+ ? 'bg-violet-500/20 border-violet-500/50 text-violet-400'+ : 'bg-[var(--bg-input)] border-[var(--border-secondary)] text-[var(--text-muted)] hover:border-violet-500/30 hover:text-violet-400'+ ]">+ <i class="fas fa-user-edit text-[11px] leading-none"></i>+ <span class="block max-w-full whitespace-normal break-normal" v-text="t('sidebar.needsSpeakers')"></span>+ </button>+ </div>+<!-- Tag Filter --><div class="bg-[var(--bg-secondary)] rounded-lg p-2.5 border border-[var(--border-primary)]"><div class="flex items-center justify-between gap-2 mb-2">diff --git a/tests/test_cov_recordings_read.py b/tests/test_cov_recordings_read.pyindex e7e13082..2dc1aa82 100644--- a/tests/test_cov_recordings_read.py+++ b/tests/test_cov_recordings_read.py@@ -156,7 +156,7 @@ def make_user():def make_recording(user, *, status="COMPLETED", transcription="hello world this is a transcript",audio_path="local://covrec/audio.mp3", title="rec",summary="a summary", original_filename="audio.mp3",- mime_type="audio/mpeg", folder_id=None):+ mime_type="audio/mpeg", folder_id=None, participants=None):rec = Recording(audio_path=audio_path,original_filename=original_filename,@@ -164,6 +164,7 @@ def make_recording(user, *, status="COMPLETED", transcription="hello world thisstatus=status,transcription=transcription,summary=summary,+ participants=participants,user_id=user.id,mime_type=mime_type,folder_id=folder_id,@@ -385,6 +386,166 @@ def test_paginated_speaker_filter(owner):assert nomatch_id not in ids+def test_paginated_needs_transcription_filter(owner):+ with _db():+ u = db.session.get(User, owner)+ missing = make_recording(u, title="needs-transcription", transcription=None).id+ error = make_recording(+ u,+ title="failed-transcription",+ status="FAILED",+ transcription="Transcription failed: provider unavailable",+ ).id+ ready = make_recording(u, title="already-transcribed", transcription="valid transcript").id+ active = make_recording(+ u,+ title="active-transcription",+ status="QUEUED",+ transcription=None,+ ).id++ c = new_client()+ login(c, owner)+ resp = c.get("/api/recordings?needs_transcription=true&per_page=100")+ assert resp.status_code == 200+ ids = {r["id"] for r in resp.get_json()["recordings"]}+ assert missing in ids+ assert error in ids+ assert ready not in ids+ assert active not in ids+++def test_paginated_needs_summary_filter(owner):+ with _db():+ u = db.session.get(User, owner)+ missing = make_recording(+ u,+ title="needs-summary",+ transcription="valid transcript with enough words",+ summary=None,+ ).id+ failed = make_recording(+ u,+ title="failed-summary",+ status="FAILED",+ transcription="valid transcript with enough words",+ summary="[Summary generation failed: quota exceeded]",+ ).id+ no_transcript = make_recording(+ u,+ title="no-transcript-summary",+ transcription=None,+ summary=None,+ ).id+ active = make_recording(+ u,+ title="active-summary",+ status="SUMMARIZING",+ transcription="valid transcript with enough words",+ summary=None,+ ).id+ ready = make_recording(+ u,+ title="summary-ready",+ transcription="valid transcript with enough words",+ summary="finished summary",+ ).id++ c = new_client()+ login(c, owner)+ resp = c.get("/api/recordings?needs_summary=true&per_page=100")+ assert resp.status_code == 200+ ids = {r["id"] for r in resp.get_json()["recordings"]}+ assert missing in ids+ assert failed in ids+ assert no_transcript not in ids+ assert active not in ids+ assert ready not in ids+++def test_paginated_needs_speakers_filter(owner):+ with _db():+ u = db.session.get(User, owner)+ unresolved = make_recording(+ u,+ title="needs-speakers",+ transcription=json.dumps([+ {"speaker": "SPEAKER_00", "sentence": "Hello."},+ {"speaker": "Alice", "sentence": "Hi."},+ ]),+ ).id+ assigned = make_recording(+ u,+ title="speakers-assigned",+ transcription=json.dumps([+ {"speaker": "Alice", "sentence": "Hello."},+ {"speaker": "Bob", "sentence": "Hi."},+ ]),+ participants="Alice, Bob",+ ).id+ active = make_recording(+ u,+ title="active-speakers",+ status="PROCESSING",+ transcription=json.dumps([+ {"speaker": "SPEAKER_00", "sentence": "Still running."},+ ]),+ ).id+ no_transcript = make_recording(u, title="no-speaker-transcript", transcription=None).id++ c = new_client()+ login(c, owner)+ resp = c.get("/api/recordings?needs_speakers=true&per_page=100")+ assert resp.status_code == 200+ ids = {r["id"] for r in resp.get_json()["recordings"]}+ assert unresolved in ids+ assert assigned not in ids+ assert active not in ids+ assert no_transcript not in ids+++def test_paginated_needs_filters_and_with_existing_filters(owner):+ tagname = f"needstag{uuid.uuid4().hex[:6]}"+ with _db():+ u = db.session.get(User, owner)+ tag = Tag(name=tagname, user_id=u.id)+ db.session.add(tag)+ db.session.commit()+ tagged_need = make_recording(+ u,+ title="tagged-needs-summary",+ transcription="valid transcript with enough words",+ summary=None,+ )+ db.session.add(RecordingTag(recording_id=tagged_need.id, tag_id=tag.id, order=1))+ tagged_ready = make_recording(+ u,+ title="tagged-summary-ready",+ transcription="valid transcript with enough words",+ summary="finished summary",+ )+ db.session.add(RecordingTag(recording_id=tagged_ready.id, tag_id=tag.id, order=1))+ untagged_need = make_recording(+ u,+ title="untagged-needs-summary",+ transcription="valid transcript with enough words",+ summary=None,+ )+ db.session.commit()+ tagged_need_id = tagged_need.id+ tagged_ready_id = tagged_ready.id+ untagged_need_id = untagged_need.id++ c = new_client()+ login(c, owner)+ resp = c.get(f"/api/recordings?needs_summary=true&q=tag:{tagname}&per_page=100")+ assert resp.status_code == 200+ ids = {r["id"] for r in resp.get_json()["recordings"]}+ assert tagged_need_id in ids+ assert tagged_ready_id not in ids+ assert untagged_need_id not in ids++def test_paginated_requires_login():c = new_client()resp = c.get("/api/recordings")