How librosa is automatically taking care of two channel (stereo type) audio signal?

786 views
Skip to first unread message

KRISHNA CHAUHAN

unread,
Jan 19, 2022, 1:29:07 AM1/19/22
to librosa
Hi there we have created our own audio datasets,  with a Sony recorder, and there are two channels as I can see in Matlab code. But in python when I am using librosa, there is no such problem, Code is running fine.

however I am confused how two channel and single channel data is processed. Is there any mechanism in librosa, which convert two channel to single?? If yes how it is done here?

Please guide

Vincent Lostanlen

unread,
Jan 19, 2022, 3:33:59 AM1/19/22
to KRISHNA CHAUHAN, librosa
Hello,

You should do: 

librosa.load(y, sr=None, mono=False)


to avoid automatic conversion to mono and to 22050 Hz sample rate





I hope this helps!


Vincent


--
You received this message because you are subscribed to the Google Groups "librosa" group.
To unsubscribe from this group and stop receiving emails from it, send an email to librosa+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/librosa/73ef0373-1c7f-4694-90e8-22ccb12746f2n%40googlegroups.com.

Brian McFee

unread,
Jan 19, 2022, 7:32:05 AM1/19/22
to librosa
A couple more points in addition to Vincent's response:

Librosa does provide a helper function to convert multichannel to mono: https://librosa.org/doc/latest/generated/librosa.to_mono.html and this is called automatically on load unless you explicitly opt out.

As for general processing, librosa 0.8 and earlier do not directly support multichannel processing.  However, in the upcoming 0.9 release, nearly every operation supports multichannel processing with little to no work necessary on the user's end.

I expect to put out the new release within a week or two, but if you want to try it out early, the current version on github already includes these changes.

KRISHNA CHAUHAN

unread,
Jan 20, 2022, 12:39:39 AM1/20/22
to librosa
thank you both :). But when I tried

X, sample_rate = librosa.load(file_name,sr=44100,mono=False)

I am getting this error:

Invalid shape for monophonic audio: ndim=2, shape=(2, 152064)

KRISHNA CHAUHAN

unread,
Jan 20, 2022, 12:45:15 AM1/20/22
to librosa
oh sorry I should write

 mono=True

so I think mono=True is default as per @Brian sir?
Sir another query is what technique is used to make double channel to single here, I mean average of channels  first or second channel, or max of both?
Reply all
Reply to author
Forward
0 new messages