- Implement DiarizeService with pyannote.audio speaker detection - Build PipelineService combining transcribe → diarize → merge with overlap-based speaker assignment per segment - Add pipeline.start and diarize.start IPC handlers - Add run_pipeline Tauri command for full pipeline execution - Wire frontend to use pipeline: speakers auto-created with colors, segments assigned to detected speakers - Build SpeakerManager with rename support (double-click or edit button) - Add speaker color coding throughout transcript display - Add pyannote.audio dependency - Tests: 24 Python (including merge logic), 6 Rust, 0 Svelte errors Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
143 lines
3.4 KiB
Svelte
143 lines
3.4 KiB
Svelte
<script lang="ts">
|
|
import { speakers } from '$lib/stores/transcript';
|
|
import type { Speaker } from '$lib/types/transcript';
|
|
|
|
let editingSpeakerId = $state<string | null>(null);
|
|
let editName = $state('');
|
|
|
|
function startRename(speaker: Speaker) {
|
|
editingSpeakerId = speaker.id;
|
|
editName = speaker.display_name || speaker.label;
|
|
}
|
|
|
|
function finishRename(speakerId: string) {
|
|
const trimmed = editName.trim();
|
|
if (trimmed) {
|
|
speakers.update(list => list.map(s => {
|
|
if (s.id !== speakerId) return s;
|
|
return { ...s, display_name: trimmed };
|
|
}));
|
|
}
|
|
editingSpeakerId = null;
|
|
}
|
|
|
|
function handleKeydown(e: KeyboardEvent, speakerId: string) {
|
|
if (e.key === 'Enter') {
|
|
e.preventDefault();
|
|
finishRename(speakerId);
|
|
} else if (e.key === 'Escape') {
|
|
editingSpeakerId = null;
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<div class="speaker-manager">
|
|
<h3>Speakers</h3>
|
|
{#if $speakers.length === 0}
|
|
<p class="empty-hint">No speakers detected yet</p>
|
|
{:else}
|
|
<ul class="speaker-list">
|
|
{#each $speakers as speaker (speaker.id)}
|
|
<li class="speaker-item">
|
|
<span class="speaker-color" style="background: {speaker.color}"></span>
|
|
{#if editingSpeakerId === speaker.id}
|
|
<input
|
|
class="rename-input"
|
|
type="text"
|
|
bind:value={editName}
|
|
onblur={() => finishRename(speaker.id)}
|
|
onkeydown={(e) => handleKeydown(e, speaker.id)}
|
|
/>
|
|
{:else}
|
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
<span class="speaker-name" ondblclick={() => startRename(speaker)}>
|
|
{speaker.display_name || speaker.label}
|
|
</span>
|
|
<button class="rename-btn" onclick={() => startRename(speaker)} title="Rename speaker">
|
|
✏
|
|
</button>
|
|
{/if}
|
|
</li>
|
|
{/each}
|
|
</ul>
|
|
<p class="speaker-hint">Double-click a name to rename</p>
|
|
{/if}
|
|
</div>
|
|
|
|
<style>
|
|
.speaker-manager {
|
|
padding: 1rem;
|
|
background: #16213e;
|
|
border-radius: 8px;
|
|
color: #e0e0e0;
|
|
}
|
|
h3 {
|
|
margin: 0 0 0.5rem;
|
|
font-size: 0.95rem;
|
|
}
|
|
.empty-hint {
|
|
color: #666;
|
|
font-size: 0.875rem;
|
|
}
|
|
.speaker-list {
|
|
list-style: none;
|
|
padding: 0;
|
|
margin: 0;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 0.5rem;
|
|
}
|
|
.speaker-item {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 0.5rem;
|
|
padding: 0.35rem 0.5rem;
|
|
background: rgba(255,255,255,0.03);
|
|
border-radius: 4px;
|
|
}
|
|
.speaker-color {
|
|
width: 12px;
|
|
height: 12px;
|
|
border-radius: 50%;
|
|
flex-shrink: 0;
|
|
}
|
|
.speaker-name {
|
|
flex: 1;
|
|
cursor: pointer;
|
|
font-size: 0.875rem;
|
|
}
|
|
.rename-btn {
|
|
background: none;
|
|
border: none;
|
|
color: #666;
|
|
cursor: pointer;
|
|
font-size: 0.75rem;
|
|
padding: 0.15rem 0.3rem;
|
|
border-radius: 3px;
|
|
}
|
|
.rename-btn:hover {
|
|
background: rgba(255,255,255,0.1);
|
|
color: #e0e0e0;
|
|
}
|
|
.rename-input {
|
|
flex: 1;
|
|
background: #1a1a2e;
|
|
color: #e0e0e0;
|
|
border: 1px solid #e94560;
|
|
border-radius: 3px;
|
|
padding: 0.2rem 0.4rem;
|
|
font-size: 0.875rem;
|
|
font-family: inherit;
|
|
}
|
|
.rename-input:focus {
|
|
outline: none;
|
|
border-color: #ff6b81;
|
|
}
|
|
.speaker-hint {
|
|
color: #555;
|
|
font-size: 0.7rem;
|
|
margin-top: 0.5rem;
|
|
margin-bottom: 0;
|
|
}
|
|
</style>
|