Python API

Note

The whole library is accessible by importing the h5features module.

import h5features

Item

class h5features.Item(self, name: str, features: ndarray[dtype=float64, shape=(*, *), order='C', writable=False], times: ndarray[dtype=float64, order='C', writable=False], properties: dict | None = None)

Handle the features of a single item (e.g. a speech signal).

features(self) numpy.ndarray[dtype=float64, shape=(*, *), order='C']

The item’s features.

times(self) numpy.ndarray[dtype=float64, shape=(*, *), order='C']

The item’s timestamps.

property name str

The name of the item.

property dim int

The dimension of the features.

property size int

The number of vectors in the features.

property properties dict

The item’s properties.

Writer

class h5features.Writer(self, filename: str | os.PathLike, *, group: str = 'features', overwrite: bool = False, compress: bool = False, version: Version = Version.v2_0)

Write Item instances to an HDF5 file.

write(self, item: Item) None
write(self, items: collections.abc.Sequence[Item]) None

Overloaded function.

  1. write(self, item: h5features._core.Item) -> None

Write an Item to disk.

  1. write(self, items: collections.abc.Sequence[h5features._core.Item]) -> None

Write a sequence of Item to disk in parallel.

property filename str

The HDF5 file name.

property groupname str

The HDF5 group name.

property version Version

The h5features format Version being written.

Reader

class h5features.Reader(self, filename: str | os.PathLike, *, group: str = 'features')

Read Item instances from an HDF5 file.

read(self, name: str, *, ignore_properties: bool = False) Item

Read an Item from the HDF5 file.

read_all(self, *, ignore_properties: bool = False) list[Item]

Read all the items stored in the file.

read_partial(self, name: str, start: float, stop: float, *, ignore_properties: bool = False) Item

Partial read of an Item within the time interval [start, stop].

items(self) list[str]

The name of stored items.

list_groups(filename: str | os.PathLike) list[str]

Return the list of groups in the specified HDF5 file.

property filename str

The name of the file being read.

property groupname str

The name of the group being read in the file.

property version Version

The Version of the h5features data in the group.

Version

enum h5features.Version(value)

The different h5features format versions.

This is not the version of the h5features library but the available versions of the underlying file format.

Valid values are as follows:

v1_0 = Version.v1_0
v1_1 = Version.v1_1
v1_2 = Version.v1_2
v2_0 = Version.v2_0