Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
hagenw opened this issue Jul 28, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@hagenw
Copy link
Member

hagenw commented Jul 28, 2023

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
@hagenw hagenw added the bug Something isn't working label Jul 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant