algorithms/asa.py
def _map_segmentation_mask_to_stft_domain(mask, times, frequencies, stft_times, stft_frequencies):
    """
    Maps the given `mask`, which is in domain (`frequencies`, `times`) to the new domain (`stft_frequencies`, `stft_times`)
    and returns the result.
    """
    assert mask.shape == (frequencies.shape[0], times.shape[0]), "Times is shape {} and frequencies is shape {}, but mask is shaped {}".format(
        times.shape, frequencies.shape, mask.shape
    )
    result = np.zeros((stft_frequencies.shape[0], stft_times.shape[0]))

    if len(stft_times) > len(times):
        all_j = [j for j in range(len(stft_times))]
        idxs  = [int(i) for i in np.linspace(0, len(times) - 1, num=len(stft_times))]
        all_i = [all_j[idx] for idx in idxs]
    else:
        all_i = [i for i in range(len(times))]
        idxs  = [int(i) for i in np.linspace(0, len(stft_times) - 1, num=len(times))]
        all_j = [all_i[idx] for idx in idxs]

    for i, j in zip(all_i, all_j):
        result[:, j] = np.interp(stft_frequencies, frequencies, mask[:, i])

    return result
def _map_segmentation_mask_to_stft_domain(mask, times, frequencies, stft_times, stft_frequencies):
    """
    Maps the given `mask`, which is in domain (`frequencies`, `times`) to the new domain (`stft_frequencies`, `stft_times`)
    and returns the result.
    """
    assert mask.shape == (frequencies.shape[0], times.shape[0]), "Times is shape {} and frequencies is shape {}, but mask is shaped {}".format(
        times.shape, frequencies.shape, mask.shape
    )
    result = np.zeros((stft_frequencies.shape[0], stft_times.shape[0]))

    if len(stft_times) > len(times):
        all_j = [j for j in range(len(stft_times))]
        idxs  = [int(i) for i in np.linspace(0, len(times) - 1, num=len(stft_times))]
        all_i = [all_j[idx] for idx in idxs]
    else:
        all_i = [i for i in range(len(times))]
        idxs  = [int(i) for i in np.linspace(0, len(stft_times) - 1, num=len(times))]
        all_j = [all_i[idx] for idx in idxs]

    for i, j in zip(all_i, all_j):
        result[:, j] = np.interp(stft_frequencies, frequencies, mask[:, i])

    return result
def _map_segmentation_mask_to_stft_domain ( mask , times , frequencies , stft_times , stft_frequencies ) : assert mask . shape == ( frequencies . shape [ 0 ] , times . shape [ 0 ] ) , "Times is shape {} and frequencies is shape {}, but mask is shaped {}" . format ( times . shape , frequencies . shape , mask . shape ) result = np . zeros ( ( stft_frequencies . shape [ 0 ] , stft_times . shape [ 0 ] ) ) if len ( stft_times ) > len ( times ) : all_j = [ j for j in range ( len ( stft_times ) ) ] idxs = [ int ( i ) for i in np . linspace ( 0 , len ( times ) - 1 , num = len ( stft_times ) ) ] all_i = [ all_j [ idx ] for idx in idxs ] else : all_i = [ i for i in range ( len ( times ) ) ] idxs = [ int ( i ) for i in np . linspace ( 0 , len ( stft_times ) - 1 , num = len ( times ) ) ] all_j = [ all_i [ idx ] for idx in idxs ] for i , j in zip ( all_i , all_j ) : result [ : , j ] = np . interp ( stft_frequencies , frequencies , mask [ : , i ] ) return result
Maps the given `mask`, which is in domain (`frequencies`, `times`) to the new domain (`stft_frequencies`, `stft_times`)
    and returns the result.
Maps the given mask which is in domain ( frequencies times ) to the new domain ( stft_frequencies stft_times ) and returns the result .