Filter out too short segments from diarization in the separation pipeline#1816
Conversation
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
There was a problem hiding this comment.
Pull Request Overview
This PR adds filtering functionality to remove speech segments that are too short in the speaker diarization component of the speech separation pipeline.
- Adds a
min_duration_onparameter to control the minimum duration of speech segments - Implements morphological closing operation to filter out segments shorter than the threshold
- Updates import statements to include the necessary scipy.ndimage functions
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| from scipy.ndimage import binary_dilation, binary_closing | ||
| import torch |
There was a problem hiding this comment.
[nitpick] The import reorganization places scipy.ndimage import before torch import, breaking alphabetical ordering. Consider maintaining consistent import ordering for better code organization.
| from scipy.ndimage import binary_dilation, binary_closing | |
| import torch | |
| import torch | |
| from scipy.ndimage import binary_dilation, binary_closing |
| discrete_diarization.data = binary_closing( | ||
| discrete_diarization.data, structure=np.array([[True] * min_frames_on]).T | ||
| ) | ||
|
|
There was a problem hiding this comment.
Creating a new numpy array with np.array([[True] * min_frames_on]).T for each call is inefficient. Consider creating the structure array once outside the conditional or reusing it across calls.
| discrete_diarization.data = binary_closing( | |
| discrete_diarization.data, structure=np.array([[True] * min_frames_on]).T | |
| ) | |
| structure = np.array([[True] * min_frames_on]).T | |
| discrete_diarization.data = binary_closing( | |
| discrete_diarization.data, structure=structure | |
| ) |
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
No description provided.