Can't reproduce audio file using python pyo library

85 views Asked by At

I'm testing pyo library and I can't reproduce any audio file. Here's the sample code:

from pyo import *

s = Server().boot()

path = SNDS_PATH + r"/05.Black Alien - Take Ten"

sf = SfPlayer(path, speed=[1, 0.995], loop=True, mul=0.4).out()

s.gui(locals())

I keep getting this error:

Traceback (most recent call last):
  File "D:/UFPA/2022.2/Programação I/SpotifyPremiumMelhorado1/main.py", line 7, in <module>
    sf = SfPlayer(path, speed=[1, 0.995], loop=True, mul=0.4).out()
  File "D:\UFPA\2022.2\Programação I\SpotifyPremiumMelhorado1\venv\lib\site-packages\pyo\lib\players.py", line 116, in __init__
    _snd_size, _dur, _snd_sr, _snd_chnls, _format, _type = sndinfo(path[0])
TypeError: cannot unpack non-iterable NoneType object
1

There are 1 answers

0
CristiFati On

The problem is that sndinfo could not get file info. Are you sure the path is correct (the extension is missing)? You could verify it by os.path.isfile(path).

PyO produces a misleading error / stacktrace.
To fix that, I submitted [GitHub]: belangeo/pyo - Raise exception on error (merged on 220930 (after a few additional commits)).
Check [SO]: How to change username of job in print queue using python & win32print (@CristiFati's answer) (at the end) for possible ways to go further.