Skip to content

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

Python

Add auto speaker labelling and per-user auto-summarization settings

Murtaza Nasir22b231ae0fbc
diff --git a/src/api/auth.py b/src/api/auth.py
index 1d9523f0..0c78e8c2 100644
--- a/src/api/auth.py
+++ b/src/api/auth.py
@@ -624,6 +624,7 @@ def account():
USE_NEW_TRANSCRIPTION_ARCHITECTURE = os.environ.get('USE_NEW_TRANSCRIPTION_ARCHITECTURE', 'true').lower() == 'true'
ENABLE_AUTO_DELETION = os.environ.get('ENABLE_AUTO_DELETION', 'false').lower() == 'true'
ENABLE_INTERNAL_SHARING = os.environ.get('ENABLE_INTERNAL_SHARING', 'false').lower() == 'true'
+ ASR_RETURN_SPEAKER_EMBEDDINGS = os.environ.get('ASR_RETURN_SPEAKER_EMBEDDINGS', 'false').lower() == 'true'
# Get connector diarization support (new architecture)
connector_supports_diarization = USE_ASR_ENDPOINT # Default to USE_ASR_ENDPOINT for backwards compat
@@ -662,6 +663,10 @@ def account():
password_login_disabled = sso_enabled and sso_config.get('disable_password_login', False)
+ # Check if admin has globally disabled auto-summarization
+ admin_setting = SystemSetting.get_setting('disable_auto_summarization', False)
+ admin_disabled_auto_summarization = admin_setting if isinstance(admin_setting, bool) else str(admin_setting).lower() == 'true'
+
return render_template('account.html',
title='Account',
default_summary_prompt_text=default_summary_prompt_text,
@@ -678,7 +683,61 @@ def account():
sso_linked=sso_linked,
sso_subject=current_user.sso_subject,
has_password=bool(current_user.password),
- password_login_disabled=password_login_disabled)
+ password_login_disabled=password_login_disabled,
+ speaker_embeddings_enabled=ASR_RETURN_SPEAKER_EMBEDDINGS,
+ auto_speaker_labelling=current_user.auto_speaker_labelling,
+ auto_speaker_labelling_threshold=current_user.auto_speaker_labelling_threshold or 'medium',
+ admin_disabled_auto_summarization=admin_disabled_auto_summarization,
+ auto_summarization=current_user.auto_summarization if current_user.auto_summarization is not None else True)
+
+
+@auth_bp.route('/api/user/auto-speaker-labelling', methods=['POST'])
+@login_required
+def update_auto_speaker_labelling():
+ """Update user's auto speaker labelling settings."""
+ data = request.get_json()
+
+ if data is None:
+ return jsonify({'success': False, 'error': 'Invalid JSON'}), 400
+
+ # Update enabled state
+ if 'enabled' in data:
+ current_user.auto_speaker_labelling = bool(data['enabled'])
+
+ # Update threshold (validate value)
+ if 'threshold' in data:
+ threshold = data['threshold']
+ if threshold in ('low', 'medium', 'high'):
+ current_user.auto_speaker_labelling_threshold = threshold
+ else:
+ return jsonify({'success': False, 'error': 'Invalid threshold value'}), 400
+
+ db.session.commit()
+
+ return jsonify({
+ 'success': True,
+ 'auto_speaker_labelling': current_user.auto_speaker_labelling,
+ 'auto_speaker_labelling_threshold': current_user.auto_speaker_labelling_threshold
+ })
+
+
+@auth_bp.route('/api/user/auto-summarization', methods=['POST'])
+@login_required
+def update_auto_summarization():
+ """Update user's auto summarization setting."""
+ data = request.get_json()
+
+ if data is None:
+ return jsonify({'success': False, 'error': 'Invalid JSON'}), 400
+
+ if 'enabled' in data:
+ current_user.auto_summarization = bool(data['enabled'])
+ db.session.commit()
+
+ return jsonify({
+ 'success': True,
+ 'auto_summarization': current_user.auto_summarization
+ })
@auth_bp.route('/change_password', methods=['POST'])
diff --git a/src/init_db.py b/src/init_db.py
index 2f454971..4b119efb 100644
--- a/src/init_db.py
+++ b/src/init_db.py
@@ -264,6 +264,16 @@ def initialize_database(app):
if add_column_if_not_exists(engine, 'user', 'password_reset_sent_at', 'DATETIME'):
app.logger.info("Added password_reset_sent_at column to user table")
+ # Auto speaker labelling settings
+ if add_column_if_not_exists(engine, 'user', 'auto_speaker_labelling', 'BOOLEAN DEFAULT 0'):
+ app.logger.info("Added auto_speaker_labelling column to user table")
+ if add_column_if_not_exists(engine, 'user', 'auto_speaker_labelling_threshold', 'VARCHAR(10) DEFAULT "medium"'):
+ app.logger.info("Added auto_speaker_labelling_threshold column to user table")
+
+ # Auto summarization setting (per-user, default enabled)
+ if add_column_if_not_exists(engine, 'user', 'auto_summarization', 'BOOLEAN DEFAULT 1'):
+ app.logger.info("Added auto_summarization column to user table")
+
# Create indexes for token lookups (for faster token verification)
try:
inspector = inspect(engine)
diff --git a/src/models/user.py b/src/models/user.py
index 1e456ce2..9b1f95e8 100644
--- a/src/models/user.py
+++ b/src/models/user.py
@@ -51,6 +51,13 @@ class User(db.Model, UserMixin):
password_reset_token = db.Column(db.String(200), nullable=True, index=True)
password_reset_sent_at = db.Column(db.DateTime, nullable=True)
+ # Auto speaker labelling settings
+ auto_speaker_labelling = db.Column(db.Boolean, default=False) # Enable auto-labelling when voice confidence exceeds threshold
+ auto_speaker_labelling_threshold = db.Column(db.String(10), nullable=True, default='medium') # 'low', 'medium', 'high'
+
+ # Auto summarization setting (user can disable if admin hasn't globally disabled)
+ auto_summarization = db.Column(db.Boolean, default=True)
+
def __repr__(self):
return f"User('{self.username}', '{self.email}')"
diff --git a/src/services/speaker_embedding_matcher.py b/src/services/speaker_embedding_matcher.py
index 74626486..fc99150c 100644
--- a/src/services/speaker_embedding_matcher.py
+++ b/src/services/speaker_embedding_matcher.py
@@ -12,6 +12,7 @@ It provides functions to:
Uses 256-dimensional embeddings from WhisperX diarization.
"""
+import json
import numpy as np
from datetime import datetime
from sklearn.metrics.pairwise import cosine_similarity
@@ -251,3 +252,199 @@ def _get_confidence_level(score):
return 'medium'
else:
return 'high'
+
+
+# Threshold mapping for auto-labelling
+AUTO_LABEL_THRESHOLDS = {
+ 'low': 0.3, # Aggressive, may have more false positives
+ 'medium': 0.6, # Default, balanced approach
+ 'high': 0.8 # Only auto-label well-established speakers
+}
+
+# Base similarity threshold for finding matches (70%)
+BASE_SIMILARITY_THRESHOLD = 0.70
+
+# Ambiguity threshold: if top 2 matches are within 5% similarity, skip
+AMBIGUITY_MARGIN = 0.05
+
+
+def apply_auto_speaker_labels(recording, user):
+ """
+ Automatically label speakers in a recording based on voice profile matching.
+
+ This function matches speaker embeddings from the recording against the user's
+ saved speaker profiles and returns a mapping of generic labels to speaker names.
+
+ Args:
+ recording: Recording model instance with speaker_embeddings
+ user: User model instance with auto_speaker_labelling settings
+
+ Returns:
+ dict: Mapping of {SPEAKER_XX: speaker_name} for matched speakers,
+ or empty dict if auto-labelling is disabled or no matches found
+ """
+ # Check if user has auto-labelling enabled
+ if not user.auto_speaker_labelling:
+ return {}
+
+ # Check if recording has speaker embeddings
+ if not recording.speaker_embeddings:
+ return {}
+
+ # Get the user's threshold setting
+ threshold_setting = user.auto_speaker_labelling_threshold or 'medium'
+ confidence_threshold = AUTO_LABEL_THRESHOLDS.get(threshold_setting, AUTO_LABEL_THRESHOLDS['medium'])
+
+ speaker_map = {}
+ embeddings = recording.speaker_embeddings
+
+ for speaker_label, embedding_data in embeddings.items():
+ # embedding_data should be a list of floats (256 dimensions)
+ if not embedding_data or not isinstance(embedding_data, list):
+ continue
+
+ # Find matching speakers with base similarity threshold
+ matches = find_matching_speakers(
+ target_embedding=embedding_data,
+ user_id=user.id,
+ threshold=BASE_SIMILARITY_THRESHOLD
+ )
+
+ if not matches:
+ continue
+
+ # Check if the best match exceeds the user's confidence threshold
+ best_match = matches[0]
+ best_similarity = best_match['similarity'] / 100.0 # Convert from percentage
+
+ if best_similarity < confidence_threshold:
+ continue
+
+ # Check for ambiguity: if top 2 matches are within 5% similarity, skip
+ if len(matches) >= 2:
+ second_similarity = matches[1]['similarity'] / 100.0
+ if (best_similarity - second_similarity) <= AMBIGUITY_MARGIN:
+ # Ambiguous - top 2 matches too close
+ continue
+
+ # We have a clear winner - add to speaker map
+ speaker_map[speaker_label] = best_match['name']
+
+ return speaker_map
+
+
+def apply_speaker_names_to_transcription(recording, speaker_map):
+ """
+ Apply speaker name mappings to a recording's transcription.
+
+ This function updates the transcription JSON by replacing generic speaker
+ labels (SPEAKER_00, SPEAKER_01, etc.) with actual speaker names, and
+ updates the recording's participants list.
+
+ Args:
+ recording: Recording model instance with transcription
+ speaker_map: Dict mapping {SPEAKER_XX: speaker_name}
+
+ Returns:
+ bool: True if changes were made, False otherwise
+ """
+ import logging
+ logger = logging.getLogger(__name__)
+
+ if not speaker_map or not recording.transcription:
+ logger.warning(f"Auto-label: No speaker_map or transcription (map={bool(speaker_map)}, trans={bool(recording.transcription)})")
+ return False
+
+ try:
+ # Parse transcription as JSON array: [{speaker, sentence, start_time, end_time}, ...]
+ segments = json.loads(recording.transcription)
+ except (json.JSONDecodeError, TypeError) as e:
+ logger.warning(f"Auto-label: Failed to parse transcription as JSON: {e}")
+ return False
+
+ if not isinstance(segments, list) or not segments:
+ logger.warning(f"Auto-label: Transcription not in expected array format")
+ return False
+
+ # Track which speakers were renamed
+ renamed_speakers = set()
+
+ # Update speaker labels in segments
+ for segment in segments:
+ if 'speaker' in segment and segment['speaker'] in speaker_map:
+ segment['speaker'] = speaker_map[segment['speaker']]
+ renamed_speakers.add(segment['speaker'])
+
+ if not renamed_speakers:
+ logger.warning(f"Auto-label: No speakers matched in segments")
+ return False
+
+ logger.info(f"Auto-label: Applied names to {len(renamed_speakers)} speakers: {renamed_speakers}")
+
+ # Update participants field
+ all_speakers = set(s.get('speaker') for s in segments if 'speaker' in s)
+ if all_speakers:
+ recording.participants = ', '.join(sorted(all_speakers))
+
+ # Save updated transcription
+ recording.transcription = json.dumps(segments)
+ db.session.commit()
+
+ return True
+
+
+def update_speaker_profiles_from_recording(recording, speaker_map, user):
+ """
+ Update speaker voice profiles with new embeddings from a recording.
+
+ For each successfully matched speaker, this function updates their
+ average embedding and increments their usage count.
+
+ Args:
+ recording: Recording model instance with speaker_embeddings
+ speaker_map: Dict mapping {SPEAKER_XX: speaker_name} that was applied
+ user: User model instance
+
+ Returns:
+ int: Number of speaker profiles updated
+ """
+ if not speaker_map or not recording.speaker_embeddings:
+ return 0
+
+ updated_count = 0
+ embeddings = recording.speaker_embeddings
+
+ for speaker_label, speaker_name in speaker_map.items():
+ if speaker_label not in embeddings:
+ continue
+
+ embedding_data = embeddings[speaker_label]
+ if not embedding_data or not isinstance(embedding_data, list):
+ continue
+
+ # Find the speaker profile
+ speaker = Speaker.query.filter_by(
+ user_id=user.id,
+ name=speaker_name
+ ).first()
+
+ if not speaker:
+ continue
+
+ try:
+ # Update the speaker's embedding with the new sample
+ update_speaker_embedding(speaker, embedding_data, recording.id)
+
+ # Update usage tracking
+ speaker.use_count = (speaker.use_count or 0) + 1
+ speaker.last_used = datetime.utcnow()
+
+ updated_count += 1
+ except Exception:
+ # Skip if embedding update fails
+ continue
+
+ if updated_count > 0:
+ db.session.commit()
+
+ return updated_count
diff --git a/src/tasks/processing.py b/src/tasks/processing.py
index fd3c030c..64268492 100644
--- a/src/tasks/processing.py
+++ b/src/tasks/processing.py
@@ -1637,15 +1637,50 @@ def transcribe_with_connector(app_context, recording_id, filepath, original_file
# Don't fail transcription if usage tracking fails
current_app.logger.warning(f"Failed to record transcription usage: {usage_err}")
- # Check if auto-summarization is disabled
- disable_auto_summarization = SystemSetting.get_setting('disable_auto_summarization', False)
- will_auto_summarize = not disable_auto_summarization
+ # Apply auto speaker labelling if enabled and embeddings available
+ if recording.speaker_embeddings:
+ try:
+ from src.services.speaker_embedding_matcher import (
+ apply_auto_speaker_labels,
+ apply_speaker_names_to_transcription,
+ update_speaker_profiles_from_recording
+ )
+
+ user = User.query.get(recording.user_id)
+ if user and user.auto_speaker_labelling:
+ current_app.logger.info(f"Applying auto speaker labelling for recording {recording.id}")
+ speaker_map = apply_auto_speaker_labels(recording, user)
+
+ if speaker_map:
+ current_app.logger.info(f"Auto-matched speakers: {speaker_map}")
+ # Apply names to transcription
+ if apply_speaker_names_to_transcription(recording, speaker_map):
+ current_app.logger.info(f"Applied speaker names to transcription")
+ # Update speaker profiles with new embeddings
+ updated_count = update_speaker_profiles_from_recording(recording, speaker_map, user)
+ if updated_count > 0:
+ current_app.logger.info(f"Updated {updated_count} speaker profiles with new embeddings")
+ else:
+ current_app.logger.warning(f"Failed to apply speaker names to transcription for recording {recording.id}")
+ else:
+ current_app.logger.info(f"No speakers matched for auto-labelling")
+ except Exception as auto_label_err:
+ # Don't fail transcription if auto-labelling fails
+ current_app.logger.warning(f"Failed to apply auto speaker labelling: {auto_label_err}")
+
+ # Check if auto-summarization is disabled (admin setting or user preference)
+ admin_setting = SystemSetting.get_setting('disable_auto_summarization', False)
+ admin_disabled = admin_setting if isinstance(admin_setting, bool) else str(admin_setting).lower() == 'true'
+ user = User.query.get(recording.user_id)
+ user_disabled = user and user.auto_summarization is False
+ will_auto_summarize = not admin_disabled and not user_disabled
# Generate title immediately
generate_title_task(app_context, recording_id, will_auto_summarize=will_auto_summarize)
- if disable_auto_summarization:
- current_app.logger.info(f"Auto-summarization disabled, skipping summary for recording {recording_id}")
+ if not will_auto_summarize:
+ reason = "admin setting" if admin_disabled else "user preference"
+ current_app.logger.info(f"Auto-summarization disabled ({reason}), skipping summary for recording {recording_id}")
recording = db.session.get(Recording, recording_id)
if recording:
recording.status = 'COMPLETED'
@@ -1971,6 +2006,32 @@ def transcribe_audio_asr(app_context, recording_id, filepath, original_filename,
# Commit the transcription data
db.session.commit()
+ # Apply auto speaker labelling if enabled and embeddings available
+ if recording.speaker_embeddings:
+ try:
+ from src.services.speaker_embedding_matcher import (
+ apply_auto_speaker_labels,
+ apply_speaker_names_to_transcription,
+ update_speaker_profiles_from_recording
+ )
+ user = User.query.get(recording.user_id)
+ if user and user.auto_speaker_labelling:
+ current_app.logger.info(f"Applying auto speaker labelling for recording {recording.id}")
+ speaker_map = apply_auto_speaker_labels(recording, user)
+ if speaker_map:
+ current_app.logger.info(f"Auto-matched speakers: {speaker_map}")
+ if apply_speaker_names_to_transcription(recording, speaker_map):
+ current_app.logger.info(f"Applied speaker names to transcription")
+ updated_count = update_speaker_profiles_from_recording(recording, speaker_map, user)
+ if updated_count > 0:
+ current_app.logger.info(f"Updated {updated_count} speaker profiles with new embeddings")
+ else:
+ current_app.logger.warning(f"Failed to apply speaker names to transcription for recording {recording.id}")
+ else:
+ current_app.logger.info(f"No speakers matched for auto-labelling")
+ except Exception as auto_label_err:
+ current_app.logger.warning(f"Failed to apply auto speaker labelling: {auto_label_err}")
+
# Calculate and save transcription duration
transcription_end_time = time.time()
recording.transcription_duration_seconds = int(transcription_end_time - transcription_start_time)
@@ -1994,15 +2055,19 @@ def transcribe_audio_asr(app_context, recording_id, filepath, original_filename,
except Exception as usage_err:
current_app.logger.warning(f"Failed to record ASR transcription usage: {usage_err}")
- # Check if auto-summarization is disabled
- disable_auto_summarization = SystemSetting.get_setting('disable_auto_summarization', False)
- will_auto_summarize = not disable_auto_summarization
+ # Check if auto-summarization is disabled (admin setting or user preference)
+ admin_setting = SystemSetting.get_setting('disable_auto_summarization', False)
+ admin_disabled = admin_setting if isinstance(admin_setting, bool) else str(admin_setting).lower() == 'true'
+ user = User.query.get(recording.user_id)
+ user_disabled = user and user.auto_summarization is False
+ will_auto_summarize = not admin_disabled and not user_disabled
# Generate title immediately (pass flag so it knows whether to set COMPLETED)
generate_title_task(app_context, recording_id, will_auto_summarize=will_auto_summarize)
- if disable_auto_summarization:
- current_app.logger.info(f"Auto-summarization disabled, skipping summary for recording {recording_id}")
+ if not will_auto_summarize:
+ reason = "admin setting" if admin_disabled else "user preference"
+ current_app.logger.info(f"Auto-summarization disabled ({reason}), skipping summary for recording {recording_id}")
recording = db.session.get(Recording, recording_id)
if recording:
recording.status = 'COMPLETED'
@@ -2194,15 +2259,19 @@ def transcribe_audio_task(app_context, recording_id, filepath, filename_for_asr,
except Exception as usage_err:
current_app.logger.warning(f"Failed to record Whisper transcription usage: {usage_err}")
- # Check if auto-summarization is disabled
- disable_auto_summarization = SystemSetting.get_setting('disable_auto_summarization', False)
- will_auto_summarize = not disable_auto_summarization
+ # Check if auto-summarization is disabled (admin setting or user preference)
+ admin_setting = SystemSetting.get_setting('disable_auto_summarization', False)
+ admin_disabled = admin_setting if isinstance(admin_setting, bool) else str(admin_setting).lower() == 'true'
+ user = User.query.get(recording.user_id)
+ user_disabled = user and user.auto_summarization is False
+ will_auto_summarize = not admin_disabled and not user_disabled
# Generate title immediately (pass flag so it knows whether to set COMPLETED)
generate_title_task(app_context, recording_id, will_auto_summarize=will_auto_summarize)
- if disable_auto_summarization:
- current_app.logger.info(f"Auto-summarization disabled, skipping summary for recording {recording_id}")
+ if not will_auto_summarize:
+ reason = "admin setting" if admin_disabled else "user preference"
+ current_app.logger.info(f"Auto-summarization disabled ({reason}), skipping summary for recording {recording_id}")
recording.status = 'COMPLETED'
recording.completed_at = datetime.utcnow()
db.session.commit()
diff --git a/templates/account.html b/templates/account.html
index 35274058..75ae56ca 100644
--- a/templates/account.html
+++ b/templates/account.html
@@ -659,7 +659,23 @@
</div>
<div id="content-prompts" class="hidden tab-content pt-6">
- <h2 class="text-2xl font-semibold text-[var(--text-primary)] mb-6" data-i18n="accountTabs.promptOptions">Prompt Options</h2>
+ <!-- Header with Auto-summarization toggle -->
+ <div class="flex items-center justify-between mb-6">
+ <h2 class="text-2xl font-semibold text-[var(--text-primary)]" data-i18n="accountTabs.promptOptions">Prompt Options</h2>
+ {% if not admin_disabled_auto_summarization %}
+ <div class="flex items-center gap-3" title="Automatically generate summaries after transcription completes">
+ <span class="text-sm text-[var(--text-secondary)]">Auto-summarize</span>
+ <label class="relative inline-flex items-center cursor-pointer">
+ <input type="checkbox" id="autoSummarizationToggle" class="sr-only peer" {% if auto_summarization %}checked{% endif %}>
+ <div class="w-11 h-6 bg-[var(--bg-tertiary)] peer-focus:outline-none peer-focus:ring-2 peer-focus:ring-[var(--border-focus)] rounded-full peer peer-checked:after:translate-x-full rtl:peer-checked:after:-translate-x-full after:content-[''] after:absolute after:top-[2px] after:start-[2px] after:bg-[var(--text-muted)] after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-[var(--bg-accent)] peer-checked:after:bg-white"></div>
+ </label>
+ </div>
+ {% else %}
+ <div class="text-sm text-[var(--text-muted)] italic" title="Auto-summarization has been disabled by the administrator">
+ <i class="fas fa-lock mr-1"></i> Auto-summarization disabled by admin
+ </div>
+ {% endif %}
+ </div>
<form id="customPromptsForm" method="POST" action="{{ url_for('auth.account') }}" class="space-y-6">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
@@ -757,35 +773,52 @@
</div>
<div id="content-speakers" class="hidden tab-content pt-6 flex flex-col h-full">
- <!-- Header -->
- <div class="flex-shrink-0 mb-4">
- <h2 class="text-2xl font-semibold text-[var(--text-primary)] mb-2" data-i18n="accountTabs.speakersManagement">Speakers Management</h2>
- <p class="text-sm text-[var(--text-secondary)]" data-i18n="speakersManagement.description">Manage your saved speakers. These are automatically saved when you use speaker names in your recordings.</p>
+ <!-- Header with Auto-label toggle -->
+ <div class="flex-shrink-0 mb-4 flex items-center justify-between">
+ <div>
+ <h2 class="text-2xl font-semibold text-[var(--text-primary)] mb-1" data-i18n="accountTabs.speakersManagement">Speakers Management</h2>
+ <p class="text-sm text-[var(--text-secondary)] hidden sm:block" data-i18n="speakersManagement.description">Manage your saved speakers. These are automatically saved when you use speaker names in your recordings.</p>
+ </div>
+ {% if speaker_embeddings_enabled %}
+ <div class="flex items-center gap-2 sm:gap-3 ml-4 flex-shrink-0" title="Automatically label speakers in new recordings when voice profiles match">
+ <span class="text-sm text-[var(--text-secondary)] hidden sm:inline">Auto-label</span>
+ <label class="relative inline-flex items-center cursor-pointer">
+ <input type="checkbox" id="autoSpeakerLabellingToggle" class="sr-only peer" {% if auto_speaker_labelling %}checked{% endif %}>
+ <div class="w-11 h-6 bg-[var(--bg-tertiary)] peer-focus:outline-none peer-focus:ring-2 peer-focus:ring-[var(--border-focus)] rounded-full peer peer-checked:after:translate-x-full rtl:peer-checked:after:-translate-x-full after:content-[''] after:absolute after:top-[2px] after:start-[2px] after:bg-[var(--text-muted)] after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-[var(--bg-accent)] peer-checked:after:bg-white"></div>
+ </label>
+ <select id="autoSpeakerLabellingThreshold" class="text-sm bg-[var(--bg-secondary)] border border-[var(--border-secondary)] rounded-md px-2 py-1 text-[var(--text-primary)] focus:ring-2 focus:ring-blue-500 disabled:opacity-50 disabled:cursor-not-allowed" {% if not auto_speaker_labelling %}disabled{% endif %}>
+ <option value="high" {% if auto_speaker_labelling_threshold == 'high' %}selected{% endif %}>High</option>
+ <option value="medium" {% if auto_speaker_labelling_threshold == 'medium' %}selected{% endif %}>Medium</option>
+ <option value="low" {% if auto_speaker_labelling_threshold == 'low' %}selected{% endif %}>Low</option>
+ </select>
+ </div>
+ {% endif %}
</div>
<!-- Top toolbar with bulk actions -->
- <div class="flex-shrink-0 flex justify-between items-center py-3 px-4 bg-[var(--bg-tertiary)] rounded-lg border border-[var(--border-primary)] mb-3">
- <div class="flex items-center gap-4">
+ <div class="flex-shrink-0 flex flex-wrap justify-between items-center gap-2 py-2 sm:py-3 px-3 sm:px-4 bg-[var(--bg-tertiary)] rounded-lg border border-[var(--border-primary)] mb-3">
+ <div class="flex items-center gap-2 sm:gap-4">
<label class="flex items-center text-sm text-[var(--text-muted)] cursor-pointer hover:text-[var(--text-primary)] transition-colors">
- <input type="checkbox" id="selectAllSpeakersTop" class="select-all-checkbox mr-2 rounded border-gray-300 dark:border-gray-600 text-blue-600 focus:ring-blue-500">
- <span>Select All</span>
+ <input type="checkbox" id="selectAllSpeakersTop" class="select-all-checkbox mr-1.5 sm:mr-2 rounded border-gray-300 dark:border-gray-600 text-blue-600 focus:ring-blue-500">
+ <span class="hidden sm:inline">Select All</span>
+ <span class="sm:hidden">All</span>
</label>
<span class="text-sm text-[var(--text-muted)]">
- <span id="speakersTabCountTop" class="speakers-count">0</span> <span data-i18n="speakersManagement.totalSpeakers">speakers saved</span>
+ <span id="speakersTabCountTop" class="speakers-count">0</span> <span class="hidden sm:inline" data-i18n="speakersManagement.totalSpeakers">speakers saved</span>
</span>
</div>
- <div class="flex space-x-2">
- <button class="bulk-delete-btn px-3 py-1.5 text-sm bg-red-600 dark:bg-red-500 text-white rounded-md hover:bg-red-700 dark:hover:bg-red-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors" disabled>
- <i class="fas fa-trash mr-1"></i>
- <span>Delete</span>
+ <div class="flex space-x-1 sm:space-x-2">
+ <button class="bulk-delete-btn px-2 sm:px-3 py-1 sm:py-1.5 text-sm bg-red-600 dark:bg-red-500 text-white rounded-md hover:bg-red-700 dark:hover:bg-red-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors" disabled title="Delete">
+ <i class="fas fa-trash"></i>
+ <span class="hidden sm:inline ml-1">Delete</span>
</button>
- <button class="bulk-clear-btn px-3 py-1.5 text-sm bg-orange-600 dark:bg-orange-500 text-white rounded-md hover:bg-orange-700 dark:hover:bg-orange-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors" disabled>
- <i class="fas fa-waveform-lines mr-1"></i>
- <span>Clear Profiles</span>
+ <button class="bulk-clear-btn px-2 sm:px-3 py-1 sm:py-1.5 text-sm bg-orange-600 dark:bg-orange-500 text-white rounded-md hover:bg-orange-700 dark:hover:bg-orange-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors" disabled title="Clear Profiles">
+ <i class="fas fa-eraser"></i>
+ <span class="hidden sm:inline ml-1">Clear</span>
</button>
- <button class="bulk-merge-btn px-3 py-1.5 text-sm bg-[var(--bg-accent)] text-[var(--text-accent)] rounded-md hover:bg-[var(--bg-accent-hover)] disabled:opacity-50 disabled:cursor-not-allowed transition-colors" disabled>
- <i class="fas fa-object-group mr-1"></i>
- <span>Merge</span>
+ <button class="bulk-merge-btn px-2 sm:px-3 py-1 sm:py-1.5 text-sm bg-[var(--bg-accent)] text-[var(--text-accent)] rounded-md hover:bg-[var(--bg-accent-hover)] disabled:opacity-50 disabled:cursor-not-allowed transition-colors" disabled title="Merge">
+ <i class="fas fa-object-group"></i>
+ <span class="hidden sm:inline ml-1">Merge</span>
</button>
</div>
</div>
@@ -818,28 +851,29 @@
</div>
<!-- Bottom toolbar with bulk actions -->
- <div class="flex-shrink-0 flex justify-between items-center py-3 px-4 bg-[var(--bg-tertiary)] rounded-lg border border-[var(--border-primary)] mt-3">
- <div class="flex items-center gap-4">
+ <div class="flex-shrink-0 flex flex-wrap justify-between items-center gap-2 py-2 sm:py-3 px-3 sm:px-4 bg-[var(--bg-tertiary)] rounded-lg border border-[var(--border-primary)] mt-3">
+ <div class="flex items-center gap-2 sm:gap-4">
<label class="flex items-center text-sm text-[var(--text-muted)] cursor-pointer hover:text-[var(--text-primary)] transition-colors">
- <input type="checkbox" id="selectAllSpeakersBottom" class="select-all-checkbox mr-2 rounded border-gray-300 dark:border-gray-600 text-blue-600 focus:ring-blue-500">
- <span>Select All</span>
+ <input type="checkbox" id="selectAllSpeakersBottom" class="select-all-checkbox mr-1.5 sm:mr-2 rounded border-gray-300 dark:border-gray-600 text-blue-600 focus:ring-blue-500">
+ <span class="hidden sm:inline">Select All</span>
+ <span class="sm:hidden">All</span>
</label>
<span class="text-sm text-[var(--text-muted)]">
- <span id="speakersTabCountBottom" class="speakers-count">0</span> <span data-i18n="speakersManagement.totalSpeakers">speakers saved</span>
+ <span id="speakersTabCountBottom" class="speakers-count">0</span> <span class="hidden sm:inline" data-i18n="speakersManagement.totalSpeakers">speakers saved</span>
</span>
</div>
- <div class="flex space-x-2">
- <button class="bulk-delete-btn px-3 py-1.5 text-sm bg-red-600 dark:bg-red-500 text-white rounded-md hover:bg-red-700 dark:hover:bg-red-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors" disabled>
- <i class="fas fa-trash mr-1"></i>
- <span>Delete</span>
+ <div class="flex space-x-1 sm:space-x-2">
+ <button class="bulk-delete-btn px-2 sm:px-3 py-1 sm:py-1.5 text-sm bg-red-600 dark:bg-red-500 text-white rounded-md hover:bg-red-700 dark:hover:bg-red-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors" disabled title="Delete">
+ <i class="fas fa-trash"></i>
+ <span class="hidden sm:inline ml-1">Delete</span>
</button>
- <button class="bulk-clear-btn px-3 py-1.5 text-sm bg-orange-600 dark:bg-orange-500 text-white rounded-md hover:bg-orange-700 dark:hover:bg-orange-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors" disabled>
- <i class="fas fa-waveform-lines mr-1"></i>
- <span>Clear Profiles</span>
+ <button class="bulk-clear-btn px-2 sm:px-3 py-1 sm:py-1.5 text-sm bg-orange-600 dark:bg-orange-500 text-white rounded-md hover:bg-orange-700 dark:hover:bg-orange-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors" disabled title="Clear Profiles">
+ <i class="fas fa-eraser"></i>
+ <span class="hidden sm:inline ml-1">Clear</span>
</button>
- <button class="bulk-merge-btn px-3 py-1.5 text-sm bg-[var(--bg-accent)] text-[var(--text-accent)] rounded-md hover:bg-[var(--bg-accent-hover)] disabled:opacity-50 disabled:cursor-not-allowed transition-colors" disabled>
- <i class="fas fa-object-group mr-1"></i>
- <span>Merge</span>
+ <button class="bulk-merge-btn px-2 sm:px-3 py-1 sm:py-1.5 text-sm bg-[var(--bg-accent)] text-[var(--text-accent)] rounded-md hover:bg-[var(--bg-accent-hover)] disabled:opacity-50 disabled:cursor-not-allowed transition-colors" disabled title="Merge">
+ <i class="fas fa-object-group"></i>
+ <span class="hidden sm:inline ml-1">Merge</span>
</button>
</div>
</div>
@@ -1609,7 +1643,7 @@ curl "https://your-speakr-instance.com/api/recordings?token=YOUR_TOKEN_HERE"</co
<div class="bg-gradient-to-r from-orange-500 to-[var(--bg-secondary)] p-5 rounded-t-xl flex items-center">
<div class="flex items-center">
<div class="w-12 h-12 bg-gradient-to-br from-orange-500 to-amber-600 rounded-full flex items-center justify-center mr-4 shadow-lg">
- <i class="fas fa-waveform-lines text-white text-lg"></i>
+ <i class="fas fa-eraser text-white text-lg"></i>
</div>
<div>
<h3 class="text-xl font-bold text-[var(--text-primary)] mb-1">Clear Voice Profiles</h3>
@@ -1662,7 +1696,7 @@ curl "https://your-speakr-instance.com/api/recordings?token=YOUR_TOKEN_HERE"</co
Cancel
</button>
<button id="confirmClearVoiceProfilesBtn" class="px-5 py-2.5 bg-gradient-to-r from-orange-500 to-amber-600 text-white rounded-lg hover:from-orange-600 hover:to-amber-700 transition-all duration-200 flex items-center shadow-lg font-medium">
- <i class="fas fa-waveform-lines mr-2"></i>
+ <i class="fas fa-eraser mr-2"></i>
Clear Profiles
</button>
</div>
@@ -2026,6 +2060,79 @@ curl "https://your-speakr-instance.com/api/recordings?token=YOUR_TOKEN_HERE"</co
console.error('Error initializing i18n:', error);
}
+ // Setup auto speaker labelling toggle and dropdown
+ const autoLabelToggle = document.getElementById('autoSpeakerLabellingToggle');
+ const autoLabelThreshold = document.getElementById('autoSpeakerLabellingThreshold');
+
+ async function updateAutoSpeakerLabelling() {
+ const enabled = autoLabelToggle ? autoLabelToggle.checked : false;
+ const threshold = autoLabelThreshold ? autoLabelThreshold.value : 'medium';
+
+ // Enable/disable dropdown based on toggle
+ if (autoLabelThreshold) {
+ autoLabelThreshold.disabled = !enabled;
+ }
+
+ const csrfToken = document.querySelector('meta[name=csrf-token]')?.getAttribute('content');
+ try {
+ const response = await fetch('/api/user/auto-speaker-labelling', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ 'X-CSRFToken': csrfToken
+ },
+ body: JSON.stringify({
+ enabled: enabled,
+ threshold: threshold
+ })
+ });
+
+ if (!response.ok) {
+ console.error('Failed to update auto speaker labelling settings');
+ }
+ } catch (error) {
+ console.error('Error updating auto speaker labelling:', error);
+ }
+ }
+
+ if (autoLabelToggle) {
+ autoLabelToggle.addEventListener('change', updateAutoSpeakerLabelling);
+ }
+ if (autoLabelThreshold) {
+ autoLabelThreshold.addEventListener('change', updateAutoSpeakerLabelling);
+ }
+
+ // Setup auto summarization toggle
+ const autoSummarizationToggle = document.getElementById('autoSummarizationToggle');
+
+ async function updateAutoSummarization() {
+ if (!autoSummarizationToggle) return;
+
+ const csrfToken = document.querySelector('meta[name=csrf-token]')?.getAttribute('content');
+ try {
+ const response = await fetch('/api/user/auto-summarization', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ 'X-CSRFToken': csrfToken
+ },
+ body: JSON.stringify({
+ enabled: autoSummarizationToggle.checked
+ })
+ });
+
+ if (!response.ok) {
+ console.error('Failed to update auto summarization setting');
+ }
+ } catch (error) {
+ console.error('Error updating auto summarization:', error);
+ }
+ }
+
+ if (autoSummarizationToggle) {
+ autoSummarizationToggle.addEventListener('change', updateAutoSummarization);
+ }
+
// Setup merge modal event listeners
const closeMergeModalBtn = document.getElementById('closeMergeModal');
const cancelMergeBtn = document.getElementById('cancelMergeBtn');
@@ -2486,7 +2593,7 @@ curl "https://your-speakr-instance.com/api/recordings?token=YOUR_TOKEN_HERE"</co
${hasVoiceProfile ? `
<div class="flex items-center justify-between gap-2 mb-2 px-2 py-1 bg-[var(--bg-secondary)] rounded">
<div class="flex items-center gap-1.5 min-w-0">
- <i class="fas fa-waveform-lines text-blue-500 text-[10px] flex-shrink-0"></i>
+ <i class="fas fa-eraser text-blue-500 text-[10px] flex-shrink-0"></i>
<span class="text-[10px] text-[var(--text-muted)] truncate">${speaker.embedding_count} sample${speaker.embedding_count !== 1 ? 's' : ''}</span>
</div>
${confidenceBadge}