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

Feature.process_signal() does not fail for unsupported signal types #37

Closed
hagenw opened this issue Feb 2, 2022 · 3 comments · Fixed by #38
Closed

Feature.process_signal() does not fail for unsupported signal types #37

hagenw opened this issue Feb 2, 2022 · 3 comments · Fixed by #38

Comments

@hagenw
Copy link
Member

hagenw commented Feb 2, 2022

When you use an ONNX machine learning model, it usually expects float32 as input:

>>> model = audinterface.Process(process_func=onnx)
>>> sampling_rate = 16000
>>> signal = np.random.randn(1, 16000)
>>> model.process_signal(signal, sampling_rate)
...
InvalidArgument: [ONNXRuntimeError] : 2 : INVALID_ARGUMENT : Unexpected input data type. Actual: (tensor(double)) , expected: (tensor(float))
>>> model.process_signal(signal.astype('float32'), sampling_rate)
start   end            
0 days  0 days 00:00:01    [[0.5469817]]
dtype: object

If we use audinterface.Feature instead it works with the double signal without any issue:

>>> model = audinterface.Feature(['feature'], process_func=onnx)
>>> model.process_signal(signal, sampling_rate)
                         feature
start  end                      
0 days 0 days 00:00:01  0.546982
>>> model.process_signal(signal.astype('float32'), sampling_rate)
                         feature
start  end                      
0 days 0 days 00:00:01  0.546982

I would propose that both should behave the same way. So we need audinterface.Feature to raise an error or change audinterface.Process to not raise the error.

@frankenjoe
Copy link
Collaborator

frankenjoe commented Feb 2, 2022

I tried to replicate, but for me it fails in both cases.

Sorry, my bad. Can replicate :)

@frankenjoe
Copy link
Collaborator

frankenjoe commented Feb 2, 2022

Here is the answer: In Feature we always set channels, which means we always call audresample.remix()in preprocess_signal() and that is changing the dtype to float32. So it is basically a bug in audresample.remix().

@hagenw hagenw changed the title audinterafce.Feature.process_signal does not fail for unsupported signal types Feature.process_signal() does not fail for unsupported signal types Feb 2, 2022
@frankenjoe
Copy link
Collaborator

frankenjoe commented Feb 2, 2022

I created audeering/audresample#15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants