-
-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
following to Feature Request: Implementing Persistent Speaker Embeddings Across Conversations #227 #228
base: main
Are you sure you want to change the base?
Conversation
that's how I run this
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this PR! I have several questions about the best way to implement the centroid retrieval. Centroid setting for the beginning of a conversation is missing in the current code.
Also, please make sure to run the black formatter before pushing
@@ -225,6 +226,9 @@ def __call__( | |||
agg_prediction = shifted_agg_prediction | |||
|
|||
outputs.append((agg_prediction, agg_waveform)) | |||
if self.return_embeddings: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to return centroids with each output? In order to have persistent centroids it would be enough to have a way of extracting them after inference and a way of setting them before inference. I think the best way to do this would be to expose getters and setters.
The thing is I don't want the RedisWriter to be exclusively for diarization. I would like for it to be compatible with VAD and in the future with transcription too.
Adding things at the end of each output is not a sustainable solution. With time, we could end up having huge tuples. An alternative would be to have different output objects per pipeline, like DiarizationOutput
and VADOutput
, but I want all sinks to be able to handle outputs seamlessly so they should remain at least similar enough. This would also require big changes to all inference and sink objects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think, we need to have setnroings ducing inference in the real time application. Obviously, every iteration is overkill
it would be enough to have a way of extracting them after inference
My usecase is about global speakers identification in real - time environment, which means I want to obtain speaker embeddings at some points for vector store lookup. After inference is not enough. As for now, I think good idea is to obtain a centroid for each new speaker after it's well - converged. Getting embeddings at each iteration obviously is overkill, but that worka for me at this point, as I can keep only the last state of centroids downstream. Maybe, a better idea is to develop an on-demand method for that, but I am pretty new to real time application and not sure how to do it right. Exposing getters looks good to me, but I am not sure how to use them
self.patch_collar = patch_collar | ||
|
||
def on_next(self, value: Union[Tuple, Annotation]): | ||
if isinstance(value, tuple): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use _extract_prediction()
here to get the annotation object instead of using an if statement
super().__init__() | ||
self.uri = uri | ||
self.redis_client = redis_client | ||
self.conversation_id = uri # Assuming URI as a unique identifier for the conversation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This attribute is not needed. self.uri
is enough
if len(value)==3: | ||
diarization_data['centroids'] = value[-1].tolist() | ||
|
||
self.redis_client.rpush(f'diarization_{self.conversation_id}', json.dumps(diarization_data)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not name this "diarization". We could also be writing the output of a VAD pipeline here
###### | ||
|
||
class RedisWriter(Observer): | ||
def __init__(self, uri: Text, redis_client, patch_collar: float = 0.05): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
patch_collar
isn't used here, right? In that case it should be removed
@@ -55,6 +56,46 @@ def on_error(self, error: Exception): | |||
def on_completed(self): | |||
self.patch() | |||
|
|||
###### |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove blank comment
# Handle completion (optional) | ||
pass | ||
|
||
####### |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove blank comment
Do you have specific use case for centroids setting, do you find it helpful? |
@DmitriyG228 if we can't set speaker centroids in the beginning, then this is not implementing "persistent speaker embeddings across conversations". Maybe I'm not understanding the use case very well, could you clarify this? |
I have a similar requirement, I need to recognize the "moderator" in a conversation, I am sure the moderator speaks for the first 30 seconds, I do not need the recognizing of the other speakers, but I need to be sure when the moderator is speaking again. A sort of "fix this centroid forever", the others I do not care. There is any way to do such operation in the current implementation? There is the possibility to store the "embeddng" of a voice and just recognize such speaker during a conversation? The others speakers can be wrong I'll not use that. |
@vtontodonato that would be an interesting feature to add, but I think it's unrelated to this PR. If you're up for it, I would suggest adding a |
I'll give a look at such methods ... and send you modification I'll be able to do to fit DIART in my scenario. |
Hey @juanmc2005,
Following to the issue #227,
Thank you!