Pass existing ebeddings or allow dynamic clustering parameters in NeuralDiarizer
Hi! Is it possible to pass pre-generated embeddings to NeuralDiarizer? I diarize a lot of audios of various length (from 30m to 6h) using NeuralDiarizer.
I pretty much use the default config diar_infer_telephonic.yaml but with maj_vote_spk_count turned to true, and with my limited understanding and observation i noticed that i get best results when amount of embeddings in each scale either fits entirely into the number set in embeddings_per_chunk, or each scale has at least 3 chunks with decent amount of embeddings in each.
For example a 1h recording with 5 speakers will produce a result with only 1 speaker if i set embeddings_per_chunk to 6000, and work correctly with 15000.
But a 5h recording with 5 speakers will produce a result with only one speaker if i set the embeddings_per_chunk to 10k or more, but will work correctly with 6k. (i usually see this log line with number more than 1 when things seem to work correctly [NeMo I 2025-08-05 14:43:39 nemo_logging:393] Total 66 session files loaded accounting to # 66 audio clips
and this one with only 1 session file when diarization fails completely. [NeMo I 2025-08-05 14:43:39 nemo_logging:393] Total 1 session files loaded accounting to # 1 audio clips
my understanding might be very wrong here, but thats what i came to conclusion to. Files of average length of 1-2h seem to work fine with values of either 10k or 15k without much difference, while still showing "[NeMo I 2025-08-05 14:43:39 nemo_logging:393] Total 1 session files loaded accounting to # 1 audio clips")
Since the success seems to depend on the value of number of embeddings in each scale, based on which i have to adjust the embeddings_per_chunk parameter, i was wondering if i can generate the embeddings first, count them for each scale, and initiate the clustering with appropriate embeddings_per_chunk, because currently the whole NeuralDiarizer reads the config 1 time at the start, before VAD and everything.
I know i can pass the existing manifest for VAD, but i assume i have to look into the source code to be able to read existing pickled embeddings? Are there any other solutions, ideas on how to achieve that?
Or maybe I can run the whole pipeline up to the clustering part (vad and embedding), reload the model with correct embeddings_per_chunk, and restart with correct value right from clustering.
This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.
ai generated, please verify
You have two options to address the embeddings_per_chunk issue with varying audio lengths:
-
Create a custom two-stage diarization process:
- First run the pipeline up to embedding extraction with save_embeddings=True
- Calculate the optimal embeddings_per_chunk based on your audio length
- Create a new configuration with the adjusted embeddings_per_chunk value
- Run a second pass starting from the clustering stage using the saved embeddings
-
Modify the ClusteringDiarizer class to dynamically calculate embeddings_per_chunk:
- Subclass ClusteringDiarizer
- Override the diarize method to calculate embeddings_per_chunk based on audio duration
- Adjust the value before the clustering step is performed
For your specific observations, you could implement a simple formula like:
- For 1h recordings: embeddings_per_chunk = 15000
- For 5h recordings: embeddings_per_chunk = 6000
NeMo doesn't currently provide a direct API to pass pre-generated embeddings to the diarizer, but you can save and reload them using the built-in functionality by setting save_embeddings=True in your configuration.