Skip to content

Process function does not work with segmentation object that returns smaller end than start values #147

@hagenw

Description

@hagenw

Let's consider the following code:

import audinterface
import audiofile
import numpy as np

sampling_rate = 8000
signal = np.concatenate(
    [np.zeros((1, 8000)), np.ones((1, 8000))],
    axis=1,
)
file = 'file.wav'
audiofile.write(file, signal, sampling_rate)

segment = audinterface.Segment(
    process_func=lambda x, sr:
    audinterface.utils.signal_index(1, 0)
)
process = audinterface.Process(segment=segment)

It defines a segmentation object that returns start and end values in a wrong order,
but still not totally meaning less:

>>> segment.process_file(file)
MultiIndex([('file.wav', '0 days 00:00:01', '0 days')],
           names=['file', 'start', 'end'])

If this is used as a segment object inside audinterface.Process it will process a segment with 1 duration, it reads the segment at the correct position, but returns wrong timestamps:

>>> process.process_file(file)
file      start            end            
file.wav  0 days 00:00:01  0 days 00:00:02    [[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,...
dtype: object

Expected behavior would have been:

>>> process.process_file(file)
file      start            end            
file.wav  0 days 00:00:00  0 days 00:00:01    [[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,...
dtype: object

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions