voxseg_/extract_feats.py
def _calculate_mat_feats(row: pd.DataFrame, params: dict) -> np.ndarray:
    '''Auxiliary function used by extract(). Extracts log-mel spectrograms from a row of a pd.DataFrame
    containing dataset information created by prep_data().

    Args:
        row: A row of a pd.DataFrame created by prep_data().
        params: a dictionary containing
                    frame_length -- the size of the input to the CNN, 
                    nfilt -- number of filters for logfbank
                    winlen -- size of the window for logfbank
                    winstep -- step for logfbank 

    Returns:
        An np.ndarray of features.
    '''

    sig = row['signal']
    if 'utterance-id' in row:
        id = row['utterance-id']
    else:
        id = row['recording-id']
        
    try:
        (interval_length, winstep) = utils.get_mat_interval_length(params) ## to make overlapping frames 
               
        len_sig = len(sig) 
        assert len(range(0, len_sig-1-interval_length, interval_length)) > 0
        feats = []
        end = 0
        for j in utils.progressbar(range(0, len_sig-1-interval_length, winstep), id):
            feats.append(np.flipud(np.array(sig[j:j+interval_length]).T))
            end = j+interval_length

        ## add last incomplete interval
        if end < len_sig-1:
            feats.append(np.flipud(np.array(sig[len_sig-interval_length:len_sig]).T))
        
        return np.array(feats)

    except AssertionError:
        print(f'WARNING: {id} is too short to extract features, will be ignored.')
Auxiliary function used by extract(). Extracts log-mel spectrograms from a row of a pd.DataFrame
    containing dataset information created by prep_data().

    Args:
        row: A row of a pd.DataFrame created by prep_data().
        params: a dictionary containing
                    frame_length -- the size of the input to the CNN, 
                    nfilt -- number of filters for logfbank
                    winlen -- size of the window for logfbank
                    winstep -- step for logfbank 

    Returns:
        An np.ndarray of features.
    
Auxiliary function used by extract(). Extracts log-mel spectrograms from a row of a pd.DataFrame
containing dataset information created by prep_data().
Auxiliary function used by extract () . Extracts log - mel spectrograms from a row of a pd . DataFrame containing dataset information created by prep_data () .
def _calculate_mat_feats(row: pd.DataFrame, params: dict) -> np.ndarray:
    sig = row['signal']
    if 'utterance-id' in row:
        id = row['utterance-id']
    else:
        id = row['recording-id']
    try:
        (interval_length, winstep) = utils.get_mat_interval_length(params) 
        len_sig = len(sig) 
        assert len(range(0, len_sig-1-interval_length, interval_length)) > 0
        feats = []
        end = 0
        for j in utils.progressbar(range(0, len_sig-1-interval_length, winstep), id):
            feats.append(np.flipud(np.array(sig[j:j+interval_length]).T))
            end = j+interval_length
        if end < len_sig-1:
            feats.append(np.flipud(np.array(sig[len_sig-interval_length:len_sig]).T))
        return np.array(feats)
    except AssertionError:
        print(f'WARNING: {id} is too short to extract features, will be ignored.')
def _calculate_mat_feats ( row : pd . DataFrame , params : dict ) -> np . ndarray : sig = row [ 'signal' ] if 'utterance-id' in row : id = row [ 'utterance-id' ] else : id = row [ 'recording-id' ] try : ( interval_length , winstep ) = utils . get_mat_interval_length ( params ) len_sig = len ( sig ) assert len ( range ( 0 , len_sig - 1 - interval_length , interval_length ) ) > 0 feats = [ ] end = 0 for j in utils . progressbar ( range ( 0 , len_sig - 1 - interval_length , winstep ) , id ) : feats . append ( np . flipud ( np . array ( sig [ j : j + interval_length ] ) . T ) ) end = j + interval_length if end < len_sig - 1 : feats . append ( np . flipud ( np . array ( sig [ len_sig - interval_length : len_sig ] ) . T ) ) return np . array ( feats ) except AssertionError : print ( f'WARNING: {id} is too short to extract features, will be ignored.' )
Auxiliary function used by extract().
Auxiliary function used by extract () .
'''Auxiliary function used by extract(). Extracts log-mel spectrograms from a row of a pd.DataFrame
    containing dataset information created by prep_data().

    Args:
        row: A row of a pd.DataFrame created by prep_data().
        params: a dictionary containing
                    frame_length -- the size of the input to the CNN, 
                    nfilt -- number of filters for logfbank
                    winlen -- size of the window for logfbank
                    winstep -- step for logfbank 

    Returns:
        An np.ndarray of features.
    ''' ## to make overlapping frames  ## add last incomplete interval
An np.ndarray of features.
An np . ndarray of features .
row
pd.DataFrame
A row of a pd.DataFrame created by prep_data().
A row of a pd . DataFrame created by prep_data () .
params
dict
a dictionary containing
frame_length -- the size of the input to the CNN,
nfilt -- number of filters for logfbank
winlen -- size of the window for logfbank
winstep -- step for logfbank
a dictionary containing frame_length -- the size of the input to the CNN nfilt -- number of filters for logfbank winlen -- size of the window for logfbank winstep -- step for logfbank