Skip to content

Error in wfdb_to_wav #410

Done
Done

Description

@dmerinodel

Hi everyone,

this is my first time writing an issue as well as using wfdb so, excuse me in advance for the mistakes I'll surely make :)

I'm trying to obtain some .wav from the data stored in VOICED database with the following piece of code:

import wfdb.io.convert.wav
import os

path = 'my_path'
wfdb.io.convert.wav.wfdb_to_wav('voice001', pn_dir='voiced',
                                output_filename=os.path.join(path, 'aaab.wav'))

Thus, I obtain the following error:

Traceback (most recent call last):
File "path_of_my_script", line 18, in
wfdb.io.convert.wav.wfdb_to_wav('voice001', pn_dir='voiced',
File "C:[...]\AppData\Local\Programs\Python\Python310\lib\site-packages\wfdb\io\convert\wav.py", line 121, in wfdb_to_wav
np.left_shift(np.subtract(record.adc(), offset), shift)
File "C:[...]\AppData\Local\Programs\Python\Python310\lib\site-packages\wfdb\io_signal.py", line 578, in adc
nanlocs = np.isnan(self.p_signal)
TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

At first I thought that I was messing it up and went to the documentation page. I ended up realizing that if I try to run the example piece of code that appears for wfdb_to_wav:

wfdb_to_wav('100', pn_dir='pwave')

I obtain the same error as my code's. I did some research and some people has the same 'TypeError: ufunc 'isnan' not supported...' in other context, they managed to fix it using pandas instead of numpy, but it doesn't work for me. Any idea of why is this happening?

Activity

  1. bemoody commented on Jul 22, 2022

    @bemoody
    Collaborator
  2. dmerinodel commented on Jul 25, 2022

    @dmerinodel
    Author

    I tried with smooth_frames=True and my code runs, but the .wav that generates doesn't make any sound. I guess it's not that easy :) thanks!

  3. tompollard commented on Nov 23, 2026

    @tompollard
    Member

    Fixed: wfdb_to_wav now reads the record with smooth_frames=True. Please reopen if you still see the error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions