voxseg_/evaluate.py
def score_syllables(wav_scp: pd.DataFrame, sys_segs: pd.DataFrame, ref_segs: pd.DataFrame, winlen: float):
    '''Function for calculating the syllable scores
    
    Args:
        wav_scp: A pd.DataFrame containing information about the wavefiles that have been segmented.
        sys_segs: A pd.DataFrame containing the endpoints produced by a VAD system.
        ref_segs: A pd.DataFrame containing the ground truth reference endpoints. 
        winlen: The time interval covered by a column in the spectrogram -- not used right now   
    '''

    max_tolerance = 6
    #scores = [{'TP': 0, 'FP': 0, 'Nr_syll': 0}] * max_tolerance
    scores = []
    for i in range(max_tolerance):
        scores.append({'TP': 0, 'FP': 0, 'Nr_syll': 0})

    for _, row in wav_scp.iterrows():
        f = row['extended filename']
        rec_id = row['recording-id']
        rate, signal = wavfile.read(f) 
        len_data = len(signal)

        (t_onsets, t_offsets) = getWavBoundaries(len_data, rate, rec_id, ref_segs) 
        (p_onsets, p_offsets) = getWavBoundaries(len_data, rate, rec_id, sys_segs)
        
        #logging.debug("Processing file: {}".format(f))
        #logging.debug("predictions:\n\t onsets: {}\n\t offsets: {}".format(p_onsets, p_offsets))
        #logging.debug("reference:\n\t onsets: {}\n\t offsets: {}".format(t_onsets, t_offsets))
    
        
        for t in range(max_tolerance):
            (TP, FP, nr_syll) = score_boundaries(p_onsets, p_offsets, t_onsets, t_offsets, int(t * winlen * rate))
            scores[t]['TP'] += TP 
            scores[t]['FP'] += FP
            scores[t]['Nr_syll'] += nr_syll
                        
    for t in range(max_tolerance):
        scores[t]["Prec"] = scores[t]['TP'] / (scores[t]['TP'] + scores[t]['FP'] + sys.float_info.epsilon)
        scores[t]["Rec"]  = scores[t]['TP']/ (scores[t]['Nr_syll'] + sys.float_info.epsilon)
        scores[t]["F1"] = 2 * scores[t]["Prec"] * scores[t]["Rec"] / (scores[t]["Prec"] + scores[t]["Rec"] + sys.float_info.epsilon)
        
    logging.info("\nSyllable scores for tolerance between 0 and {}:\n{}".format(max_tolerance-1, pd.DataFrame(scores)))
    
    syllable_scores_Xinyu(wav_scp, ref_segs, sys_segs, winlen)
Function for calculating the syllable scores
    
    Args:
        wav_scp: A pd.DataFrame containing information about the wavefiles that have been segmented.
        sys_segs: A pd.DataFrame containing the endpoints produced by a VAD system.
        ref_segs: A pd.DataFrame containing the ground truth reference endpoints. 
        winlen: The time interval covered by a column in the spectrogram -- not used right now   
    
Function for calculating the syllable scores
Function for calculating the syllable scores
def score_syllables(wav_scp: pd.DataFrame, sys_segs: pd.DataFrame, ref_segs: pd.DataFrame, winlen: float):
    max_tolerance = 6
    scores = []
    for i in range(max_tolerance):
        scores.append({'TP': 0, 'FP': 0, 'Nr_syll': 0})
    for _, row in wav_scp.iterrows():
        f = row['extended filename']
        rec_id = row['recording-id']
        rate, signal = wavfile.read(f) 
        len_data = len(signal)
        (t_onsets, t_offsets) = getWavBoundaries(len_data, rate, rec_id, ref_segs) 
        (p_onsets, p_offsets) = getWavBoundaries(len_data, rate, rec_id, sys_segs)
        for t in range(max_tolerance):
            (TP, FP, nr_syll) = score_boundaries(p_onsets, p_offsets, t_onsets, t_offsets, int(t * winlen * rate))
            scores[t]['TP'] += TP 
            scores[t]['FP'] += FP
            scores[t]['Nr_syll'] += nr_syll
    for t in range(max_tolerance):
        scores[t]["Prec"] = scores[t]['TP'] / (scores[t]['TP'] + scores[t]['FP'] + sys.float_info.epsilon)
        scores[t]["Rec"]  = scores[t]['TP']/ (scores[t]['Nr_syll'] + sys.float_info.epsilon)
        scores[t]["F1"] = 2 * scores[t]["Prec"] * scores[t]["Rec"] / (scores[t]["Prec"] + scores[t]["Rec"] + sys.float_info.epsilon)
    logging.info("\nSyllable scores for tolerance between 0 and {}:\n{}".format(max_tolerance-1, pd.DataFrame(scores)))
    syllable_scores_Xinyu(wav_scp, ref_segs, sys_segs, winlen)
