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: Documentation/SpeakerManager.md
+35-15Lines changed: 35 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -78,7 +78,7 @@ Sometimes, there are already speakers in the database that may have the same ID.
78
78
```swift
79
79
let alice =Speaker(id: "alice", name: "Alice", currentEmbedding: aliceEmbedding)
80
80
let bob =Speaker(id: "bob", name: "Bob", currentEmbedding: bobEmbedding)
81
-
speakerManager.initializeKnownSpeakers([alice, bob], mode: .overwrite, preservePermanent: false) // replace any speakers with ID "alice" or "bob" with the new speakers, even if the old ones were marked as permanent.
81
+
speakerManager.initializeKnownSpeakers([alice, bob], mode: .overwrite, preserveIfPermanent: false) // replace any speakers with ID "alice" or "bob" with the new speakers, even if the old ones were marked as permanent.
82
82
```
83
83
84
84
> The `mode` argument dictates how to handle redundant speakers. It is of type `SpeakerInitializationMode`, and can take on one of four values:
> -`.overwrite`: overwrite existing speakers with the same IDs as the new ones
88
88
> -`.skip`: skip adding speakers whose IDs match existing ones
89
89
>
90
-
> The `preservePermanent` argument determines whether existing speakers marked as permanent should be preserved (i.e., not overwritten or merged). It is `true` by default.
90
+
> The `preserveIfPermanent` argument determines whether existing speakers marked as permanent should be preserved (i.e., not overwritten or merged). It is `true` by default.
91
91
92
92
**Use case:** When you have pre-recorded voice samples of known speakers and want to recognize them by name instead of numeric IDs.
93
93
@@ -191,6 +191,13 @@ Make the speaker not permanent.
191
191
speakerManager.revokePermanence(from: "alice") // mark "alice" as not permanent
192
192
```
193
193
194
+
#### resetPermanentFlags
195
+
Mark all speakers as not permanent.
196
+
197
+
```swift
198
+
speakerManager.resetPermanentFlags()
199
+
```
200
+
194
201
### Speaker Retrieval
195
202
196
203
#### findSpeaker
@@ -263,6 +270,15 @@ let allSpeakers = speakerManager.getSpeakerList()
263
270
// Returns: [Speaker] - Array of speakers
264
271
```
265
272
273
+
#### hasSpeaker
274
+
Check if the speaker database has a speaker with a given ID.
275
+
276
+
```swift
277
+
if speakerManager.hasSpeaker("alice") {
278
+
print("Alice was found in the database")
279
+
}
280
+
```
281
+
266
282
#### speakerCount
267
283
Get the total number of tracked speakers.
268
284
@@ -285,7 +301,7 @@ Clear all speakers from the database.
285
301
286
302
```swift
287
303
speakerManager.reset()
288
-
speakerManager.reset(keepPermanent: true) // remove all non-permanent speakers from the database
304
+
speakerManager.reset(keepIfPermanent: true) // remove all non-permanent speakers from the database
289
305
```
290
306
291
307
Useful for:
@@ -696,23 +712,25 @@ class RealtimeDiarizer {
696
712
| Method | Returns | Description |
697
713
|--------|---------|-------------|
698
714
|`assignSpeaker(_:speechDuration:confidence:)`|`Speaker?`| Assign/create speaker from embedding |
699
-
|`initializeKnownSpeakers(_:mode:preservePermanent:)`|`Void`| Pre-load known speaker profiles |
715
+
|`initializeKnownSpeakers(_:mode:preserveIfPermanent:)`|`Void`| Pre-load known speaker profiles |
700
716
|`findSpeaker(with:speakerThreshold:)`|`(id: String?, distance: Float)`| Find speaker that matches an embedding |
701
-
|`findMatchingSpeaker(with:speakerThreshold:)`|`[(id: String, distance: Float)]`| Find all speakers that match an embedding |
702
-
| `findSpeakers(where:)` | [String] | Find all speakers that meet a certain predicate
703
-
| findMergeablePairs(speakerThreshold:excludeIfBothPermanent:) |[(speakerToMerge: String, destination: String)]| Find all pairs of very similar speakers |
704
-
|`removeSpeaker(_:keepIfPermanent:)`|`Bool`| Remove a speaker from the database |
705
-
|`removeSpeakersInactive(since:keepIfPermanent:)`|`Bool`| Remove speakers inactive since a given date |
706
-
|`removeSpeakersInactive(for:keepIfPermanent:)`|`Bool`| Remove speakers inactive for a given duration |
707
-
|`removeSpeakers(where:)`|`Bool`| Remove speakers that satisfy a given predicate |
708
-
|`removeSpeakers(where:keepIfPermanent:)`|`Bool`| Remove speakers that satisfy a given predicate |
709
-
|`mergeSpeaker(_:into:mergedName:stopIfPermanent:)`|`Bool`| Merge a speaker into another one |
717
+
|`findMatchingSpeakers(with:speakerThreshold:)`|`[(id: String, distance: Float)]`| Find all speakers that match an embedding |
718
+
| `findSpeakers(where:)` | `[String]` | Find all speakers that meet a certain predicate
719
+
|`findMergeablePairs(speakerThreshold:excludeIfBothPermanent:)`|`[(speakerToMerge: String, destination: String)]`| Find all pairs of very similar speakers |
720
+
|`removeSpeaker(_:keepIfPermanent:)`|`Void`| Remove a speaker from the database |
721
+
|`removeSpeakersInactive(since:keepIfPermanent:)`|`Void`| Remove speakers inactive since a given date |
722
+
|`removeSpeakersInactive(for:keepIfPermanent:)`|`Void`| Remove speakers inactive for a given duration |
723
+
|`removeSpeakers(where:)`|`Void`| Remove speakers that satisfy a given predicate |
724
+
|`removeSpeakers(where:keepIfPermanent:)`|`Void`| Remove speakers that satisfy a given predicate |
725
+
|`mergeSpeaker(_:into:mergedName:stopIfPermanent:)`|`Void`| Merge a speaker into another one |
710
726
|`upsertSpeaker(_:)`|`Void`| Update or insert speaker (from object) |
711
727
|`upsertSpeaker(id:currentEmbedding:duration:...)`|`Void`| Update or insert speaker (from params) |
712
728
|`getSpeaker(for:)`|`Speaker?`| Get speaker by ID |
713
729
|`getAllSpeakers()`|`[String: Speaker]`| Get all speakers (debugging) |
714
-
|`reset()`|`Void`| Clear speaker database |
715
-
|`reassignSegment(segmentId:from:to:)`|`Bool`| Move segment between speakers |
730
+
|`getSpeakerList()`|`[Speaker]`| Get array of all speakers (debugging) |
731
+
|`hasSpeaker(_:)`|`Bool`| Check if database has a speaker with a given ID |
0 commit comments