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
starts (
Union
[float
,int
,str
,Timedelta
,Sequence
[Union
[float
,int
,str
,Timedelta
]],None
]) – segment start positions. Time values given as float or integers are treated as secondsends (
Union
[float
,int
,str
,Timedelta
,Sequence
[Union
[float
,int
,str
,Timedelta
]],None
]) – segment end positions. Time values given as float or integers are treated as seconds
- Return type
- Returns
index with start and end times
- Raises
ValueError – if
start
andends
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'])