Rabia Ahmad
Rabia Ahmad

Reputation: 99

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

Upvotes: 4

Views: 9261

Answers (1)

Warren Weckesser
Warren Weckesser

Reputation: 114831

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)

Upvotes: 5

Related Questions