def score_syllables ( wav_scp : pd . DataFrame , sys_segs : pd . DataFrame , ref_segs : pd . DataFrame , winlen : float ) : max_tolerance = 6 scores = [ ] for i in range ( max_tolerance ) : scores . append ( { 'TP' : 0 , 'FP' : 0 , 'Nr_syll' : 0 } ) for _ , row in wav_scp . iterrows ( ) : f = row [ 'extended filename' ] rec_id = row [ 'recording-id' ] rate , signal = wavfile . read ( f ) len_data = len ( signal ) ( t_onsets , t_offsets ) = getWavBoundaries ( len_data , rate , rec_id , ref_segs ) ( p_onsets , p_offsets ) = getWavBoundaries ( len_data , rate , rec_id , sys_segs ) for t in range ( max_tolerance ) : ( TP , FP , nr_syll ) = score_boundaries ( p_onsets , p_offsets , t_onsets , t_offsets , int ( t * winlen * rate ) ) scores [ t ] [ 'TP' ] += TP scores [ t ] [ 'FP' ] += FP scores [ t ] [ 'Nr_syll' ] += nr_syll for t in range ( max_tolerance ) : scores [ t ] [ "Prec" ] = scores [ t ] [ 'TP' ] / ( scores [ t ] [ 'TP' ] + scores [ t ] [ 'FP' ] + sys . float_info . epsilon ) scores [ t ] [ "Rec" ] = scores [ t ] [ 'TP' ] / ( scores [ t ] [ 'Nr_syll' ] + sys . float_info . epsilon ) scores [ t ] [ "F1" ] = 2 * scores [ t ] [ "Prec" ] * scores [ t ] [ "Rec" ] / ( scores [ t ] [ "Prec" ] + scores [ t ] [ "Rec" ] + sys . float_info . epsilon ) logging . info ( "\nSyllable scores for tolerance between 0 and {}:\n{}" . format ( max_tolerance - 1 , pd . DataFrame ( scores ) ) ) syllable_scores_Xinyu ( wav_scp , ref_segs , sys_segs , winlen )
Function for calculating the syllable scores
Function for calculating the syllable scores
'''Function for calculating the syllable scores
    
    Args:
        wav_scp: A pd.DataFrame containing information about the wavefiles that have been segmented.
        sys_segs: A pd.DataFrame containing the endpoints produced by a VAD system.
        ref_segs: A pd.DataFrame containing the ground truth reference endpoints. 
        winlen: The time interval covered by a column in the spectrogram -- not used right now   
    ''' #scores = [{'TP': 0, 'FP': 0, 'Nr_syll': 0}] * max_tolerance #logging.debug("Processing file: {}".format(f)) #logging.debug("predictions:\n\t onsets: {}\n\t offsets: {}".format(p_onsets, p_offsets)) #logging.debug("reference:\n\t onsets: {}\n\t offsets: {}".format(t_onsets, t_offsets))
wav_scp
pd.DataFrame
A pd.DataFrame containing information about the wavefiles that have been segmented.
A pd . DataFrame containing information about the wavefiles that have been segmented .
sys_segs
pd.DataFrame
A pd.DataFrame containing the endpoints produced by a VAD system.
A pd . DataFrame containing the endpoints produced by a VAD system .
ref_segs
pd.DataFrame
A pd.DataFrame containing the ground truth reference endpoints.
A pd . DataFrame containing the ground truth reference endpoints .
winlen
float
The time interval covered by a column in the spectrogram -- not used right now
The time interval covered by a column in the spectrogram -- not used right now