You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Sources/FluidAudio/Diarizer/Clustering/SpeakerManager.swift
+36-36Lines changed: 36 additions & 36 deletions
Original file line number
Diff line number
Diff line change
@@ -37,9 +37,9 @@ public class SpeakerManager {
37
37
38
38
/// Add known speakers to the database
39
39
/// - Parameters:
40
-
/// - speakers: list of `Speaker`s to add
41
-
/// - mode: mode for handling overlapping ID conflicts. `.reset` will reset the speaker database before initializing new speakers. `.overwrite` will overwrite the old speakers and replace them with the new ones. `.merge` will merge the new speakers with the old ones, keeping the new name. `.skip` will skip new speakers if their ID matches an existing one. (Default: `.skip`)
42
-
/// - preservePermanent: whether to avoid overwriting/merging pre-existing permanent speakers
40
+
/// - speakers: Array of `Speaker`s to add
41
+
/// - mode: Mode for handling overlapping ID conflicts. `.reset` will reset the speaker database before initializing new speakers. `.overwrite` will overwrite the old speakers and replace them with the new ones. `.merge` Will merge the new speakers with the old ones, keeping the new name. `.skip` will skip new speakers if their ID matches an existing one. (Default: `.skip`)
42
+
/// - preservePermanent: Whether to avoid overwriting/merging pre-existing permanent speakers
if !(oldSpeaker.isPermanent && preservePermanent){
65
+
if !(oldSpeaker.isPermanent && preserveIfPermanent){
66
66
logger.warning("Speaker \(speaker.id) is already initialized. Overwriting old speaker.")
67
67
speakerDatabase[speaker.id]= speaker
68
68
}else{
@@ -101,11 +101,11 @@ public class SpeakerManager {
101
101
/// Match the embedding to the closest existing speaker if sufficiently similar or create a new one if not.
102
102
/// - Parameters:
103
103
/// - embedding: 256D speaker embedding vector
104
-
/// - speechDuration: duration of the speech segment during which this speaker was active
105
-
/// - confidence: confidence in the embedding vector being correct
106
-
/// - speakerThreshold: the maximum cosine distance to an existing speaker to create a new one (uses the default threshold for this `SpeakerManager` object if none is provided)
107
-
/// - newName: name to assign the speaker if a new one is created (default: `Speaker $id`)
108
-
/// - Returns: a `Speaker` object if a match was found or a new one was created. Returns `nil` if an error occured.
104
+
/// - speechDuration: Duration of the speech segment during which this speaker was active
105
+
/// - confidence: Confidence in the embedding vector being correct
106
+
/// - speakerThreshold: The maximum cosine distance to an existing speaker to create a new one (uses the default threshold for this `SpeakerManager` object if none is provided)
107
+
/// - newName: Name to assign the speaker if a new one is created (default: `Speaker $id`)
108
+
/// - Returns: A `Speaker` object if a match was found or a new one was created. Returns `nil` if an error occured.
109
109
publicfunc assignSpeaker(
110
110
_ embedding:[Float],
111
111
speechDuration:Float,
@@ -162,8 +162,8 @@ public class SpeakerManager {
162
162
/// Find the closest existing speaker to an embedding, up to a maximum cosine distance of `speakerThreshold`.
163
163
/// - Parameters:
164
164
/// - embedding: 256D speaker embedding vector
165
-
/// - speakerThreshold: the maximum cosine distance to an existing speaker to create a new one (uses the default threshold for this `SpeakerManager` object if none is provided)
166
-
/// - Returns: the ID of the match (if found) and the distance to that match.
165
+
/// - speakerThreshold: Maximum cosine distance to an existing speaker to create a new one (uses the default threshold for this `SpeakerManager` object if none is provided)
166
+
/// - Returns: ID of the match (if found) and the distance to that match.
0 commit comments