signal_index()

audinterface.utils.signal_index(starts=None, ends=None)[source]

Create signal index.

Returns a segmented index like audformat.segmented_index(), but without the 'file' level. Can be used with the following methods:

Parameters
Return type

MultiIndex

Returns

index with start and end times

Raises

ValueError – if start and ends differ in size

Examples

>>> signal_index(0, 1.1)
MultiIndex([('0 days', '0 days 00:00:01.100000')],
           names=['start', 'end'])
>>> signal_index("0ms", "1ms")
MultiIndex([('0 days', '0 days 00:00:00.001000')],
           names=['start', 'end'])
>>> signal_index([None, 1], [1, None])
MultiIndex([(              NaT, '0 days 00:00:01'),
            ('0 days 00:00:01',              NaT)],
           names=['start', 'end'])
>>> signal_index(
...     starts=[0, 1],
...     ends=pd.to_timedelta([1000, 2000], unit="ms"),
... )
MultiIndex([('0 days 00:00:00', '0 days 00:00:01'),
            ('0 days 00:00:01', '0 days 00:00:02')],
           names=['start', 'end'])
>>> signal_index([0, 1])
MultiIndex([('0 days 00:00:00', NaT),
            ('0 days 00:00:01', NaT)],
           names=['start', 'end'])
>>> signal_index(ends=[1, 2])
MultiIndex([('0 days', '0 days 00:00:01'),
            ('0 days', '0 days 00:00:02')],
           names=['start', 'end'])