Speaker Clustering Methods
Choose and implement clustering algorithms for grouping speaker embeddings after VAD and embedding extraction. Compare Hierarchical clustering (auto-tunes speaker count), KMeans (fast, requires known count), and Agglomerative clustering (fixed clusters).
Install / Use
npx skills add benchflow-ai/skillsbench --skill speaker-clusteringInstalls into whichever agent you are using.
SKILL.md
Installable skill definition
Quality Score
Category
AI & Machine LearningSupported Platforms
Tags
Our assessment of Speaker Clustering Methods
Speaker Clustering Methods scores 92/100 on our quality scale, 232nd of 970 AI & Machine Learning skills we index (top 24%).
Its SKILL.md is 7.5 KB long, well organised into 28 sections with 7 code examples: a thorough specification that gives an agent plenty to work with.
With 1,813 GitHub stars, it is one of the more widely adopted skills in the catalogue.
Maintenance, license and trust
- The repository was last updated about 2 months ago, so Speaker Clustering Methods is actively maintained.
- It is released under the Apache-2.0 license, a permissive license that allows use, modification and commercial use with attribution.
- Its trust signals score 100/100, with no cautions. These come from repository metadata, not a code audit — read the skill file before letting an agent act on it.
Safety scan
No issues foundOur scan of the whole file found no instruction hijacking, hidden characters, credential access, data exfiltration or destructive commands.
Automated pattern scan on 2026-10-02. It catches known dangerous patterns, not every risk — read a skill before letting an agent act on it.
Speaker Clustering Methods compared with similar skills
All 4 of these similar skills score higher than Speaker Clustering Methods; compare them before choosing.
| Skill | Score | Stars | Updated | Format |
|---|---|---|---|---|
| Speaker Clustering Methods (this skill)by benchflow-ai | 92 | 1.8k | 2mo ago | SKILL.md |
| claude-memby thedotmack | 100 | 95.2k | today | CLAUDE.md |
| Understand-Anythingby Egonex-AI | 100 | 85.0k | today | CLAUDE.md |
| headroomby headroomlabs-ai | 100 | 74.3k | today | CLAUDE.md |
| CowAgentby zhayujie | 100 | 47.2k | today | CLAUDE.md |
Frequently asked questions
- How do I install Speaker Clustering Methods?
- Run
npx skills add benchflow-ai/skillsbench --skill "Speaker Clustering Methods". The install tabs above show the steps for each supported agent. - Which AI agents does Speaker Clustering Methods work with?
- It is written for Universal, as a SKILL.md file. Other agents that read the same format can often use it too.
- Is Speaker Clustering Methods safe to use?
- Our scan of the whole file found no instruction hijacking, hidden characters, credential access, data exfiltration or destructive commands. It is Apache-2.0-licensed and scores 100/100 on trust signals. Skills are instructions an agent will follow, so read the file before installing it and do not approve commands you do not understand.
- Is Speaker Clustering Methods still maintained?
- The repository was last updated about 2 months ago, so Speaker Clustering Methods is actively maintained.
Skill content
View source on GitHubname: Speaker Clustering Methods description: Choose and implement clustering algorithms for grouping speaker embeddings after VAD and embedding extraction. Compare Hierarchical clustering (auto-tunes speaker count), KMeans (fast, requires known count), and Agglomerative clustering (fixed clusters). Use Hierarchical clustering when speaker count is unknown, KMeans when count is known, and always normalize embeddings before clustering.
Speaker Clustering Methods
Overview
After extracting speaker embeddings from audio segments, you need to cluster them to identify unique speakers. Different clustering methods have different strengths.
When to Use
- After extracting speaker embeddings from VAD segments
- Need to group similar speakers together
- Determining number of speakers automatically or manually
Available Clustering Methods
1. Hierarchical Clustering (Recommended for Auto-tuning)
Best for: Automatically determining number of speakers, flexible threshold tuning
from scipy.cluster.hierarchy import linkage, fcluster
from scipy.spatial.distance import pdist
import numpy as np
# Prepare embeddings
embeddings_array = np.array(embeddings_list)
n_segments = len(embeddings_array)
# Compute distance matrix
distances = pdist(embeddings_array, metric='cosine')
# Create linkage matrix
linkage_matrix = linkage(distances, method='average')
# Auto-tune threshold to get reasonable speaker count
min_speakers = 2
max_speakers = max(2, min(10, n_segments // 2))
threshold = 0.7
labels = fcluster(linkage_matrix, t=threshold, criterion='distance')
n_speakers = len(set(labels))
# Adjust threshold if needed
if n_speakers > max_speakers:
for t in [0.8, 0.9, 1.0, 1.1, 1.2]:
labels = fcluster(linkage_matrix, t=t, criterion='distance')
n_speakers = len(set(labels))
if n_speakers <= max_speakers:
threshold = t
break
elif n_speakers < min_speakers:
for t in [0.6, 0.5, 0.4]:
labels = fcluster(linkage_matrix, t=t, criterion='distance')
n_speakers = len(set(labels))
if n_speakers >= min_speakers:
threshold = t
break
print(f"Selected: t={threshold}, {n_speakers} speakers")
Advantages:
- Automatically determines speaker count
- Flexible threshold tuning
- Good for unknown number of speakers
- Can visualize dendrogram
2. KMeans Clustering
Best for: Known number of speakers, fast clustering
from sklearn.cluster import KMeans
from sklearn.metrics import silhouette_score
import numpy as np
# Normalize embeddings
embeddings_array = np.array(embeddings_list)
norms = np.linalg.norm(embeddings_array, axis=1, keepdims=True)
embeddings_normalized = embeddings_array / np.clip(norms, 1e-9, None)
# Try different k values and choose best
best_k = 2
best_score = -1
best_labels = None
for k in range(2, min(7, len(embeddings_normalized))):
kmeans = KMeans(n_clusters=k, random_state=0, n_init=10)
labels = kmeans.fit_predict(embeddings_normalized)
if len(set(labels)) < 2:
continue
score = silhouette_score(embeddings_normalized, labels, metric='cosine')
if score > best_score:
best_score = score
best_k = k
best_labels = labels
print(f"Best k={best_k}, silhouette score={best_score:.3f}")
Advantages:
- Fast and efficient
- Works well with known speaker count
- Simple to implement
Disadvantages:
- Requires specifying number of clusters
- May get stuck in local minima
3. Agglomerative Clustering
Best for: Similar to hierarchical but with fixed number of clusters
from sklearn.cluster import AgglomerativeClustering
from sklearn.metrics import silhouette_score
import numpy as np
# Normalize embeddings
embeddings_array = np.array(embeddings_list)
norms = np.linalg.norm(embeddings_array, axis=1, keepdims=True)
embeddings_normalized = embeddings_array / np.clip(norms, 1e-9, None)
# Try different numbers of clusters
best_n = 2
best_score = -1
best_labels = None
for n_clusters in range(2, min(6, len(embeddings_normalized))):
clustering = AgglomerativeClustering(n_clusters=n_clusters)
labels = clustering.fit_predict(embeddings_normalized)
if len(set(labels)) < 2:
continue
score = silhouette_score(embeddings_normalized, labels, metric='cosine')
if score > best_score:
best_score = score
best_n = n_clusters
best_labels = labels
print(f"Best n_clusters={best_n}, silhouette score={best_score:.3f}")
Advantages:
- Deterministic results
- Good for fixed number of clusters
- Can use different linkage methods
Comparison Table
| Method | Auto Speaker Count | Speed | Best For | |--------|-------------------|-------|----------| | Hierarchical | ✅ Yes | Medium | Unknown speaker count | | KMeans | ❌ No | Fast | Known speaker count | | Agglomerative | ❌ No | Medium | Fixed clusters needed |
Embedding Normalization
Always normalize embeddings before clustering:
# L2 normalization
embeddings_normalized = embeddings_array / np.clip(
np.linalg.norm(embeddings_array, axis=1, keepdims=True),
1e-9, None
)
Distance Metrics
- Cosine: Best for speaker embeddings (default)
- Euclidean: Can work but less ideal for normalized embeddings
Choosing Number of Speakers
Method 1: Silhouette Score (for KMeans/Agglomerative)
from sklearn.metrics import silhouette_score
best_k = 2
best_score = -1
for k in range(2, min(7, len(embeddings))):
labels = clusterer.fit_predict(embeddings)
score = silhouette_score(embeddings, labels, metric='cosine')
if score > best_score:
best_score = score
best_k = k
Method 2: Threshold Tuning (for Hierarchical)
# Start with reasonable threshold
threshold = 0.7
labels = fcluster(linkage_matrix, t=threshold, criterion='distance')
n_speakers = len(set(labels))
# Adjust based on constraints
if n_speakers > max_speakers:
# Increase threshold to merge more
threshold = 0.9
elif n_speakers < min_speakers:
# Decrease threshold to split more
threshold = 0.5
Post-Clustering: Merging Segments
After clustering, merge adjacent segments with same speaker:
def merge_speaker_segments(labeled_segments, gap_threshold=0.15):
"""
labeled_segments: list of (start, end, speaker_label)
gap_threshold: merge if gap <= this (seconds)
"""
labeled_segments.sort(key=lambda x: (x[0], x[1]))
merged = []
cur_s, cur_e, cur_spk = labeled_segments[0]
for s, e, spk in labeled_segments[1:]:
if spk == cur_spk and s <= cur_e + gap_threshold:
cur_e = max(cur_e, e)
else:
merged.append((cur_s, cur_e, cur_spk))
cur_s, cur_e, cur_spk = s, e, spk
merged.append((cur_s, cur_e, cur_spk))
return merged
Common Issues
- Too many speakers: Increase threshold (hierarchical) or decrease k (KMeans)
- Too few speakers: Decrease threshold (hierarchical) or increase k (KMeans)
- Poor clustering: Check embedding quality, try different normalization
- Over-segmentation: Increase gap_threshold when merging segments
Best Practices
- Normalize embeddings before clustering
- Use cosine distance for speaker embeddings
- Try multiple methods and compare results
- Validate speaker count with visual features if available
- Merge adjacent segments after clustering
- After diarization, use high-quality ASR: Use Whisper
smallorlarge-v3model for transcription (see automatic-speech-recognition skill)
Related Skills
claude-mem
95.2kPersistent Context Across Sessions for Every Agent – Captures everything your agent does during sessions, compresses it with AI, and injects relevant context back into future sessions. Works with Claude Code, OpenClaw, Codex, Gemini, Hermes, Copilot, OpenCode + More
Understand-Anything
85.0kGraphs that teach > graphs that impress. Turn any code into an interactive knowledge graph you can explore, search, and ask questions about. Works with Claude Code, Codex, Cursor, Copilot, Gemini CLI, and more.
headroom
74.3kCompress tool outputs, logs, files, and RAG chunks before they reach the LLM. 20% fewer tokens for coding agents, 60-95% fewer tokens for JSON, same answers. Library, proxy, MCP server.
CowAgent
47.2kOpen-source personal AI assistant & Agent Harness. Plans tasks, runs tools and skills, self-evolves with memory and knowledge. Multi-agent, multi-model, multi-channel. Lightweight, extensible, one-line install.
Languages
Trust signals
From repository metadata: license, adoption, age and documentation. Not a code audit — see the Safety scan above for what the skill file itself contains.
