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

Assertion Error: pyroomacoustics.build_rir.fast_rir_builder #205

Closed
ghost opened this issue Jan 11, 2021 · 11 comments
Closed

Assertion Error: pyroomacoustics.build_rir.fast_rir_builder #205

ghost opened this issue Jan 11, 2021 · 11 comments

Comments

@ghost
Copy link

ghost commented Jan 11, 2021

File "...\Anaconda3\lib\site-packages\pyroomacoustics\soundsource.py", line 254, in get_rir
fast_rir_builder(ir, time, alpha, visibility.astype(np.int32), Fs, fdl)
File "pyroomacoustics\build_rir.pyx", line 53, in pyroomacoustics.build_rir.fast_rir_builder
AssertionError

Hi there,
Any idea what might lead to the above error message?

@fakufaku
Copy link
Collaborator

Hi @moonlightSong , thanks for reporting the error. Can you please provide the OS, python version, platform, and how you installed the package ? Thanks!

@ghost
Copy link
Author

ghost commented Jan 12, 2021

@fakufaku Thanks for reply.
The OS is Windows 10. The python version is python 3.7. The platform is conda 4.9.2. Install is by pip.
The error message is given by pyroomacoustics 0.4.2. For some setup it works and for some it prints the error. In the later case, pyroomacoustics 0.3.1 fails quietly.
The setup is
room_x, room_y, room_z = 8.59, 6.46, 3.20
micL_x, micL_y = 4.36, 3.24
micR_x, micR_y = 4.50, 3.28
mic_z = 0.97
s1_x, s1_y, s1_z = 4.04, 2.48, 1.00
s2_x, s2_y, s2_z = 5.39, 2.44, 1.62
t60 = 0.44

compute_rir is given by:
def compute_rir(self):

    self.rir = []
    self.visibility = None

    self.image_source_model()

    for m, mic in enumerate(self.mic_array.R.T):
        h = []
        for s, source in enumerate(self.sources):
            h.append(source.get_rir(mic, self.visibility[s][m], self.fs, self.t0)[:self.max_rir_len])
        self.rir.append(h)

@fakufaku
Copy link
Collaborator

Thank you very much for providing the extra information.
This seems to be an error with the cython code that builds the RIR from the information about the echo delays and amplitudes. I think this may happen if the source and the microphones are too close (which would be a bug of course, since all cases should be covered). Is it possible for you to check if the failing cases have the smallest distance between sources and microphones ?

@ghost
Copy link
Author

ghost commented Jan 13, 2021

In

def compute_rir(self):

at this line
# we add the delay due to the factional delay filter to

the time is adjusted.
When use room.compute_rir() directly instead of rewrite it like posted above, the code doesn't complain.

In

def get_rir(self, mic, visibility, Fs, t0=0., t_max=None):

time is not adjusted.

so it seems that get_rir() is causing the problem because it didn't adjust the time.

@fakufaku
Copy link
Collaborator

Sorry for coming back so late to this issue. Indeed, the code in soundsource is something left-over from the previous implementation of the Room class.
In recent version of pyroomacoustics, the preferred way to get the room impulse response is via the Room class, see the doc here.

@ghost
Copy link
Author

ghost commented Feb 16, 2021 via email

@c-ma13
Copy link

c-ma13 commented Jan 2, 2022

Thank you so much. You really helped me.
I add the same time delay when using get_rir(), and looks like it worked when generating WHAMR! dataset.

In

def compute_rir(self):

at this line

# we add the delay due to the factional delay filter to

the time is adjusted.
When use room.compute_rir() directly instead of rewrite it like posted above, the code doesn't complain.
In

def get_rir(self, mic, visibility, Fs, t0=0., t_max=None):

time is not adjusted.
so it seems that get_rir() is causing the problem because it didn't adjust the time.

@SilentIcyMoon
Copy link

I meet the same error when I generating the reverberation based on WHAMR! scripts.
I am still unclear how to fix the issue. Could you please explain how to add the "same time delay"? and what is the "same time dealy"? Thank you!

@fakufaku
Copy link
Collaborator

Hi @SilentIcyMoon
To generate whamr! using the original script you need to use an old version of pyroomacoustics.
According to the requirements.txt provided with the generation scripts, you need 0.3.1.

pyroomacoustics==0.3.1
SoundFile==0.10.3.post1
pandas==1.1.2
scipy==1.5.2
numpy==1.19.1
pyloudnorm==0.1.0

@SilentIcyMoon
Copy link

SilentIcyMoon commented May 30, 2024

Hi @fakufaku
Thank you so much for your information!
I followed your suggestion to re-install the required modules. And I met the following new error:

RuntimeError: module compiled against API version 0xf but this version of numpy is 0xd
C-extension libroom unavailable. Falling back to pure python
C-extension libroom unavailable. Falling back to pure python
Traceback (most recent call last):
File "create_wham_from_scratch.py", line 167, in
create_wham(args.wsj0_root, args.wham_noise_root, args.output_dir)
File "create_wham_from_scratch.py", line 71, in create_wham
room.generate_rirs()
File "/home/joschi/Downloads/Data/wham_noise/whamr_scripts/wham_room.py", line 52, in generate_rirs
self.compute_rir()
File "/home/joschi/Downloads/Data/wham_noise/whamr_scripts/wham_room.py", line 44, in compute_rir
h.append(source.get_rir(mic, self.visibility[s][m], self.fs, self.t0)[:self.max_rir_len])
File "/home/joschi/Dokumente/espnet-master/tools/anaconda/envs/myenv/lib/python3.8/site-packages/pyroomacoustics/soundsource.py", line 233, in get_rir
fast_rir_builder(ir, time, alpha, visibility, Fs, fdl)
File "pyroomacoustics/build_rir.pyx", line 14, in pyroomacoustics.build_rir.fast_rir_builder
ValueError: Buffer dtype mismatch, expected 'int' but got 'bool'

And I further solved the above issue by changing the versions of some modules, now I share the modules' versions being used now based on my situation:
python==3.10.14
cython==0.29.30
pyroomacoustics==0.3.1
SoundFile==0.10.3.post1
pandas==2.2.2 (new)
scipy==1.13.1 (new)
numpy==1.22.4 (new)

I hope these information will be helpful for someone who is facing the same issue.
In addition, I find a useful link can refer:
asteroid-team/asteroid#613

@fakufaku
Copy link
Collaborator

@SilentIcyMoon thanks for reporting back! The version is pretty old so I am not surprised there are some problems with the compilation 😭
Happy you solved it and it is good to have the information here now! 🤗

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

No branches or pull requests

3 participants