Skip to content

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

Python

better UI for speaker labeling

Murtaza Nasir4a746195d4a2
diff --git a/static/css/styles.css b/static/css/styles.css
index 9b30d782..ce8b946f 100644
--- a/static/css/styles.css
+++ b/static/css/styles.css
@@ -697,3 +697,20 @@ body {
.blink {
animation: blink-animation 1.5s infinite;
}
+
+/* Speaker tag styling in the modal */
+.speaker-tag {
+ font-weight: 600; /* Make speaker tags bold */
+ color: var(--text-accent);
+ padding: 2px 4px;
+ border-radius: 4px;
+ transition: all 0.2s ease-in-out;
+}
+
+.speaker-highlight {
+ background-color: var(--bg-accent);
+ color: var(--text-accent);
+ padding: 3px 6px;
+ border-radius: 6px;
+ box-shadow: 0 0 10px var(--bg-accent-hover);
+}
diff --git a/static/js/app.js b/static/js/app.js
index 556866f9..82f17f99 100644
--- a/static/js/app.js
+++ b/static/js/app.js
@@ -150,14 +150,19 @@ document.addEventListener('DOMContentLoaded', () => {
const highlightedTranscript = computed(() => {
if (!selectedRecording.value?.transcription) return '';
let html = selectedRecording.value.transcription;
- // Escape HTML to prevent injection
+ // Escape HTML to prevent injection, but keep it minimal
html = html.replace(/</g, '<').replace(/>/g, '>');
+
+ // 1. Replace newlines with <br> tags for proper line breaks in HTML
+ html = html.replace(/\n/g, '<br>');
- // Wrap each speaker tag in a span
+ // 2. Wrap each speaker tag in a span for styling and interaction
html = html.replace(/\[(SPEAKER_\d+)\]/g, (match, speakerId) => {
const isHighlighted = speakerId === highlightedSpeaker.value;
- return `<span class="speaker-tag ${isHighlighted ? 'highlighted' : ''}" data-speaker-id="${speakerId}">${match}</span>`;
+ // Use a more specific and stylish class structure
+ return `<span class="speaker-tag ${isHighlighted ? 'speaker-highlight' : ''}" data-speaker-id="${speakerId}">${match}</span>`;
});
+
return html;
});