aeneas.cdtw¶
aeneas.cdtw is a Python C extension for computing the DTW.

cdtw.
compute_best_path
(mfcc1, mfcc2, delta)¶ Compute the DTW (approximated) best path for the two audio waves, represented by their MFCCs.
This function implements the SakoeChiba heuristic, that is, it explores only a band of width
2 * delta
around the main diagonal of the cost matrix.The computation is done inmemory, and it might fail if there is not enough memory to allocate the cost matrix or the list to be returned.
The returned list contains tuples
(i, j)
, representing the best path from(0, 0)
to(n1, m1)
, wheren
is the length ofmfcc1
, andm
is the length ofmfcc2
. The returned list has length betweenmin(n, m)
andn + m
(it can be less thann + m
if diagonal steps are selected in the best path).Parameters:  mfcc1 (
numpy.ndarray
) – the MFCCs of the first wave(n, mfcc_size)
 mfcc2 (
numpy.ndarray
) – the MFCCs of the second wave(m, mfcc_size)
 delta (int) – the margin parameter
Return type: list of tuples
 mfcc1 (

cdtw.
compute_cost_matrix_step
(mfcc1, mfcc2, delta)¶ Compute the DTW (approximated) cost matrix for the two audio waves, represented by their MFCCs.
This function implements the SakoeChiba heuristic, that is, it explores only a band of width
2 * delta
around the main diagonal of the cost matrix.The computation is done inmemory, and it might fail if there is not enough memory to allocate the cost matrix.
The returned tuple
(cost_matrix, centers)
contains the cost matrix (NumPy 2D array of shape (n, delta)) and the row centers (NumPy 1D array of size n).Parameters:  mfcc1 (
numpy.ndarray
) – the MFCCs of the first wave(n, mfcc_size)
 mfcc2 (
numpy.ndarray
) – the MFCCs of the second wave(m, mfcc_size)
 delta (int) – the margin parameter
Return type: tuple
 mfcc1 (

cdtw.
compute_accumulated_cost_matrix_step
(cost_matrix, centers)¶ Compute the DTW (approximated) accumulated cost matrix from the cost matrix and the row centers.
This function implements the SakoeChiba heuristic, that is, it explores only a band of width
2 * delta
around the main diagonal of the cost matrix.The computation is done inmemory, and the accumulated cost matrix is computed in place, that is, the original cost matrix is destroyed and its allocated memory used to store the accumulated cost matrix. Hence, this call should not fail for memory reasons.
The returned NumPy 2D array of shape
(n, delta)
contains the accumulated cost matrix.Parameters:  cost_matrix (
numpy.ndarray
) – the cost matrix(n, delta)
 centers (
numpy.ndarray
) – the row centers(n,)
Return type: numpy.ndarray
 cost_matrix (

cdtw.
compute_best_path_step
(accumulated_cost_matrix, centers)¶ Compute the DTW (approximated) best path from the accumulated cost matrix and the row centers.
This function implements the SakoeChiba heuristic, that is, it explores only a band of width
2 * delta
around the main diagonal of the cost matrix.The computation is done inmemory, and it might fail if there is not enough memory to allocate the list to be returned.
The returned list contains tuples
(i, j)
, representing the best path from(0, 0)
to(n1, m1)
, wheren
is the length ofmfcc1
, andm
is the length ofmfcc2
. The returned list has length betweenmin(n, m)
andn + m
(it can be less thann + m
if diagonal steps are selected in the best path).Parameters:  cost_matrix (
numpy.ndarray
) – the accumulated cost matrix(n, delta)
 centers (
numpy.ndarray
) – the row centers(n, )
Return type: list of tuples
 cost_matrix (