Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sounddevice.PortAudioError: Error opening OutputStream: Invalid number of channels

My code is:

import scipy.io as sio
import sounddevice as sd
xx= sio.loadmat('C:\\Users\\dell\\Desktop\\Rabia Ahmad spring 2016\\FYP\\1. Matlab Work\\record work\\aa.mat')['aa']
sd.play(xx,64000)

I got the error sounddevice.PortAudioError: Error opening OutputStream: Invalid number of channels

like image 795
Rabia Ahmad Avatar asked Oct 16 '25 17:10

Rabia Ahmad


1 Answers

In a comment, you said that xx has shape (1, 4999). sounddevice.play is interpreting this as a single sample with 4999 channels!

Try transposing the array, so play sees the array as 4999 samples of a signal with 1 channel:

sd.play(xx.T, 64000)
like image 135
Warren Weckesser Avatar answered Oct 18 '25 06:10

Warren Weckesser



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!