duration()

audformat.utils.duration(obj, *, root=None, num_workers=1, verbose=False)[source]

Total duration of all entries present in the object.

The object might contain a segmented or a filewise index. For a segmented index the duration is calculated from its start and end values. If an end value is NaT or the object contains a filewise index the duration is calculated from the media file by calling audiofile.duration().

Parameters
  • obj (Union[Index, Series, DataFrame]) – object conform to table specifications

  • root (Optional[str]) – root directory under which the files referenced in the index are stored. Only relevant when the duration of the files needs to be detected from the file

  • num_workers (int) – number of parallel jobs. Only relevant when the duration of the files needs to be detected from the file If None will be set to the number of processors on the machine multiplied by 5

  • verbose (bool) – show progress bar. Only relevant when the duration of the files needs to be detected from the file

Return type

Timedelta

Returns

duration

Examples

>>> index = segmented_index(
...     files=["a", "b", "c"],
...     starts=[0, 1, 3],
...     ends=[1, 2, 4],
... )
>>> duration(index)
Timedelta('0 days 00:00:03')