Skip to content

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

Python
13.7 KB
Raw Blame
<!-- Desktop Transcription Panel (Left Column) -->
<div id="leftMainColumn" class="flex flex-col overflow-hidden" :style="{width: leftColumnWidth + '%'}">
    <!-- Docked video, top-of-left-column slot (see _video-dock.html). -->
    {% with dock_pos = 'left-top' %}{% include 'components/detail/_video-dock.html' %}{% endwith %}
    <!-- Transcription header (design system v1).
         Matches the right-rail tab-bar pattern: 40px tab strip with the
         title on the left and contextual toggles + action icons on the
         right. View mode is a single Bubble *toggle* (Simple is the
         default; the toggle modifies that default), not a pair of tabs. -->
    <div class="tabs-bar px-4">
        <div class="tabs">
            <span class="tab is-active" style="cursor: default;">
                <i class="fas fa-file-text" style="font-size: 13px; opacity: 0.7;"></i>
                <span v-text="t('transcription.title')"></span>
            </span>
        </div>
        <div class="tabs-bar__actions">
            <!-- Follow Player toggle (icon-only; label in tooltip) -->
            <button v-if="processedTranscription.isJson && processedTranscription.hasDialogue"
                    @click="toggleFollowPlayerMode"
                    class="toggle"
                    :class="{ 'is-on': followPlayerMode }"
                    :title="followPlayerMode ? t('tooltips.followPlayerEnabled') : t('tooltips.followPlayerDisabled')">
                <i class="fas fa-arrows-alt-v" style="font-size: 11px;"></i>
            </button>

            <!-- View mode: ONE toggle. Off = Simple (default), On = Bubble -->
            <button v-if="processedTranscription.hasDialogue"
                    @click="toggleTranscriptionViewMode"
                    class="toggle"
                    :class="{ 'is-on': transcriptionViewMode === 'bubble' }"
                    :title="transcriptionViewMode === 'bubble' ? t('tooltips.switchToSimpleView') : t('tooltips.switchToBubbleView')">
                <i class="fas fa-comments" style="font-size: 11px;"></i>
                <span v-text="t('transcription.bubble')"></span>
            </button>

            <!-- Copy -->
            <button @click="copyTranscription"
                    class="btn btn--icon"
                    :title="t('tooltips.copyTranscript')">
                <i class="fas fa-copy"></i>
            </button>

            <!-- Download with dropdown -->
            <div v-if="selectedRecording && selectedRecording.transcription" class="relative">
                <button @click="showDownloadMenu = !showDownloadMenu"
                        data-download-toggle
                        class="btn btn--icon"
                        :title="t('tooltips.downloadTranscriptWithTemplate')">
                    <i class="fas fa-download"></i>
                </button>
                <div v-if="showDownloadMenu"
                     data-download-dropdown
                     class="absolute right-0 top-full mt-1 surface-raised z-50 overflow-hidden whitespace-nowrap"
                     style="min-width: 220px;">
                    <!-- Output format toggle (TXT / MD) — a persisted preference
                         applied to whichever download action is chosen below. -->
                    <div class="flex items-center justify-between gap-2 px-3 py-2 border-b border-[var(--border-primary)]">
                        <span class="text-xs text-[var(--text-muted)]" v-text="t('transcriptTemplates.format')"></span>
                        <div class="inline-flex rounded-md overflow-hidden border border-[var(--border-primary)]">
                            <button @click.stop="transcriptDownloadFormat = 'txt'"
                                    :class="['px-2.5 py-1 text-xs transition-colors', transcriptDownloadFormat === 'txt' ? 'bg-[var(--bg-button)] text-[var(--text-button)]' : 'text-[var(--text-secondary)] hover:bg-[var(--bg-tertiary)]']">TXT</button>
                            <button @click.stop="transcriptDownloadFormat = 'md'"
                                    :class="['px-2.5 py-1 text-xs transition-colors border-l border-[var(--border-primary)]', transcriptDownloadFormat === 'md' ? 'bg-[var(--bg-button)] text-[var(--text-button)]' : 'text-[var(--text-secondary)] hover:bg-[var(--bg-tertiary)]']">MD</button>
                        </div>
                    </div>
                    <button @click="downloadWithDefaultTemplate(); showDownloadMenu = false"
                            class="w-full text-left px-3 py-2 text-sm hover:bg-[var(--bg-tertiary)] transition-colors flex items-center gap-2">
                        <i class="fas fa-star text-[var(--text-accent)] text-[10px]"></i>
                        <span v-text="t('transcriptTemplates.downloadDefault')"></span>
                    </button>
                    <button @click="showTemplateSelector(); showDownloadMenu = false"
                            class="w-full text-left px-3 py-2 text-sm hover:bg-[var(--bg-tertiary)] transition-colors flex items-center gap-2 border-t border-[var(--border-primary)]">
                        <i class="fas fa-list text-[var(--text-muted)] text-[10px]"></i>
                        <span v-text="t('transcriptTemplates.chooseTemplate')"></span>
                    </button>
                </div>
            </div>

            <!-- Edit -->
            <button @click="openTranscriptionEditor"
                    v-if="selectedRecording && selectedRecording.transcription"
                    class="btn btn--icon"
                    :title="t('tooltips.editTranscript')">
                <i class="fas fa-pen"></i>
            </button>
        </div>
    </div>

    <!-- Transcription Content -->
    <div class="flex-1 overflow-y-auto p-4 relative">
        <!-- Floating Processing Indicator -->
        <div v-if="selectedRecording.status === 'PROCESSING'"
             :class="['processing-indicator-floating', processingIndicatorMinimized ? 'minimized' : '']">
            <template v-if="!processingIndicatorMinimized">
                <div class="processing-indicator-content">
                    <i class="fas fa-spinner fa-spin text-[var(--text-accent)]"></i>
                    <span class="text-sm text-[var(--text-secondary)]" v-text="t('help.processingTranscription')"></span>
                </div>
                <button @click="processingIndicatorMinimized = true"
                        class="processing-indicator-minimize"
                        :title="t('tooltips.minimize')">
                    <i class="fas fa-chevron-up"></i>
                </button>
            </template>
            <template v-else>
                <button @click="processingIndicatorMinimized = false"
                        class="processing-indicator-expand"
                        :title="t('help.processingTranscription')">
                    <i class="fas fa-spinner fa-spin"></i>
                </button>
            </template>
        </div>

        <!-- No transcription state (only show if not processing and no transcription) -->
        <div v-if="selectedRecording.status !== 'PROCESSING' && !selectedRecording.transcription" class="text-center py-8">
            <i class="fas fa-file-text text-3xl text-[var(--text-muted)] mb-3"></i>
            <p class="text-[var(--text-muted)]" v-text="t('transcription.noTranscription')"></p>
        </div>

        <!-- Error Display (when transcription is an error message) -->
        <div v-if="processedTranscription.isError" class="error-display-container">
            {% include 'components/detail/_transcription-error.html' %}
        </div>

        <!-- Speaker Legend (for dialogue transcriptions in bubble view only) -->
        <div v-if="!processedTranscription.isError && processedTranscription.hasDialogue && processedTranscription.speakers.length > 0 && transcriptionViewMode === 'bubble'"
             :class="['speaker-legend', legendExpanded ? 'expanded' : '']">
            <div class="speaker-legend-header" @click="legendExpanded = !legendExpanded">
                <div class="speaker-legend-title">
                    <i class="fas fa-users"></i>
                    <span v-text="t('help.speakers')"></span>
                    <span class="speaker-count-indicator">(${processedTranscription.speakers.length})</span>
                </div>
                <i class="fas fa-chevron-down speaker-legend-toggle"></i>
            </div>
            <div class="speaker-legend-content">
                <div v-for="(speaker, index) in processedTranscription.speakers"
                     :key="`${selectedRecording.id}-speaker-legend-${index}`"
                     :class="['speaker-legend-item', speaker.color]">
                    <span class="speaker-name">${speaker.name}</span>
                </div>
            </div>
        </div>

        <!-- Transcription Display (hide if it's an error) -->
        <div v-if="selectedRecording.transcription && !processedTranscription.isError">
            <!-- Simple View -->
            <div v-if="!processedTranscription.hasDialogue || transcriptionViewMode === 'simple'"
                 class="transcription-simple-view">
                <!-- Speaker runs (consecutive same-speaker segments
                     grouped into one container) so the sticky speaker
                     tablet at the top of each run sticks for the WHOLE
                     run, not just the first segment. -->
                <div v-if="processedTranscription.hasDialogue">
                    <div v-for="(run, runIndex) in processedTranscription.simpleSegmentRuns"
                         :key="`run-${runIndex}-${run.startTime}`"
                         class="speaker-run">
                        <div v-if="showTimestampsSimpleView"
                             :class="['speaker-tablet-group', run.color]">
                            <span class="speaker-tablet-time">${ formatTimestamp(run.startTime) }</span>
                            <span class="speaker-tablet-name">${run.speaker}</span>
                        </div>
                        <div v-else :class="['speaker-tablet', run.color]">
                            ${run.speaker}
                        </div>
                        <div v-for="(segment, segIndex) in run.segments"
                             :key="`seg-${segment.originalIndex}-${segment.startTime}`"
                             :class="['speaker-segment', { 'active-playing-segment': currentPlayingSegmentIndex === segment.originalIndex }]"
                             @click="seekAudioFromEvent"
                             @dblclick.stop="openAsrEditorAtSegment(segment.originalIndex)"
                             :title="t('tooltips.doubleClickToEditSegment')"
                             :data-start-time="segment.startTime"
                             :data-segment-index="segment.originalIndex">
                            <div class="speaker-text">
                                ${segment.sentence}
                            </div>
                        </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"
                             @dblclick.stop="openAsrEditorAtSegment(index)"
                             :title="t('tooltips.doubleClickToEditSegment')"
                             :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 bidi-auto">
                        ${processedTranscription.content}
                    </div>
                </div>
            </div>

            <!-- Bubble View -->
            <div v-else-if="transcriptionViewMode === 'bubble'"
                 class="transcription-with-speakers">
                <template v-for="(row, rowIndex) in processedTranscription.bubbleRows" :key="`${selectedRecording.id}-bubble-row-${rowIndex}`">
                    <div :class="['bubble-row', row.isMe ? 'speaker-me' : '']">
                        <div v-for="(bubble, bubbleIndex) in row.bubbles"
                             :key="`bubble-${rowIndex}-${bubbleIndex}-${bubble.startTime}`"
                             :class="['speaker-bubble', bubble.color, row.isMe ? 'speaker-me' : '', { 'active-playing-segment': currentPlayingSegmentIndex === getBubbleGlobalIndex(rowIndex, bubbleIndex) }]"
                             @click="seekAudioFromEvent"
                             :data-start-time="bubble.startTime"
                             :data-segment-index="getBubbleGlobalIndex(rowIndex, bubbleIndex)">
                            <div class="speaker-bubble-content">
                                ${bubble.sentence}
                            </div>
                        </div>
                    </div>
                </template>
            </div>
        </div>
    </div>

    <!-- Docked video, bottom-of-left-column slot (see _video-dock.html). -->
    {% with dock_pos = 'left-bottom' %}{% include 'components/detail/_video-dock.html' %}{% endwith %}
</div>