fgnt/padertorch

Error in tbx_utils.py

mdelcroix opened this issue · 1 comments

/padertorch/padertorch/summary/tbx_utils.py, line 145, in audio
signal *= 0.95
ValueError: output array is read-only
I think it happens when there are zero signals.

The current code is like

    if normalize:
        denominator = np.max(np.abs(signal))
        if denominator > 0:
            signal = signal / denominator
        signal *= 0.95

I think it should be:

    if normalize:
        denominator = np.max(np.abs(signal))
        if denominator > 0:
            signal = signal / denominator
            signal *= 0.95

@boeddeker could you check it?

Thank you for reporting this bug.
I created a PR to fix that #30 (i.e. implement your suggestion).

You are right, this happens, when you report a CPU tensor that contains only zeros.
The reason is, that a pytorch CPU tensor and a numpy array can share the data.