Database Interface

‘data_handling.database_interface’ module within the ketos library

This module provides functions to create and use HDF5 databases as storage for acoustic data including metadata and annotations.

An audio segment or spectrogram is said to be ‘weakly annotated’, if it is assigned a single (integer) label, and is said to be ‘strongly annotated’, if it is assigned one or several labels, each accompanied by a start and end time, and potentially also a minimum and maximum frequecy.

AudioWriter(output_file[, max_size, ...])

Saves waveform or spectrogram objects to a database file (.h5).

create_database(output_file, data_dir, ...)

Create a database from a selection table.

create_table(h5file, path, name, description)

Create a new table.

create_table_col(dtype[, shape])

Create column

filter_by_label(table, label)

Find all audio objects in the table with the specified label.

load_audio(table[, indices, table_annot, stack])

Retrieve all the audio objects in a table or a subset specified by the index_list

open_file(path, mode[, create_dir])

Open an HDF5 database file.

open_table(h5file, table_path)

Open a table from an HDF5 file.

table_description(data_shape[, data_name, ...])

Description of table structure for storing audio signals or spectrograms.

table_description_annot([freq_range])

Table descriptions for strong annotations.

write(x, table[, table_annot, id])

Write waveform or spectrogram and annotations to HDF5 tables.

write_annot(table, data_index, annots)

Write annotations to a HDF5 table.

write_audio(table, data[, attrs, id])

Write an audio object, typically a waveform or spectrogram, to a HDF5 table.

write_repres_attrs(table, x)

Writes the audio representation attributes into the HDF5 database, where they become stored as table attributes.