LCAV / pyroomacoustics

Pyroomacoustics is a package for audio signal processing for indoor applications. It was developed as a fast prototyping platform for beamforming algorithms in indoor scenarios.
https://pyroomacoustics.readthedocs.io
MIT License
1.35k stars 419 forks source link

Singular matrix error #16

Closed pathasreedhar closed 6 years ago

pathasreedhar commented 6 years ago

Hi While running for linear array..many times it gives singular matrix error in almost all of the algorithms.. what care should we take while recording..

fakufaku commented 6 years ago

Hi, it would be easier to help if you post the code that you are trying to run. I know that many of the algorithm require a small value of the noise variance to work, it acts as regularization and avoid the singular matrix problem. Without knowing what you are running, it is difficult to give better advice.

pathasreedhar commented 6 years ago

Thanks for the prompt reply.. I am running doa_algorithms.py with PS3eye data. I recorded the signal in my office where there is a constant AC buzz and fellow colleagues were talking apart from 2 speakers who are intended. I think this acts fairly as noise, I also saw the wav files in audacity there is no absolute zero in it, and fair noise amount is present. It generally fails for FRIDA CSSM WAVES algo

fakufaku commented 6 years ago

Hi, I see, so the error happens while running the doa ? I thought that happened during beamforming, hence my comment about the noise. Of course, noise will be present in natural signals, so that is normally not an issue. Again, copy pasting the code would help a lot to debug. I know FRIDA sometimes pops some errors, but it normally does not affect the result too much. FRIDA can be sensitive to the choice of the subbands. You need to pick the subbands that match the inter-microphone spacing of your array. CSSM and WAVES are also not very robust in my experience and can be finicky to tune.

fakufaku commented 6 years ago

With correct tuning, I'm pretty confident FRIDA should work as we have run it multiple time during live demoes and it was very robust, even in very noisy environment.

pathasreedhar commented 6 years ago

Ok thank you can you point out me where to look for the parameters and what parameters for tuning FRIDA?

fakufaku commented 6 years ago

Hi @pathasreedhar , here is the configuration I use in the example: https://github.com/LCAV/pyroomacoustics/blob/master/examples/doa_algorithms.py#L63 in particular the fft_bins parameter should be set according to the array you are using.

pathasreedhar commented 6 years ago

Thank you for pointing out. I would like to know whether this code works for any number of sources? because while i was trying for different number of sources many times it would give only 2 directions. i have sent the number of sources as parameter

fakufaku commented 6 years ago

Hi @pathasreedhar , it is much easier to help if you paste the code that you are trying to run. FRIDA might return less sources than desired if they can't be found reliably. How many sources are you looking for ?

pathasreedhar commented 6 years ago

Hi, I am running doa_algorithms.py with few changes like 1) my own wav files 2) array R = np.array([[-0.03,0.0],[-0.01,0.0],[0.01,0.0],[0.03,0.0]]), R = R.T 3) doa.locate_sources(X, num_src=num_src,freq_range=freq_range), where num_src = 3, freq_range = [2500.0,4500.0] I did only these changes and code gives singular matrix error for many algos and for MUSIC it gives only 2 sources. i tried many wav files but result is same like error and few sources. I would like to know why the output locations are symmetric in my condition?

pathasreedhar commented 6 years ago

my wav files are sampled at 44100. Does it matter?

jay-pee commented 6 years ago

I think the sample rate doesn't matter because with freq_range you later restrict the range which the DOA algorithm is working with.

I had also this issue quite often, when I tried it. I would suggest to introduce a diagonal loading before the inversion. You can find a little bit more to this topic here.

pathasreedhar commented 6 years ago

ok thanks for input. I dont get 3 sources as output but when I give 4 sources as input the algo locates 4 sources. Why this weird thing happens despite of any other changes in code

fakufaku commented 6 years ago

Hi @pathasreedhar ,

  1. You are using a linear array. At best you can locate the sources in a half-plane, that is you can find the azimuth up to a symmetry with respect to the axis of the array.
  2. You are operating in 3D space (by providing 3D coordinates).

I am not sure how FRIDA handles linear array. But MUSIC or SRP-PHAT should give you something at least. Both of them operate a grid search to find the most likely locations. You can solve the two above problems by:

  1. Reduce the dimensionality to 2D by providing 2D coordinates for your array
  2. You need to provide a list of candidate locations for the DOA. By default, the azimuth location are 0 to 359 in 1 degree increments. You should change this to 0 to 180 degrees. The relevant parameter is azimuth (see the doc here).
  3. You should try to plot the spatial spectrum to inspect it and check if you can see the three peaks corresponding to the sources.

Note that both SRP-PHAT and MUSIC work by estimating the spatial spectrum and then find num_src peaks in the estimated locations.

pathasreedhar commented 6 years ago

Hi sorry for delayed reply.. thanks for the help I was able to use this by tweaking azimuth parameter.

fakufaku commented 6 years ago

Great!