PYNQ: PYTHON PRODUCTIVITY

Playing simple audio

Hello,

I am running this code:
from pynq.overlays.base import BaseOverlay import numpy as np base = BaseOverlay("base.bit") pAudio = base.audio pAudio.set_volume(20) pAudio.select_line_in() pAudio.bypass(seconds=5) pAudio.buffer = np.zeros(13158 ).astype(np.int) # Tried to see if I could adjust the buffer size pAudio.load("/home/xilinx/jupyter_notebooks/Brando/C.wav") pAudio.play()

I am getting this output:

---------------------------------------------------------------------------
error                                     Traceback (most recent call last)
<ipython-input-5-5f6a903a2b69> in <module>()
      7 pAudio.bypass(seconds=5)
      8 pAudio.buffer = np.zeros(680080).astype(np.int)
----> 9 pAudio.load("/home/xilinx/jupyter_notebooks/Brando/C.wav")
     10 pAudio.play()

/usr/local/lib/python3.6/dist-packages/pynq/lib/audio.py in load(self, file)
    592             self.sample_len = wav_file.getnframes()
    593         byte_format = ('%ds' % 3) * self.sample_len * 2
--> 594         samples_4byte = b'\x00'.join(struct.unpack(byte_format, samples_3byte))
    595         samples_4byte += b'\x00'
    596         self.buffer = numpy.fromstring(samples_4byte, dtype='<u4')

error: unpack requires a buffer of 13158 bytes
```

I downsampled the C.wav to 1000 Hz with a resolution of 8 bits.  Any ideas of what I could do?

Best,
Brando

Here is the audio file: