How do I select one audio channel from a multichannel array in librosa?

miguelairs

miguelairs

Posted on June 17, 2021

How do I select one audio channel from a multichannel array in librosa?

I am new to librosa (and python in general) and I am getting started with audio analysis. My starting wav files contain multichannel arrays. I am wondering if I can use librosa to choose a single, specific channel. As of now, I convert my files to mono as shown here:


Hi all!
I am new to librosa (and python in general) and I am getting started with audio analysis. My starting wav files contain multichannel arrays. I am wondering if I can use librosa to choose a single, specific channel. As of now, I convert my files to mono as shown here:
import librosa

y, sr = librosa.load(file, sr=None, mono=True)
Enter fullscreen mode Exit fullscreen mode

However, I suspect that mono=True averages the channels instead of selecting individually. Please correct me if I am wrong! I know that SciPy allows individual channel selection:

from scipy.io import wavfile

sample_rate, data = wavfile.read(file)
#[:,1] slices the channel array
spectrum, freqs, t, im = plt.specgram(data[:,1], Fs=sample_rate))
Enter fullscreen mode Exit fullscreen mode

How can I slice and select an individual channel like that in librosa?

Many thanks! Much help is greatly appreciated!

💖 💪 🙅 🚩
miguelairs
miguelairs

Posted on June 17, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related