Skip to content

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

Python

Render compact mm:ss timestamps in simple transcript view when user opts in

Murtaza Nasir90d55b48e7fd
diff --git a/static/css/styles.css b/static/css/styles.css
index 50d1951a..0055d7d0 100644
--- a/static/css/styles.css
+++ b/static/css/styles.css
@@ -1666,6 +1666,29 @@ body {
transition: background-color 0.3s ease, box-shadow 0.3s ease;
}
+/* Header row that pairs the speaker tablet with an optional timestamp.
+ Only rendered when the user has enabled `show_timestamps_simple_view`. */
+.speaker-segment-header {
+ display: flex;
+ align-items: center;
+ gap: 0.5rem;
+ margin-bottom: 0.25rem;
+}
+
+.speaker-segment-timestamp {
+ font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
+ font-size: 0.7rem;
+ color: var(--text-muted);
+ letter-spacing: 0.02em;
+ user-select: none;
+}
+
+/* Inline variant -- used in the no-dialogue branch where the timestamp sits
+ on the same line as the sentence text. */
+.speaker-segment-timestamp--inline {
+ margin-right: 0.5rem;
+}
+
/* Active segment highlighting - for currently playing transcript */
.speaker-segment.active-playing-segment,
.transcript-segment.active-playing-segment {
diff --git a/static/js/app.modular.js b/static/js/app.modular.js
index 3f5f2727..99f04a75 100644
--- a/static/js/app.modular.js
+++ b/static/js/app.modular.js
@@ -578,6 +578,8 @@ document.addEventListener('DOMContentLoaded', async () => {
const connectorSupportsSpeakerCount = ref(false); // Connector capability for min/max speakers
const connectorSupportsHotwords = ref(false); // Connector accepts hotword/keyword biasing
const connectorSupportsInitialPrompt = ref(false); // Connector accepts initial prompt / context hint
+ const showTimestampsSimpleView = ref(false); // User pref: display timestamps in simple view
+ const editorAutosave = ref(false); // User pref: autosave transcript editor
const currentUserName = ref('');
const canDeleteRecordings = ref(true);
const enableInternalSharing = ref(false);
@@ -746,7 +748,7 @@ document.addEventListener('DOMContentLoaded', async () => {
openAsrDropdownIndex,
// App Config
- useAsrEndpoint, connectorSupportsDiarization, connectorSupportsSpeakerCount, connectorSupportsHotwords, connectorSupportsInitialPrompt, currentUserName, canDeleteRecordings, enableInternalSharing, enableArchiveToggle, showUsernamesInUI,
+ useAsrEndpoint, connectorSupportsDiarization, connectorSupportsSpeakerCount, connectorSupportsHotwords, connectorSupportsInitialPrompt, showTimestampsSimpleView, editorAutosave, formatTimestamp, currentUserName, canDeleteRecordings, enableInternalSharing, enableArchiveToggle, showUsernamesInUI,
// Internal Sharing
showUnifiedShareModal, internalShareUserSearch, internalShareSearchResults,
@@ -1026,6 +1028,20 @@ document.addEventListener('DOMContentLoaded', async () => {
// =========================================================================
// COMPUTED PROPERTIES (define before composables that need them)
// =========================================================================
+
+ // Compact mm:ss / h:mm:ss formatter for transcript timestamps. Returns
+ // an empty string when the input is missing so templates can render
+ // "" without a guard.
+ const formatTimestamp = (seconds) => {
+ if (seconds == null || isNaN(seconds)) return '';
+ const total = Math.max(0, Math.floor(seconds));
+ const h = Math.floor(total / 3600);
+ const m = Math.floor((total % 3600) / 60);
+ const s = total % 60;
+ const pad = (n) => n < 10 ? '0' + n : '' + n;
+ return h > 0 ? `${h}:${pad(m)}:${pad(s)}` : `${pad(m)}:${pad(s)}`;
+ };
+
const processedTranscription = computed(() => {
if (!selectedRecording.value?.transcription) {
return { hasDialogue: false, content: '', speakers: [], simpleSegments: [], bubbleRows: [], isError: false };
@@ -2254,6 +2270,8 @@ document.addEventListener('DOMContentLoaded', async () => {
connectorSupportsSpeakerCount.value = appElement.dataset.connectorSupportsSpeakerCount === 'True';
connectorSupportsHotwords.value = appElement.dataset.connectorSupportsHotwords === 'True';
connectorSupportsInitialPrompt.value = appElement.dataset.connectorSupportsInitialPrompt === 'True';
+ showTimestampsSimpleView.value = appElement.dataset.showTimestampsSimpleView === 'True';
+ editorAutosave.value = appElement.dataset.editorAutosave === 'True';
currentUserName.value = appElement.dataset.currentUserName || '';
}
diff --git a/templates/components/detail/desktop-transcription-panel.html b/templates/components/detail/desktop-transcription-panel.html
index 8f8c6812..66b9e9b5 100644
--- a/templates/components/detail/desktop-transcription-panel.html
+++ b/templates/components/detail/desktop-transcription-panel.html
@@ -209,9 +209,14 @@
@click="seekAudioFromEvent"
:data-start-time="segment.startTime"
:data-segment-index="index">
- <div v-if="segment.showSpeaker"
- :class="['speaker-tablet', segment.color]">
- ${segment.speaker}
+ <div v-if="segment.showSpeaker" class="speaker-segment-header">
+ <div :class="['speaker-tablet', segment.color]">
+ ${segment.speaker}
+ </div>
+ <span v-if="showTimestampsSimpleView"
+ class="speaker-segment-timestamp">
+ ${ formatTimestamp(segment.startTime) }
+ </span>
</div>
<div class="speaker-text">
${segment.sentence}
@@ -226,7 +231,10 @@
@click="seekAudioFromEvent"
:data-start-time="segment.startTime"
:data-segment-index="index">
- ${segment.sentence}
+ <span v-if="showTimestampsSimpleView"
+ class="speaker-segment-timestamp speaker-segment-timestamp--inline">
+ ${ formatTimestamp(segment.startTime) }
+ </span>${segment.sentence}
</div>
</div>
<div v-else class="whitespace-pre-wrap">
diff --git a/templates/components/detail/mobile-transcript-panel.html b/templates/components/detail/mobile-transcript-panel.html
index 4e7214c6..4074189c 100644
--- a/templates/components/detail/mobile-transcript-panel.html
+++ b/templates/components/detail/mobile-transcript-panel.html
@@ -105,13 +105,16 @@
<div v-if="!processedTranscription.hasDialogue || transcriptionViewMode === 'simple'" class="transcription-simple-view">
<div v-if="processedTranscription.hasDialogue">
<div v-for="(segment, index) in processedTranscription.simpleSegments" :key="`seg-${index}-${segment.startTime}`" :class="['speaker-segment', { 'active-playing-segment': currentPlayingSegmentIndex === index }]" @click="seekAudioFromEvent" :data-start-time="segment.startTime" :data-segment-index="index">
- <div v-if="segment.showSpeaker" :class="['speaker-tablet', segment.color]">${segment.speaker}</div>
+ <div v-if="segment.showSpeaker" class="speaker-segment-header">
+ <div :class="['speaker-tablet', segment.color]">${segment.speaker}</div>
+ <span v-if="showTimestampsSimpleView" class="speaker-segment-timestamp">${ formatTimestamp(segment.startTime) }</span>
+ </div>
<div class="speaker-text">${segment.sentence}</div>
</div>
</div>
<div v-else>
<div v-if="processedTranscription.simpleSegments && processedTranscription.simpleSegments.length > 0">
- <div v-for="(segment, index) in processedTranscription.simpleSegments" :key="`seg-${index}-${segment.startTime}`" :class="['transcript-segment cursor-pointer hover:bg-[var(--bg-accent-hover)] p-2 rounded transition-colors', { 'active-playing-segment': currentPlayingSegmentIndex === index }]" @click="seekAudioFromEvent" :data-start-time="segment.startTime" :data-segment-index="index">${segment.sentence}</div>
+ <div v-for="(segment, index) in processedTranscription.simpleSegments" :key="`seg-${index}-${segment.startTime}`" :class="['transcript-segment cursor-pointer hover:bg-[var(--bg-accent-hover)] p-2 rounded transition-colors', { 'active-playing-segment': currentPlayingSegmentIndex === index }]" @click="seekAudioFromEvent" :data-start-time="segment.startTime" :data-segment-index="index"><span v-if="showTimestampsSimpleView" class="speaker-segment-timestamp speaker-segment-timestamp--inline">${ formatTimestamp(segment.startTime) }</span>${segment.sentence}</div>
</div>
<div v-else class="whitespace-pre-wrap">${processedTranscription.content}</div>
</div>
diff --git a/templates/index.html b/templates/index.html
index c48adf02..921b0374 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -54,6 +54,8 @@
data-enable-internal-sharing="{{ enable_internal_sharing }}"
data-current-user-name="{{ (current_user.name or current_user.username) if current_user.is_authenticated else '' }}"
data-user-language="{{ user_language }}"
+ data-show-timestamps-simple-view="{{ 'True' if (current_user.is_authenticated and current_user.show_timestamps_simple_view) else 'False' }}"
+ data-editor-autosave="{{ 'True' if (current_user.is_authenticated and current_user.editor_autosave) else 'False' }}"
class="h-full flex flex-col opacity-0 transition-opacity duration-500">
<!-- Header -->