Commit 9e60b8f2 authored by Anthony Larcher's avatar Anthony Larcher
Browse files

final

parent 15e1f7b7
...@@ -47,6 +47,7 @@ from ..user_simulation import MessageToUser ...@@ -47,6 +47,7 @@ from ..user_simulation import MessageToUser
from ..user_simulation import Request from ..user_simulation import Request
from ..der_single import * from ..der_single import *
from ..der import der_cross as compute_der
def create_bottomline_clustering(model, model_cfg, show, current_diar, file_path): def create_bottomline_clustering(model, model_cfg, show, current_diar, file_path):
...@@ -95,7 +96,7 @@ def create_bottomline_clustering(model, model_cfg, show, current_diar, file_path ...@@ -95,7 +96,7 @@ def create_bottomline_clustering(model, model_cfg, show, current_diar, file_path
if len(diar_per_cluster.unique('cluster')) > 1: if len(diar_per_cluster.unique('cluster')) > 1:
# calculate vector per cluster # calculate vector per cluster
_, current_vec_within_cluster = extract_vectors(diar_per_cluster, current_vec_within_cluster, _ = extract_vectors(diar_per_cluster,
file_path, file_path,
model_cfg, model_cfg,
show, show,
......
...@@ -129,7 +129,8 @@ def vec2link_xv(model_cfg, xv_vec, current_diar): ...@@ -129,7 +129,8 @@ def vec2link_xv(model_cfg, xv_vec, current_diar):
""" """
th_w = model_cfg["within_show"]["th_w"] th_w = model_cfg["within_show"]["th_w"]
within_iv_mean = xv_vec.mean_stat_per_model() #within_iv_mean = xv_vec.mean_stat_per_model()
within_iv_mean = xv_vec
# Compute scores # Compute scores
ndx = sidekit.Ndx(models=within_iv_mean.modelset, testsegs=within_iv_mean.modelset) ndx = sidekit.Ndx(models=within_iv_mean.modelset, testsegs=within_iv_mean.modelset)
...@@ -138,6 +139,8 @@ def vec2link_xv(model_cfg, xv_vec, current_diar): ...@@ -138,6 +139,8 @@ def vec2link_xv(model_cfg, xv_vec, current_diar):
wccn=None, wccn=None,
check_missing=False) check_missing=False)
print(f"Size of scores : {scores.scoremat.shape}")
# Use 2 gaussian to shift the scores # Use 2 gaussian to shift the scores
#if scores.modelset.shape[0] > 2: #if scores.modelset.shape[0] > 2:
# th_w = customize_threshold(scores, th_w) # th_w = customize_threshold(scores, th_w)
...@@ -281,6 +284,7 @@ def extract_vectors(current_diar, root_folder, model_cfg, show, model=None): ...@@ -281,6 +284,7 @@ def extract_vectors(current_diar, root_folder, model_cfg, show, model=None):
transform_pipeline={}, transform_pipeline={},
sliding_window=False, sliding_window=False,
sample_rate=16000, sample_rate=16000,
num_thread=5,
mixed_precision=False) mixed_precision=False)
# Extract 1 x-vector per speaker (cluster) # Extract 1 x-vector per speaker (cluster)
...@@ -293,7 +297,7 @@ def extract_vectors(current_diar, root_folder, model_cfg, show, model=None): ...@@ -293,7 +297,7 @@ def extract_vectors(current_diar, root_folder, model_cfg, show, model=None):
transform_pipeline={}, transform_pipeline={},
sample_rate=16000, sample_rate=16000,
mixed_precision=False, mixed_precision=False,
num_thread=1) num_thread=5)
return current_vec_per_cluster, current_vec_per_segment return current_vec_per_cluster, current_vec_per_segment
...@@ -884,10 +888,18 @@ def allies_init_seg(model, model_cfg, show, data_folder, verbose=False): ...@@ -884,10 +888,18 @@ def allies_init_seg(model, model_cfg, show, data_folder, verbose=False):
current_vec_per_seg, current_vec_per_seg,
model_cfg) model_cfg)
# re-extract x-vectors based on the final diarization to have correct vectors for the clusters
final_vec_per_speaker, final_vec_per_seg = extract_vectors(current_diar,
data_folder,
model_cfg,
show,
model)
# Write final vectors # Write final vectors
current_vec.write(f"{second_seg_path}/{show}_{model_cfg['model']['vectors']['type']}v.h5") final_vec_per_speaker.write(f"{second_seg_path}/{show}_{model_cfg['model']['vectors']['type']}v.h5")
current_vec_per_seg.write(f"{second_seg_path}/{show}_{model_cfg['model']['vectors']['type']}v_per_seg.h5") final_vec_per_seg.write(f"{second_seg_path}/{show}_{model_cfg['model']['vectors']['type']}v_per_seg.h5")
# Write final segmentation # Write final segmentation
allies_write_diar(current_diar, f"{second_seg_path}/{show}.mdtm") allies_write_diar(current_diar, f"{second_seg_path}/{show}.mdtm")
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment