def trim_df(df,max_duration=30.0,drop_bad=True):
    """
    Performs some cleaning on the dataframe, dropping recordings that
    are too long, or where the source and noisy recording lengths differ

    Inputs:
        df - A pandas dataframe representing the index file of the dataset,
            with the default columns of VOiCES index files.
        max_duration - The maximum duration, in seconds, of recordings to keep
            in the dataset (float)
        drop_bad - If True, entries where the noisy recording is not the same
            length as the source audio will be dropped
    Outputs:
        new_df - The cleaned dataframe
    """
    if drop_bad:
        new_df = df[df['noisy_length']==df['source_length']]
    else:
        new_df = df.copy()
    new_df = new_df[new_df['noisy_time']<=max_duration]
    return new_df