maad.util.write_audacity_annot

maad.util.write_audacity_annot(fname, df_rois, save_file=True)[source]

Write audio segmentation to text file in Audacity format, a file that can be imported and modified with Audacity. If the dataframe has no frequency delimiters, annotations are saved with standard Audacity format (temporal segmentation). If the dataframe has temporal and frequencial delimiters, the annotations are saved as spectral selection style (spectro-temporal selection). If the dataframe is empty, the function saves an empty file.

Parameters:
fname: str

filename to save the segmentation

df_rois: pandas dataframe

Dataframe containing the coordinates corresponding to sound signatures In case of only temporal annotations : df_rois must contain at least the columns ‘mint_t’, ‘max_t’ In case of bounding box (temporal eand frequency limits) :: df_rois must contain at least the columns ‘min_t’, ‘max_t’, ‘min_f’, ‘max_f’

save_file: bool, optional, default=True

If True, the file is saved. If False, the file is not saved.

Returns:
df_to_save

Dataframe that has been saved

Examples

>>> s, fs = maad.sound.load('../data/cold_forest_daylight.wav')
>>> Sxx_power, tn, fn, ext = maad.sound.spectrogram(s, fs)
>>> Sxx_db = maad.util.power2dB(Sxx_power) + 96
>>> Sxx_power_noNoise= maad.sound.median_equalizer(Sxx_power)
>>> Sxx_db_noNoise = maad.util.power2dB(Sxx_power_noNoise)
>>> Sxx_db_noNoise_smooth = maad.sound.smooth(Sxx_db_noNoise, std=0.5)
>>> im_mask = maad.rois.create_mask(im=Sxx_db_noNoise_smooth, mode_bin ='relative', 
                                    bin_std=8, bin_per=0.5)
>>> im_rois, df_rois = maad.rois.select_rois(im_mask, min_roi=25, max_roi=None)
>>> df_rois = maad.util.format_features(df_rois, tn, fn)

Change path to save the file containing the labels position

>>> df_to_save = maad.util.write_audacity_annot('save.txt', df_rois)

Import the wav file then the label file in Audacity