3

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

Toto
  • 89,455
  • 62
  • 89
  • 125
Rabia Ahmad
  • 89
  • 1
  • 2
  • 5

1 Answers1

4

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)
Warren Weckesser
  • 110,654
  • 19
  • 194
  • 214