diart.mapping#
Module Contents#
Classes#
Helper class that provides a standard way to create an ABC using |
|
Helper class that provides a standard way to create an ABC using |
|
Helper class that provides a standard way to create an ABC using |
|
- class diart.mapping.MappingMatrixObjective#
Bases:
abc.ABCHelper class that provides a standard way to create an ABC using inheritance.
- property invalid_value: float#
- Return type:
float
- abstract property maximize: bool#
- Return type:
bool
- abstract property best_possible_value: float#
- Return type:
float
- abstract property best_value_fn: Callable#
- Return type:
Callable
- invalid_tensor(shape)#
- Parameters:
shape (Union[Tuple, int]) –
- Return type:
numpy.ndarray
- optimal_assignments(matrix)#
- Parameters:
matrix (numpy.ndarray) –
- Return type:
List[int]
- mapped_indices(matrix, axis)#
- Parameters:
matrix (numpy.ndarray) –
axis (int) –
- Return type:
List[int]
- hard_speaker_map(num_src, num_tgt, assignments)#
Create a hard map object where the highest cost is put everywhere except on hard assignments from
assignments.- Parameters:
num_src (int) – Number of source speakers
num_tgt (int) – Number of target speakers
assignments (Iterable[Tuple[int, int]]) – An iterable of tuples with two elements having the first element as the source speaker and the second element as the target speaker
- Return type:
- class diart.mapping.MinimizationObjective#
Bases:
MappingMatrixObjectiveHelper class that provides a standard way to create an ABC using inheritance.
- property maximize: bool#
- Return type:
bool
- property best_possible_value: float#
- Return type:
float
- property best_value_fn: Callable#
- Return type:
Callable
- class diart.mapping.MaximizationObjective(max_value=1)#
Bases:
MappingMatrixObjectiveHelper class that provides a standard way to create an ABC using inheritance.
- Parameters:
max_value (float) –
- property maximize: bool#
- Return type:
bool
- property best_possible_value: float#
- Return type:
float
- property best_value_fn: Callable#
- Return type:
Callable
- class diart.mapping.SpeakerMapBuilder#
- static hard_map(shape, assignments, maximize)#
Create a
SpeakerMapobject based on the given assignments. This is a “hard” map, meaning that the highest cost is put everywhere except on hard assignments fromassignments.- Parameters:
shape (Tuple[int, int])) – Shape of the mapping matrix
assignments (Iterable[Tuple[int, int]]) – An iterable of tuples with two elements having the first element as the source speaker and the second element as the target speaker
maximize (bool) – whether to use scores where higher is better (true) or where lower is better (false)
- Return type:
- static correlation(scores1, scores2)#
- Parameters:
scores1 (numpy.ndarray) –
scores2 (numpy.ndarray) –
- Return type:
- static mse(scores1, scores2)#
- Parameters:
scores1 (numpy.ndarray) –
scores2 (numpy.ndarray) –
- Return type:
- static mae(scores1, scores2)#
- Parameters:
scores1 (numpy.ndarray) –
scores2 (numpy.ndarray) –
- Return type:
- static dist(embeddings1, embeddings2, metric='cosine')#
- Parameters:
embeddings1 (numpy.ndarray) –
embeddings2 (numpy.ndarray) –
metric (Text) –
- Return type:
- class diart.mapping.SpeakerMap(mapping_matrix, objective)#
- Parameters:
mapping_matrix (numpy.ndarray) –
objective (MappingMatrixObjective) –
- property _raw_optimal_assignments: List[int]#
- Return type:
List[int]
- property shape: Tuple[int, int]#
- Return type:
Tuple[int, int]
- __len__()#
- __add__(other)#
- Parameters:
other (SpeakerMap) –
- Return type:
- _strict_check_valid(src, tgt)#
- Parameters:
src (int) –
tgt (int) –
- Return type:
bool
- _loose_check_valid(src, tgt)#
- Parameters:
src (int) –
tgt (int) –
- Return type:
bool
- valid_assignments(strict=False, as_array=False)#
- Parameters:
strict (bool) –
as_array (bool) –
- Return type:
Union[Tuple[List[int], List[int]], Tuple[numpy.ndarray, numpy.ndarray]]
- to_dict(strict=False)#
- Parameters:
strict (bool) –
- Return type:
Dict[int, int]
- to_inverse_dict(strict=False)#
- Parameters:
strict (bool) –
- Return type:
Dict[int, int]
- is_source_speaker_mapped(source_speaker)#
- Parameters:
source_speaker (int) –
- Return type:
bool
- is_target_speaker_mapped(target_speaker)#
- Parameters:
target_speaker (int) –
- Return type:
bool
- set_source_speaker(src_speaker, tgt_speaker)#
- Parameters:
tgt_speaker (int) –
- unmap_source_speaker(src_speaker)#
- Parameters:
src_speaker (int) –
- unmap_threshold(threshold)#
- Parameters:
threshold (float) –
- Return type:
- unmap_speakers(source_speakers=None, target_speakers=None)#
- Parameters:
source_speakers (Optional[Union[List[int], numpy.ndarray]]) –
target_speakers (Optional[Union[List[int], numpy.ndarray]]) –
- Return type:
- compose(other)#
Let’s say that self is a mapping of source_speakers to intermediate_speakers and other is a mapping from intermediate_speakers to target_speakers.
Compose self with other to obtain a new mapping from source_speakers to target_speakers.
- Parameters:
other (SpeakerMap) –
- Return type:
- union(other)#
self and other are two maps with the same dimensions. Return a new hard speaker map containing assignments in both maps.
An assignment from other is ignored if it is in conflict with a source or target speaker from self.
WARNING: The resulting map doesn’t preserve soft assignments because self and other might have different objectives.
- Parameters:
other (SpeakerMap) – SpeakerMap Another speaker map
- apply(source_scores)#
Apply this mapping to a score matrix of source speakers to obtain the same scores aligned to target speakers.
- Parameters:
source_scores (SlidingWindowFeature, (num_frames, num_source_speakers)) – Source speaker scores per frame.
- Returns:
projected_scores – Score matrix for target speakers.
- Return type:
SlidingWindowFeature, (num_frames, num_target_speakers)