Skip to content

Speakr is a personal, self-hosted web application designed for transcribing audio recordings

Python

Find and replace in the transcript editors; notes given to the summarizer on request (#440)

Murtaza Nasir2e7b014c7a00
diff --git a/docs/user-guide/settings.md b/docs/user-guide/settings.md
index 0e0aa3a6..cc195733 100644
--- a/docs/user-guide/settings.md
+++ b/docs/user-guide/settings.md
@@ -109,6 +109,10 @@ At the top of the Prompt Options you can control whether the AI receives per-lin
Each toggle has a format dropdown. **Default** uses a compact `[hh:mm:ss] Speaker: text` layout; you can also select any of your saved transcript templates to control exactly how each line is rendered. Both toggles are off by default, which keeps the prompt shorter and avoids spending tokens on timestamps when you do not need them.
+### Notes in Summaries
+
+When **Give the summarization agent my notes** is on, your notes on a recording are added to the summary request as context. Notes can hold the correct spelling of names and products, an agenda, or text pasted from an email or a chat thread. The transcript remains the record of what was said. The setting is off by default, applies to summaries generated after it is turned on (regenerate a summary to use it on an existing recording), and uses only your own notes, never those of people a recording is shared with. Up to 8,000 characters of notes are sent.
+
### Writing Effective Prompts
Craft prompts based on how you actually use summaries. Do you extract action items for project management? Look for decisions that affect strategy? Track technical details for documentation? Your prompt should request exactly what you need for these next steps.
diff --git a/docs/user-guide/transcripts.md b/docs/user-guide/transcripts.md
index ab378bff..58548308 100644
--- a/docs/user-guide/transcripts.md
+++ b/docs/user-guide/transcripts.md
@@ -58,6 +58,8 @@ The ASR editor presents your transcription as a table of segments, where each ro
**Edit Text Content**: The main content of each utterance can be edited directly in its text field. You can correct transcription errors, fix grammar, add punctuation, or clarify unclear speech while maintaining the segment structure.
+**Find and Replace**: Click the search icon in the header of either editor, or press Ctrl+F (Cmd+F on a Mac), to open the find and replace bar. The number of matches is shown as you type. Enter moves to the next match and Shift+Enter to the previous one; **Replace** replaces the selected match, and **Replace all** replaces every match in the transcript text. **Aa** limits the search to the same capitals, and **ab** to whole words. Speaker names are not changed (use the speaker editor for those), and nothing is saved until you save the transcript, so Cancel discards the replacements. After correcting a name throughout, regenerate the summary to carry the correction into it.
+
**Manage Segments**: Use the trash icon to remove segments that shouldn't be in the transcription (such as false detections or noise). You can also add new segments if the ASR system missed something, positioning them with appropriate timestamps.
The ASR editor maintains the JSON structure of your transcription, which is essential for features like speaker-based search, audio synchronization (clicking on text to jump to that point in the audio), and proper display in bubble view. When you save changes in the ASR editor, the system preserves all timing and speaker information while applying your corrections.
diff --git a/src/api/auth.py b/src/api/auth.py
index c4c3dfd8..d3481ab6 100644
--- a/src/api/auth.py
+++ b/src/api/auth.py
@@ -790,6 +790,9 @@ def account():
return tpl.id if tpl else None
current_user.summary_include_timestamps = 'summary_include_timestamps' in request.form
+ # Gated on its marker field so another form cannot clear it (#440)
+ if 'summary_notes_section' in request.form:
+ current_user.summary_include_notes = 'summary_include_notes' in request.form
current_user.summary_timestamp_template_id = _ts_template_id('summary_timestamp_template_id')
current_user.chat_include_timestamps = 'chat_include_timestamps' in request.form
current_user.chat_timestamp_template_id = _ts_template_id('chat_timestamp_template_id')
diff --git a/src/init_db.py b/src/init_db.py
index 5fa6e5e2..fd3a5f92 100644
--- a/src/init_db.py
+++ b/src/init_db.py
@@ -465,6 +465,9 @@ def _run_migrations(app, engine):
# Per-feature transcript timestamp settings (#304)
if add_column_if_not_exists(engine, 'user', 'summary_include_timestamps', 'BOOLEAN DEFAULT 0'):
app.logger.info("Added summary_include_timestamps column to user table")
+ # Notes given to the summarizer (#440), off by default
+ if add_column_if_not_exists(engine, 'user', 'summary_include_notes', 'BOOLEAN DEFAULT 0'):
+ app.logger.info("Added summary_include_notes column to user table")
if add_column_if_not_exists(engine, 'user', 'summary_timestamp_template_id', 'INTEGER'):
app.logger.info("Added summary_timestamp_template_id column to user table")
if add_column_if_not_exists(engine, 'user', 'chat_include_timestamps', 'BOOLEAN DEFAULT 0'):
diff --git a/src/models/user.py b/src/models/user.py
index 19772c8b..a41274c6 100644
--- a/src/models/user.py
+++ b/src/models/user.py
@@ -101,6 +101,9 @@ class User(db.Model, UserMixin):
summary_include_timestamps = db.Column(db.Boolean, default=False)
summary_timestamp_template_id = db.Column(db.Integer, db.ForeignKey('transcript_template.id', ondelete='SET NULL'), nullable=True)
chat_include_timestamps = db.Column(db.Boolean, default=False)
+ # Give the summarizer the owner's notes on the recording (#440). Off by
+ # default, so existing summaries are generated as before.
+ summary_include_notes = db.Column(db.Boolean, default=False)
chat_timestamp_template_id = db.Column(db.Integer, db.ForeignKey('transcript_template.id', ondelete='SET NULL'), nullable=True)
# UI/display preferences
diff --git a/src/tasks/processing.py b/src/tasks/processing.py
index 844b9835..3100913c 100644
--- a/src/tasks/processing.py
+++ b/src/tasks/processing.py
@@ -67,6 +67,9 @@ PREFIX_CACHE_OPTIMIZED_PROMPTS = os.environ.get(
'PREFIX_CACHE_OPTIMIZED_PROMPTS', 'false'
).lower() == 'true'
+# Longest notes text given to the summarizer (#440)
+SUMMARY_NOTES_LIMIT = 8000
+
# Must be byte-identical between the title and summary calls. Keep it short and
# generic; per-task guidance belongs in the user-message suffix.
_SHARED_LLM_SYSTEM_MSG = (
@@ -764,6 +767,18 @@ def generate_summary_only_task(app_context, recording_id, custom_prompt_override
context_section = "Context:\n" + "\n".join(f"- {part}" for part in context_parts)
+ # The owner's notes on the recording, when they chose to include them
+ # (#440). The notes add context; the transcript stays the source.
+ if recording.owner and recording.owner.summary_include_notes:
+ owner_notes = (recording.get_user_notes(recording.owner) or '').strip()
+ if owner_notes:
+ context_section += (
+ "\n\nNotes written by the user about this recording (use them as "
+ "context, for example for names, spellings and background; the "
+ "transcript remains the record of what was said):\n"
+ f'"""\n{owner_notes[:SUMMARY_NOTES_LIMIT]}\n"""'
+ )
+
if PREFIX_CACHE_OPTIMIZED_PROMPTS:
# Shared-prefix layout: the system message and the user-message bytes
# up to and including the transcript block MUST match _generate_ai_title
diff --git a/static/css/styles.css b/static/css/styles.css
index a71cec65..6dd6cc29 100644
--- a/static/css/styles.css
+++ b/static/css/styles.css
@@ -4994,3 +4994,61 @@ select:disabled {
.usage-meters--stacked .usage-meter { padding-top: 0; padding-bottom: 0; font-size: 10px; line-height: 1.2; gap: 0.3rem; }
.usage-meters--stacked .usage-meter span { min-width: 2.2rem; text-align: right; font-variant-numeric: tabular-nums; }
.usage-meters--stacked .usage-meter > div { height: 3px; }
+
+/* Find and replace bar of the transcript editors (#440) */
+.find-replace-bar {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ gap: var(--sp-2);
+ padding: var(--sp-2) var(--sp-4);
+ border-bottom: var(--border-hairline) solid var(--border-primary);
+ background: var(--bg-secondary);
+ flex-shrink: 0;
+}
+.find-replace-bar__fields {
+ display: flex;
+ flex: 1 1 22rem;
+ gap: var(--sp-2);
+ min-width: 0;
+}
+.find-replace-bar__field {
+ position: relative;
+ flex: 1 1 0;
+ min-width: 0;
+}
+.find-replace-bar__field .field {
+ padding-left: 1.75rem;
+ padding-right: 4.5rem;
+}
+.find-replace-bar__icon {
+ position: absolute;
+ left: 0.6rem;
+ top: 50%;
+ transform: translateY(-50%);
+ font-size: 0.7rem;
+ color: var(--text-muted);
+ pointer-events: none;
+}
+.find-replace-bar__count {
+ position: absolute;
+ right: 0.6rem;
+ top: 50%;
+ transform: translateY(-50%);
+ pointer-events: none;
+ white-space: nowrap;
+}
+.find-replace-bar__replace {
+ flex: 1 1 0;
+ min-width: 0;
+}
+.find-replace-bar__actions {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ gap: var(--sp-1);
+}
+.find-replace-toggle[aria-pressed="true"] {
+ background: var(--bg-accent);
+ color: var(--text-accent);
+}
diff --git a/static/js/app.modular.js b/static/js/app.modular.js
index 9c6c6aea..3706806a 100644
--- a/static/js/app.modular.js
+++ b/static/js/app.modular.js
@@ -9,6 +9,7 @@ import { useModals } from './modules/composables/modals.js';
import { useSharing } from './modules/composables/sharing.js';
import { useReprocess } from './modules/composables/reprocess.js';
import { useTranscription } from './modules/composables/transcription.js';
+import { useFindReplace } from './modules/composables/find-replace.js';
import { useSpeakers } from './modules/composables/speakers.js';
import { useSpeakerModal } from './modules/composables/speaker-modal.js';
import { useChat } from './modules/composables/chat.js';
@@ -753,6 +754,8 @@ document.addEventListener('DOMContentLoaded', async () => {
const editingRecording = ref(null);
const editingTranscriptionContent = ref('');
const editingSegments = ref([]);
+ // Find and replace bar of the transcript editors (#440)
+ const findReplace = reactive({ open: false, find: '', replace: '', matchCase: false, wholeWord: false, current: -1 });
const availableSpeakers = ref([]);
const showEditSpeakersModal = ref(false);
const editingSpeakersList = ref([]);
@@ -1878,7 +1881,7 @@ document.addEventListener('DOMContentLoaded', async () => {
showEditModal, showDeleteModal, showEditTagsModal, selectedNewTagId, tagSearchFilter,
showReprocessModal, showResetModal, showSpeakerModal, speakerModalTab, speakerModalVideoCollapsed, toggleSpeakerModalVideo, showShareModal, showSharesListModal,
showTextEditorModal, showAsrEditorModal, asrEditorHydratedRows, hydrateAsrEditorRow, showCustomizeSummaryModal, customizeSummaryPrompt, customizeSummaryMode, editingRecording, editingTranscriptionContent,
- editingSegments, availableSpeakers, showEditSpeakersModal, editingSpeakersList,
+ editingSegments, findReplace, availableSpeakers, showEditSpeakersModal, editingSpeakersList,
databaseSpeakers, editingSpeakerSuggestions,
showEditParticipantsModal, editingParticipantsList, editingParticipantSuggestions, allParticipants,
recordingToShare, shareOptions,
@@ -2609,6 +2612,7 @@ document.addEventListener('DOMContentLoaded', async () => {
const modalsComposable = useModals(state, utils);
const sharingComposable = useSharing(state, utils);
const transcriptionComposable = useTranscription(state, utils);
+ const findReplaceComposable = useFindReplace(state, utils);
const chatComposable = useChat(state, utils);
const pwaComposable = usePWA(state, utils);
const notificationsComposable = useNotifications(state, utils);
@@ -4544,6 +4548,7 @@ document.addEventListener('DOMContentLoaded', async () => {
...sharingComposable,
...reprocessComposable,
...transcriptionComposable,
+ ...findReplaceComposable,
...speakersComposable,
...speakerModalComposable,
...chatComposable,
diff --git a/static/js/modules/composables/find-replace.js b/static/js/modules/composables/find-replace.js
new file mode 100644
index 00000000..77dd8d84
--- /dev/null
+++ b/static/js/modules/composables/find-replace.js
@@ -0,0 +1,157 @@
+/**
+ * Find and replace in the transcript editors (#440).
+ *
+ * Works on the open editor: the sentences of the segment editor, or the text
+ * of the plain transcript editor. Changes are made to the editor's copy, so
+ * Cancel still discards them.
+ */
+
+import { buildMatcher, findMatches, replaceAllIn, replaceAt } from '../utils/find-replace.js';
+
+const computedOr = (fn) => (typeof Vue !== 'undefined' && Vue.computed)
+ ? Vue.computed(fn)
+ : { get value() { return fn(); } };
+
+export function useFindReplace(state, utils) {
+ const {
+ findReplace, showAsrEditorModal, showTextEditorModal,
+ editingSegments, editingTranscriptionContent, asrEditorHighlightIndex
+ } = state;
+ const { showToast, nextTick = (fn) => fn && fn(), t = (key) => key } = utils;
+
+ const openEditor = () => {
+ if (showAsrEditorModal && showAsrEditorModal.value) return 'segments';
+ if (showTextEditorModal && showTextEditorModal.value) return 'text';
+ return null;
+ };
+
+ const editorTexts = () => {
+ const editor = openEditor();
+ if (editor === 'segments') return editingSegments.value.map((s) => s.sentence || '');
+ if (editor === 'text') return [editingTranscriptionContent.value || ''];
+ return [];
+ };
+
+ const matcher = () => buildMatcher(findReplace.find, findReplace);
+ const findReplaceMatches = computedOr(() => findMatches(editorTexts(), matcher()));
+
+ const findReplaceLabel = computedOr(() => {
+ const total = findReplaceMatches.value.length;
+ if (!findReplace.find) return '';
+ if (!total) return t('findReplace.noMatches');
+ return findReplace.current >= 0 ? `${findReplace.current + 1} / ${total}` : String(total);
+ });
+
+ const setText = (index, text) => {
+ if (openEditor() === 'segments') editingSegments.value[index].sentence = text;
+ else editingTranscriptionContent.value = text;
+ };
+
+ // Show the match in the editor: scroll its row into view and select it.
+ const revealMatch = (match) => {
+ if (!match || typeof document === 'undefined') return;
+ if (openEditor() === 'segments') {
+ if (asrEditorHighlightIndex) asrEditorHighlightIndex.value = match.index;
+ if (utils.scrollAsrEditorToIndex) utils.scrollAsrEditorToIndex(match.index);
+ }
+ nextTick(() => {
+ const field = openEditor() === 'segments'
+ ? document.querySelector(`[data-segment-index="${match.index}"] textarea`)
+ : document.querySelector('[data-transcript-textarea]');
+ if (!field) return;
+ field.blur();
+ field.setSelectionRange(match.start, match.end);
+ field.focus({ preventScroll: openEditor() === 'segments' });
+ });
+ };
+
+ const goToMatch = (step = 1) => {
+ const total = findReplaceMatches.value.length;
+ if (!total) {
+ findReplace.current = -1;
+ return;
+ }
+ const from = findReplace.current < 0 && step < 0 ? 0 : findReplace.current;
+ findReplace.current = ((from + step) % total + total) % total;
+ revealMatch(findReplaceMatches.value[findReplace.current]);
+ };
+
+ // Replace the current match, then show the one after it.
+ const replaceCurrentMatch = () => {
+ const matches = findReplaceMatches.value;
+ if (!matches.length) return;
+ if (findReplace.current < 0 || findReplace.current >= matches.length) {
+ goToMatch(1);
+ return;
+ }
+ const match = matches[findReplace.current];
+ const text = editorTexts()[match.index];
+ setText(match.index, replaceAt(text, match.start, match.end, findReplace.replace));
+ const remaining = findReplaceMatches.value.length;
+ if (!remaining) {
+ findReplace.current = -1;
+ return;
+ }
+ findReplace.current = Math.min(findReplace.current, remaining - 1);
+ revealMatch(findReplaceMatches.value[findReplace.current]);
+ };
+
+ const replaceAllMatches = () => {
+ const m = matcher();
+ let total = 0;
+ editorTexts().forEach((text, index) => {
+ const result = replaceAllIn(text, m, findReplace.replace);
+ if (result.count) {
+ setText(index, result.text);
+ total += result.count;
+ }
+ });
+ findReplace.current = -1;
+ if (asrEditorHighlightIndex) asrEditorHighlightIndex.value = null;
+ if (total && showToast) showToast(t('findReplace.replacedCount', { count: total }), 'fa-check-circle');
+ };
+
+ const openFindReplace = () => {
+ findReplace.open = true;
+ nextTick(() => {
+ const input = typeof document !== 'undefined' && document.querySelector('[data-find-input]');
+ if (input) {
+ input.focus();
+ input.select();
+ }
+ });
+ };
+
+ const closeFindReplace = () => {
+ findReplace.open = false;
+ findReplace.current = -1;
+ if (asrEditorHighlightIndex) asrEditorHighlightIndex.value = null;
+ };
+
+ // A new search starts again from the first match
+ if (typeof Vue !== 'undefined' && Vue.watch) {
+ Vue.watch(() => [findReplace.find, findReplace.matchCase, findReplace.wholeWord],
+ () => { findReplace.current = -1; });
+ // Each editor opens with the bar closed
+ Vue.watch(() => openEditor(), () => closeFindReplace());
+ }
+
+ // Ctrl+F / Cmd+F (and Ctrl+H) open the bar while an editor is open: the
+ // browser's own search does not reach text inside the editor's fields.
+ const handleFindShortcut = (event) => {
+ if (!openEditor()) return;
+ const key = (event.key || '').toLowerCase();
+ if ((event.ctrlKey || event.metaKey) && (key === 'f' || key === 'h')) {
+ event.preventDefault();
+ openFindReplace();
+ }
+ };
+ if (typeof window !== 'undefined') {
+ window.addEventListener('keydown', handleFindShortcut);
+ }
+
+ return {
+ findReplaceMatches, findReplaceLabel, goToMatch, replaceCurrentMatch,
+ replaceAllMatches, openFindReplace, closeFindReplace
+ };
+}
diff --git a/static/js/modules/composables/find-replace.test.js b/static/js/modules/composables/find-replace.test.js
new file mode 100644
index 00000000..fe7762eb
--- /dev/null
+++ b/static/js/modules/composables/find-replace.test.js
@@ -0,0 +1,68 @@
+import { describe, expect, it } from 'vitest';
+
+import { useFindReplace } from './find-replace.js';
+
+const ref = (value) => ({ value });
+
+function editor({ segments = null, text = '' } = {}) {
+ const state = {
+ findReplace: { open: true, find: '', replace: '', matchCase: false, wholeWord: false, current: -1 },
+ showAsrEditorModal: ref(!!segments),
+ showTextEditorModal: ref(!segments),
+ editingSegments: ref((segments || []).map((sentence) => ({ speaker: 'A', sentence }))),
+ editingTranscriptionContent: ref(text),
+ asrEditorHighlightIndex: ref(null),
+ };
+ const toasts = [];
+ const api = useFindReplace(state, { showToast: (m) => toasts.push(m), t: (k, p) => (p ? `${k}:${p.count}` : k) });
+ return { state, api, toasts };
+}
+
+describe('find and replace in the transcript editors (#440)', () => {
+ it('counts matches across segments', () => {
+ const { state, api } = editor({ segments: ['Acme agreed', 'acme and ACME', 'none'] });
+ state.findReplace.find = 'acme';
+ expect(api.findReplaceMatches.value.map((m) => m.index)).toEqual([0, 1, 1]);
+ expect(api.findReplaceLabel.value).toBe('3');
+ });
+
+ it('replaces every match in the segments', () => {
+ const { state, api, toasts } = editor({ segments: ['Acme agreed', 'acme and ACME'] });
+ Object.assign(state.findReplace, { find: 'acme', replace: 'Akme' });
+ api.replaceAllMatches();
+ expect(state.editingSegments.value.map((s) => s.sentence)).toEqual(['Akme agreed', 'Akme and Akme']);
+ expect(state.editingSegments.value[0].speaker).toBe('A');
+ expect(toasts).toEqual(['findReplace.replacedCount:3']);
+ });
+
+ it('replaces one match at a time, moving to the next', () => {
+ const { state, api } = editor({ segments: ['cat cat', 'cat'] });
+ Object.assign(state.findReplace, { find: 'cat', replace: 'dog' });
+ api.goToMatch(1);
+ expect(state.findReplace.current).toBe(0);
+ api.replaceCurrentMatch();
+ expect(state.editingSegments.value[0].sentence).toBe('dog cat');
+ expect(api.findReplaceLabel.value).toBe('1 / 2');
+ api.replaceCurrentMatch();
+ api.replaceCurrentMatch();
+ expect(state.editingSegments.value.map((s) => s.sentence)).toEqual(['dog dog', 'dog']);
+ expect(state.findReplace.current).toBe(-1);
+ expect(api.findReplaceLabel.value).toBe('findReplace.noMatches');
+ });
+
+ it('works on the plain transcript text', () => {
+ const { state, api } = editor({ text: 'Speaker 1: hello\nSpeaker 1: bye' });
+ Object.assign(state.findReplace, { find: 'speaker 1', replace: 'Dana', matchCase: false });
+ api.replaceAllMatches();
+ expect(state.editingTranscriptionContent.value).toBe('Dana: hello\nDana: bye');
+ });
+
+ it('wraps around when moving past the last match', () => {
+ const { state, api } = editor({ segments: ['a', 'a'] });
+ state.findReplace.find = 'a';
+ api.goToMatch(-1);
+ expect(state.findReplace.current).toBe(1);
+ api.goToMatch(1);
+ expect(state.findReplace.current).toBe(0);
+ });
+});
diff --git a/static/js/modules/utils/find-replace.js b/static/js/modules/utils/find-replace.js
new file mode 100644
index 00000000..49cb376d
--- /dev/null
+++ b/static/js/modules/utils/find-replace.js
@@ -0,0 +1,47 @@
+/**
+ * Find and replace in transcript text (#440).
+ *
+ * A search is literal text, never a regular expression. "Whole words" means
+ * the match is not part of a longer word in any script (letters, digits and
+ * underscore count as word characters).
+ */
+
+const escapeRegExp = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
+
+/** A global RegExp for the search, or null when there is nothing to find. */
+export function buildMatcher(find, { matchCase = false, wholeWord = false } = {}) {
+ if (!find) return null;
+ let source = escapeRegExp(find);
+ if (wholeWord) source = `(?<![\\p{L}\\p{N}_])${source}(?![\\p{L}\\p{N}_])`;
+ return new RegExp(source, `gu${matchCase ? '' : 'i'}`);
+}
+
+/** Every match in a list of texts, as { index, start, end }, in reading order. */
+export function findMatches(texts, matcher) {
+ const matches = [];
+ if (!matcher) return matches;
+ texts.forEach((text, index) => {
+ if (!text) return;
+ matcher.lastIndex = 0;
+ for (const m of String(text).matchAll(matcher)) {
+ matches.push({ index, start: m.index, end: m.index + m[0].length });
+ }
+ });
+ return matches;
+}
+
+/** The text with every match replaced, and the number of replacements. */
+export function replaceAllIn(text, matcher, replacement) {
+ if (!matcher || !text) return { text, count: 0 };
+ let count = 0;
+ const out = String(text).replace(matcher, () => {
+ count += 1;
+ return replacement;
+ });
+ return { text: out, count };
+}
+
+/** The text with the match at [start, end) replaced. */
+export function replaceAt(text, start, end, replacement) {
+ return text.slice(0, start) + replacement + text.slice(end);
+}
diff --git a/static/js/modules/utils/find-replace.test.js b/static/js/modules/utils/find-replace.test.js
new file mode 100644
index 00000000..771485cf
--- /dev/null
+++ b/static/js/modules/utils/find-replace.test.js
@@ -0,0 +1,39 @@
+import { describe, expect, it } from 'vitest';
+
+import { buildMatcher, findMatches, replaceAllIn, replaceAt } from './find-replace.js';
+
+describe('find and replace in transcript text (#440)', () => {
+ it('finds literal text, ignoring case by default', () => {
+ const m = buildMatcher('acme corp.');
+ expect(findMatches(['ACME Corp. and acme corp.', 'acme corpx'], m)).toEqual([
+ { index: 0, start: 0, end: 10 },
+ { index: 0, start: 15, end: 25 },
+ ]);
+ });
+
+ it('matches case when asked', () => {
+ expect(findMatches(['Kubernetes kubernetes'], buildMatcher('kubernetes', { matchCase: true })))
+ .toEqual([{ index: 0, start: 11, end: 21 }]);
+ });
+
+ it('matches whole words only when asked, in any script', () => {
+ const m = buildMatcher('ana', { wholeWord: true });
+ expect(findMatches(['Ana and Anabel', 'banana', 'Ana.'], m).map((x) => x.index)).toEqual([0, 2]);
+ expect(findMatches(['Müller Müllers'], buildMatcher('Müller', { wholeWord: true }))).toHaveLength(1);
+ });
+
+ it('replaces every match with the literal replacement', () => {
+ const m = buildMatcher('Speaker');
+ expect(replaceAllIn('speaker one, Speaker two', m, 'Dana $1')).toEqual({ text: 'Dana $1 one, Dana $1 two', count: 2 });
+ });
+
+ it('finds nothing for an empty search', () => {
+ expect(buildMatcher('')).toBe(null);
+ expect(findMatches(['abc'], null)).toEqual([]);
+ expect(replaceAllIn('abc', null, 'x')).toEqual({ text: 'abc', count: 0 });
+ });
+
+ it('replaces one match by position', () => {
+ expect(replaceAt('a cat sat', 2, 5, 'dog')).toBe('a dog sat');
+ });
+});
diff --git a/static/locales/de.json b/static/locales/de.json
index 10d610f6..daa540d1 100644
--- a/static/locales/de.json
+++ b/static/locales/de.json
@@ -477,6 +477,19 @@
"ctrlSHint": "Strg+S zum Speichern",
"saveWithoutClosing": "Speichern ohne Schließen (Strg+S)"
},
+ "findReplace": {
+ "open": "Suchen und ersetzen (Strg+F)",
+ "find": "Suchen",
+ "replaceWith": "Ersetzen durch",
+ "matchCase": "Groß-/Kleinschreibung beachten",
+ "wholeWord": "Ganze Wörter",
+ "previous": "Vorheriger Treffer (Umschalt+Eingabe)",
+ "next": "Nächster Treffer (Eingabe)",
+ "replace": "Ersetzen",
+ "replaceAll": "Alle ersetzen",
+ "noMatches": "Keine Treffer",
+ "replacedCount": "{{count}} ersetzt"
+ },
"audioRemoved": {
"filterHint": "Aufnahmen, deren Audiodatei entfernt wurde; das Transkript bleibt erhalten",
"label": "Audio entfernt"
@@ -2082,6 +2095,11 @@
"chatLabel": "Dem Chat-Agenten Zeitstempel geben",
"defaultFormat": "Standard-Zeitstempelformat"
},
+ "summaryNotes": {
+ "title": "Notizen in Zusammenfassungen",
+ "description": "Ihre Notizen zu einer Aufnahme, etwa die richtige Schreibweise von Namen, eine Tagesordnung oder aus einer E-Mail eingefügter Text, können dem Zusammenfassungsagenten als Kontext übergeben werden. Das Transkript bleibt die Aufzeichnung des Gesagten.",
+ "label": "Meine Notizen an den Zusammenfassungsagenten übergeben"
+ },
"toasts": {
"processingCompleted": "Verarbeitung abgeschlossen!",
"processingFailed": "Verarbeitung fehlgeschlagen",
diff --git a/static/locales/en.json b/static/locales/en.json
index 08492a08..3b8ebb47 100644
--- a/static/locales/en.json
+++ b/static/locales/en.json
@@ -477,6 +477,19 @@
"ctrlSHint": "Ctrl+S to save",
"saveWithoutClosing": "Save without closing (Ctrl+S)"
},
+ "findReplace": {
+ "open": "Find and replace (Ctrl+F)",
+ "find": "Find",
+ "replaceWith": "Replace with",
+ "matchCase": "Match case",
+ "wholeWord": "Whole words",
+ "previous": "Previous match (Shift+Enter)",
+ "next": "Next match (Enter)",
+ "replace": "Replace",
+ "replaceAll": "Replace all",
+ "noMatches": "No matches",
+ "replacedCount": "Replaced {{count}}"
+ },
"audioRemoved": {
"filterHint": "Recordings whose audio file was removed; the transcript is kept",
"label": "Audio removed"
@@ -2082,6 +2095,11 @@
"chatLabel": "Give the chat agent timestamps",
"defaultFormat": "Default timestamp format"
},
+ "summaryNotes": {
+ "title": "Notes in Summaries",
+ "description": "Your notes on a recording, such as the correct spelling of names, an agenda or text pasted from an email, can be given to the summarization agent as context. The transcript remains the record of what was said.",
+ "label": "Give the summarization agent my notes"
+ },
"toasts": {
"processingCompleted": "Processing completed!",
"processingFailed": "Processing failed",
diff --git a/static/locales/es.json b/static/locales/es.json
index 25386a87..9e88b41c 100644
--- a/static/locales/es.json
+++ b/static/locales/es.json
@@ -477,6 +477,19 @@
"ctrlSHint": "Ctrl+S para guardar",
"saveWithoutClosing": "Guardar sin cerrar (Ctrl+S)"
},
+ "findReplace": {
+ "open": "Buscar y reemplazar (Ctrl+F)",
+ "find": "Buscar",
+ "replaceWith": "Reemplazar con",
+ "matchCase": "Distinguir mayúsculas",
+ "wholeWord": "Palabras completas",
+ "previous": "Coincidencia anterior (Mayús+Intro)",
+ "next": "Coincidencia siguiente (Intro)",
+ "replace": "Reemplazar",
+ "replaceAll": "Reemplazar todo",
+ "noMatches": "Sin coincidencias",
+ "replacedCount": "{{count}} reemplazadas"
+ },
"audioRemoved": {
"filterHint": "Grabaciones cuyo archivo de audio se eliminó; la transcripción se conserva",
"label": "Audio eliminado"
@@ -2082,6 +2095,11 @@
"chatLabel": "Dar marcas de tiempo al agente de chat",
"defaultFormat": "Formato de marca de tiempo predeterminado"
},
+ "summaryNotes": {
+ "title": "Notas en los resúmenes",
+ "description": "Sus notas sobre una grabación, como la ortografía correcta de nombres, una agenda o texto pegado de un correo, pueden darse al agente de resúmenes como contexto. La transcripción sigue siendo el registro de lo que se dijo.",
+ "label": "Dar mis notas al agente de resúmenes"
+ },
"toasts": {
"processingCompleted": "¡Procesamiento completado!",
"processingFailed": "Error en el procesamiento",
diff --git a/static/locales/fr.json b/static/locales/fr.json
index 0efce5b1..77343c97 100644
--- a/static/locales/fr.json
+++ b/static/locales/fr.json
@@ -477,6 +477,19 @@
"ctrlSHint": "Ctrl+S pour enregistrer",
"saveWithoutClosing": "Enregistrer sans fermer (Ctrl+S)"
},
+ "findReplace": {
+ "open": "Rechercher et remplacer (Ctrl+F)",
+ "find": "Rechercher",
+ "replaceWith": "Remplacer par",
+ "matchCase": "Respecter la casse",
+ "wholeWord": "Mots entiers",
+ "previous": "Occurrence précédente (Maj+Entrée)",
+ "next": "Occurrence suivante (Entrée)",
+ "replace": "Remplacer",
+ "replaceAll": "Tout remplacer",
+ "noMatches": "Aucune occurrence",
+ "replacedCount": "{{count}} remplacée(s)"
+ },
"audioRemoved": {
"filterHint": "Enregistrements dont le fichier audio a été supprimé ; la transcription est conservée",
"label": "Audio supprimé"
@@ -2082,6 +2095,11 @@
"chatLabel": "Fournir les horodatages à l'agent de chat",
"defaultFormat": "Format d'horodatage par défaut"
},
+ "summaryNotes": {
+ "title": "Notes dans les résumés",
+ "description": "Vos notes sur un enregistrement, comme l'orthographe correcte des noms, un ordre du jour ou un texte copié d'un e-mail, peuvent être transmises à l'agent de résumé comme contexte. La transcription reste la trace de ce qui a été dit.",
+ "label": "Transmettre mes notes à l'agent de résumé"
+ },
"toasts": {
"processingCompleted": "Traitement terminé !",
"processingFailed": "Échec du traitement",
diff --git a/static/locales/pt-BR.json b/static/locales/pt-BR.json
index e6a47ab7..69c7d06e 100644
--- a/static/locales/pt-BR.json
+++ b/static/locales/pt-BR.json
@@ -477,6 +477,19 @@
"saveWithoutClosing": "Salvar sem fechar (Ctrl+S)",
"saved": "Salvo"
},
+ "findReplace": {
+ "open": "Localizar e substituir (Ctrl+F)",
+ "find": "Localizar",
+ "replaceWith": "Substituir por",
+ "matchCase": "Diferenciar maiúsculas",
+ "wholeWord": "Palavras inteiras",
+ "previous": "Ocorrência anterior (Shift+Enter)",
+ "next": "Próxima ocorrência (Enter)",
+ "replace": "Substituir",
+ "replaceAll": "Substituir tudo",
+ "noMatches": "Nenhuma ocorrência",
+ "replacedCount": "{{count}} substituídas"
+ },
"audioRemoved": {
"filterHint": "Gravações cujo arquivo de áudio foi removido; a transcrição é mantida",
"label": "Áudio removido"
@@ -2082,6 +2095,11 @@
"chatLabel": "Dar marcações de tempo ao agente de chat",
"defaultFormat": "Formato de marcação de tempo padrão"
},
+ "summaryNotes": {
+ "title": "Notas nos resumos",
+ "description": "Suas notas sobre uma gravação, como a grafia correta de nomes, uma pauta ou um texto colado de um e-mail, podem ser enviadas ao agente de resumo como contexto. A transcrição continua sendo o registro do que foi dito.",
+ "label": "Enviar minhas notas ao agente de resumo"
+ },
"toasts": {
"processingCompleted": "Processamento concluído!",
"processingFailed": "Falha no processamento",
diff --git a/static/locales/ru.json b/static/locales/ru.json
index 6f09f49e..14107613 100644
--- a/static/locales/ru.json
+++ b/static/locales/ru.json
@@ -477,6 +477,19 @@
"ctrlSHint": "Ctrl+S для сохранения",
"saveWithoutClosing": "Сохранить без закрытия (Ctrl+S)"
},
+ "findReplace": {
+ "open": "Найти и заменить (Ctrl+F)",
+ "find": "Найти",
+ "replaceWith": "Заменить на",
+ "matchCase": "С учётом регистра",
+ "wholeWord": "Слова целиком",
+ "previous": "Предыдущее совпадение (Shift+Enter)",
+ "next": "Следующее совпадение (Enter)",
+ "replace": "Заменить",
+ "replaceAll": "Заменить все",
+ "noMatches": "Нет совпадений",
+ "replacedCount": "Заменено: {{count}}"
+ },
"audioRemoved": {
"filterHint": "Записи, у которых удалён аудиофайл; транскрипт сохранён",
"label": "Аудио удалено"
@@ -2082,6 +2095,11 @@
"chatLabel": "Передавать метки времени агенту чата",
"defaultFormat": "Формат меток времени по умолчанию"
},
+ "summaryNotes": {
+ "title": "Заметки в сводках",
+ "description": "Ваши заметки к записи, например правильное написание имён, повестка или текст из письма, могут передаваться агенту сводок как контекст. Запись разговора остаётся источником того, что было сказано.",
+ "label": "Передавать мои заметки агенту сводок"
+ },
"toasts": {
"processingCompleted": "Обработка завершена!",
"processingFailed": "Обработка не удалась",
diff --git a/static/locales/zh.json b/static/locales/zh.json
index 1068a164..0f8ecaf2 100644
--- a/static/locales/zh.json
+++ b/static/locales/zh.json
@@ -477,6 +477,19 @@
"ctrlSHint": "Ctrl+S 保存",
"saveWithoutClosing": "保存但不关闭 (Ctrl+S)"
},
+ "findReplace": {
+ "open": "查找和替换 (Ctrl+F)",
+ "find": "查找",
+ "replaceWith": "替换为",
+ "matchCase": "区分大小写",
+ "wholeWord": "全字匹配",
+ "previous": "上一个 (Shift+Enter)",
+ "next": "下一个 (Enter)",
+ "replace": "替换",
+ "replaceAll": "全部替换",
+ "noMatches": "无匹配",
+ "replacedCount": "已替换 {{count}} 处"
+ },
"audioRemoved": {
"filterHint": "音频文件已删除的录音;转录文本保留",
"label": "音频已删除"
@@ -2082,6 +2095,11 @@
"chatLabel": "让聊天代理获得时间戳",
"defaultFormat": "默认时间戳格式"
},
+ "summaryNotes": {
+ "title": "摘要中的笔记",
+ "description": "您对录音的笔记(例如人名的正确拼写、议程或从邮件中粘贴的文字)可以作为上下文提供给摘要代理。转录文本仍是所说内容的记录。",
+ "label": "将我的笔记提供给摘要代理"
+ },
"toasts": {
"processingCompleted": "处理完成!",
"processingFailed": "处理失败",
diff --git a/templates/account.html b/templates/account.html
index 4e2705e5..0ca83aaf 100644
--- a/templates/account.html
+++ b/templates/account.html
@@ -798,6 +798,24 @@
</div>
</div>
+ <!-- Notes in summaries (#440) -->
+ <div class="bg-[var(--bg-tertiary)] p-6 rounded-lg border border-[var(--border-primary)]">
+ <input type="hidden" name="summary_notes_section" value="1">
+ <h3 class="text-lg font-medium text-[var(--text-secondary)] mb-2">
+ <i class="fas fa-sticky-note mr-2"></i>
+ <span data-i18n="summaryNotes.title">Notes in Summaries</span>
+ </h3>
+ <p class="text-xs text-[var(--text-muted)] mb-4" data-i18n="summaryNotes.description">
+ Your notes on a recording, such as the correct spelling of names, an agenda or text pasted from an email, can be given to the summarization agent as context. The transcript remains the record of what was said.
+ </p>
+ <label class="flex items-start space-x-3">
+ <input type="checkbox" name="summary_include_notes" id="summary_include_notes"
+ {% if current_user.summary_include_notes %}checked{% endif %}
+ class="mt-1 h-4 w-4 text-[var(--border-accent)] focus:ring-[var(--border-focus)] border-[var(--border-secondary)] rounded">
+ <span class="block text-sm font-medium text-[var(--text-primary)]" data-i18n="summaryNotes.label">Give the summarization agent my notes</span>
+ </label>
+ </div>
+
<!-- Event Extraction Settings -->
<div class="bg-[var(--bg-tertiary)] p-6 rounded-lg border border-[var(--border-primary)]">
<h3 class="text-lg font-medium text-[var(--text-secondary)] mb-4">
diff --git a/templates/components/find-replace-bar.html b/templates/components/find-replace-bar.html
new file mode 100644
index 00000000..1ae791d6
--- /dev/null
+++ b/templates/components/find-replace-bar.html
@@ -0,0 +1,41 @@
+<!-- Find and replace bar of the transcript editors (#440). Included in the
+ segment editor and the plain transcript editor; it acts on whichever
+ one is open. -->
+<div v-if="findReplace.open" class="find-replace-bar" @click.stop>
+ <div class="find-replace-bar__fields">
+ <div class="find-replace-bar__field">
+ <i class="fas fa-search find-replace-bar__icon"></i>
+ <input type="text" data-find-input class="field field--sm" v-model="findReplace.find"
+ :placeholder="t('findReplace.find')" :aria-label="t('findReplace.find')"
+ @keydown.enter.exact.prevent="goToMatch(1)"
+ @keydown.shift.enter.prevent="goToMatch(-1)"
+ @keydown.esc.stop.prevent="closeFindReplace">
+ <span class="find-replace-bar__count t-meta" aria-live="polite" v-text="findReplaceLabel"></span>
+ </div>
+ <input type="text" class="field field--sm find-replace-bar__replace" v-model="findReplace.replace"
+ :placeholder="t('findReplace.replaceWith')" :aria-label="t('findReplace.replaceWith')"
+ @keydown.enter.prevent="replaceCurrentMatch"
+ @keydown.esc.stop.prevent="closeFindReplace">
+ </div>
+ <div class="find-replace-bar__actions">
+ <button type="button" class="btn btn--icon btn--sm find-replace-toggle" :aria-pressed="findReplace.matchCase ? 'true' : 'false'"
+ @click="findReplace.matchCase = !findReplace.matchCase" :title="t('findReplace.matchCase')">
+ <span class="font-mono text-xs">Aa</span>
+ </button>
+ <button type="button" class="btn btn--icon btn--sm find-replace-toggle" :aria-pressed="findReplace.wholeWord ? 'true' : 'false'"
+ @click="findReplace.wholeWord = !findReplace.wholeWord" :title="t('findReplace.wholeWord')">
+ <span class="font-mono text-xs underline">ab</span>
+ </button>
+ <button type="button" class="btn btn--icon btn--sm" @click="goToMatch(-1)" :disabled="!findReplaceMatches.length" :title="t('findReplace.previous')">
+ <i class="fas fa-chevron-up text-xs"></i>
+ </button>
+ <button type="button" class="btn btn--icon btn--sm" @click="goToMatch(1)" :disabled="!findReplaceMatches.length" :title="t('findReplace.next')">
+ <i class="fas fa-chevron-down text-xs"></i>
+ </button>
+ <button type="button" class="btn btn--ghost btn--sm" @click="replaceCurrentMatch" :disabled="!findReplaceMatches.length" v-text="t('findReplace.replace')"></button>
+ <button type="button" class="btn btn--ghost btn--sm" @click="replaceAllMatches" :disabled="!findReplaceMatches.length" v-text="t('findReplace.replaceAll')"></button>
+ <button type="button" class="btn btn--icon btn--sm" @click="closeFindReplace" :title="t('buttons.close')">
+ <i class="fas fa-times text-xs"></i>
+ </button>
+ </div>
+</div>
diff --git a/templates/modals/asr-editor-modal.html b/templates/modals/asr-editor-modal.html
index a77691b4..6ad4ff22 100644
--- a/templates/modals/asr-editor-modal.html
+++ b/templates/modals/asr-editor-modal.html
@@ -7,6 +7,7 @@
<i class="fas fa-check-circle"></i>
<span v-text="t('asrEditor.saved')"></span>
</span>
+ <button @click="findReplace.open ? closeFindReplace() : openFindReplace()" class="modal-close ml-auto" :title="t('findReplace.open')"><i class="fas fa-search"></i></button>
<button @click="closeAsrEditorModal" class="modal-close" :title="t('buttons.close')"><i class="fas fa-times"></i></button>
</div>
@@ -73,6 +74,8 @@
</div>
</div>
+ {% include 'components/find-replace-bar.html' %}
+
<!-- Editor table uses VIRTUAL SCROLLING with fixed itemHeight=44
(set in app.modular.js's asrEditorVirtualScroll). This
modal is spreadsheet-like — every row carries the same
diff --git a/templates/modals/text-editor-modal.html b/templates/modals/text-editor-modal.html
index 88d9b20c..4c02a9b5 100644
--- a/templates/modals/text-editor-modal.html
+++ b/templates/modals/text-editor-modal.html
@@ -3,12 +3,14 @@
<div class="modal-panel modal-panel--lg">
<div class="modal-header">
<h3 class="modal-title" v-text="t('modal.editTranscription')"></h3>
+ <button @click="findReplace.open ? closeFindReplace() : openFindReplace()" class="modal-close ml-auto" :title="t('findReplace.open')"><i class="fas fa-search"></i></button>
<button @click="closeTextEditorModal" class="modal-close" :title="t('buttons.close')"><i class="fas fa-times"></i></button>
</div>
+ {% include 'components/find-replace-bar.html' %}
<div class="modal-body">
<div>
<label class="block text-sm font-medium mb-2" v-text="t('transcription.title')"></label>
- <textarea dir="auto" v-model="editingTranscriptionContent" rows="15" class="field font-mono" style="min-height: 320px;"></textarea>
+ <textarea dir="auto" data-transcript-textarea v-model="editingTranscriptionContent" rows="15" class="field font-mono" style="min-height: 320px;"></textarea>
</div>
</div>
<div class="modal-footer">
diff --git a/tests/test_summary_notes.py b/tests/test_summary_notes.py
new file mode 100644
index 00000000..47332b9d
--- /dev/null
+++ b/tests/test_summary_notes.py
@@ -0,0 +1,85 @@
+"""The owner's notes given to the summarizer (#440).
+
+Off by default. When the owner turns it on, their notes on the recording are
+added to the summary prompt's context, in both prompt layouts, and no other
+user's notes are used.
+"""
+
+from unittest.mock import MagicMock, patch
+
+import pytest
+
+import src.tasks.processing as processing
+from src.app import app, db
+from src.models import Recording, User
+
+NOTES = "Spell the client as Akme Corp. Agenda: launch date."
+
+
+def recording():
+ with app.app_context():
+ user = User(username="sumnotes_user", email="[email protected]", password="x")
+ db.session.add(user)
+ db.session.commit()
+ rec = Recording(user_id=user.id, title="Notes test", status="COMPLETED", notes=NOTES,
+ transcription="Alice: acme corp agreed on the 14th. Bob: good, that works for us.")
+ db.session.add(rec)
+ db.session.commit()
+ yield user, rec
+ db.session.delete(rec)
+ db.session.delete(user)
+ db.session.commit()
+
+
+def _summary_prompt(user, rec):
+ calls = []
+
+ def fake(messages=None, **kwargs):
+ calls.append(messages)
+ stub = MagicMock()
+ stub.choices = [MagicMock()]
+ stub.choices[0].message.content = "Summary"
+ stub.choices[0].message.reasoning = None
+ stub.usage = MagicMock(prompt_tokens=1, completion_tokens=1, total_tokens=2)
+ return stub
+
+ with patch("src.tasks.processing.call_llm_completion", side_effect=fake), \
+ patch("src.tasks.processing.client", new=MagicMock()):
+ processing.generate_summary_only_task(app.app_context(), rec.id, user_id=user.id)
+ return "\n".join(m["content"] for m in calls[0])
+
+
[email protected]("prefix_cache", [False, True])
+def test_notes_are_left_out_by_default(recording, prefix_cache):
+ user, rec = recording
+ with patch.object(processing, "PREFIX_CACHE_OPTIMIZED_PROMPTS", prefix_cache):
+ assert NOTES not in _summary_prompt(user, rec)
+
+
[email protected]("prefix_cache", [False, True])
+def test_notes_are_given_when_the_owner_turns_it_on(recording, prefix_cache):
+ user, rec = recording
+ user.summary_include_notes = True
+ db.session.commit()
+ with patch.object(processing, "PREFIX_CACHE_OPTIMIZED_PROMPTS", prefix_cache):
+ assert NOTES in _summary_prompt(user, rec)
+
+
+def test_account_form_saves_the_setting(recording):
+ user, _ = recording
+ client = app.test_client()
+ with client.session_transaction() as sess:
+ sess["_user_id"] = str(user.id)
+ sess["_fresh"] = True
+ app.config["WTF_CSRF_ENABLED"] = False
+ client.post("/account", data={"summary_prompt": "", "summary_notes_section": "1",
+ "summary_include_notes": "on"})
+ db.session.expire_all()
+ assert db.session.get(User, user.id).summary_include_notes is True
+ client.post("/account", data={"summary_prompt": ""})
+ db.session.expire_all()
+ assert db.session.get(User, user.id).summary_include_notes is True
+ client.post("/account", data={"summary_prompt": "", "summary_notes_section": "1"})
+ db.session.expire_all()
+ assert db.session.get(User, user.id).summary_include_notes is False