A word about pyo (audio backend)

Hi there, I am new to Psychopy and python coding. I am using Psychopy3 for a psychology EEG study. It is a language comprehension study where I am presenting the subjects with word pairs in a prime-target fashion (i.e. dog-cat, you-card, mom-dad) and so on. I get no error message when I run the experiment. However, some words are not fully heard. They are abruptly cut in the middle/before they end. The experiment runs fully and with no stops. It is just that some words are cut randomly, but then it proceeds fine to the next word. I noticed that those words are usually the longer ones for some reason (i.e. inexpensive, migraine etc.). My supervisor and I tried different things regarding that matter but it stills seems to be a problem. My trial loop is random so sometimes the words being cut are not the same as before. Do you reckon this is because of a bug in the programme which can be solved easily? Is there something I can do about it (would it help downloading the recent version of pyo or downgrading the psychopy?)

Thanks in advance for any help

Hi Cleopetra,
I was wondering if you were able to resolve this issue. I am designing a similar task and I keep getting the same error about closing audio backend. In study, it is a picture naming task where participants are presented with pictures that they have to name. The program seems to be working fine but I am really not sure how to solve this error.

Hello,

I’d advise everyone with such audio issues to upgrade to the latest version of PsychoPy (> 3.2). Version 3.2 introduced a new PTB audio backend that was ported from the PsychToolbox project. It is much more reliable than the variety of other third party backends that we have had to rely upon before.

Hi Michael,

Thanks very much for responding. I am actually using 3.2.1 after receiving an email about the latest release. Maybe it has to do with the Hardware settings ? I am attaching a screenshot of my settings.

Hi Oliver,

I am trying to get pro to play in Windows with ASIO card and I installed pyo and ASIO on the machine but then when I ran the test script that you recommend:
“”"
Windows audio host inspector.

This script will check if pyo can run in duplex mode (both audio input and output)
and will test every host API to help the user in making his audio device choice.

“”"
import sys, time
from pyo import *

if sys.platform == “win32”:
host_apis = [“mme”, “directsound”, “asio”, “wasapi”, “wdm-ks”]
else:
print(“This program must be used on a windows system! Ciao!”)
exit()

print("* Checking for any available audio input… *")

input_names, input_indexes = pa_get_input_devices()

print("* Checking audio output hosts… *")

s = Server(duplex=0)
s.verbosity = 0

host_results = []
for host in host_apis:
print("* Testing %s… *" % host)
try:
s.reinit(buffersize=1024, duplex=0, winhost=host)
s.boot().start()
a = Sine(freq=440, mul=0.2).out()
time.sleep(2)
s.stop()
s.shutdown()
host_results.append(True)
except:
host_results.append(False)

print("\nResults")
print("-------\n")

if len(input_names):
print(“Duplex mode OK!”)
print(“Initialize the Server with duplex=1 as argument.\n”)
else:
print(“No input available. Duplex mode should be turned off.”)
print(“Initialize the Server with duplex=0 as argument.\n”)

for i, host in enumerate(host_apis):
if host_results[i]:
print(“Host: %s ==> OK!” % host)
else:
print(“Host: %s ==> Failed…” % host)

print(“Initialize the Server with the desired host given to winhost argument.”)

print("\nFinished!")

I get the error message stating that the “pa_get_input_devices()” is not defined. What does it mean? and what do I do next? I am quite new to Python and psychoPy so any detailed help you can provide will be appreciated.

Thanks,
Ana

Hi,

How did you install pyo? And how do you run the python script? If the line

from pyo import *

does not give an error, then pa_get_input_devices() should exist…

Olivier

Sorry, I missed your reply @Roaa. It looks like you manually need to insert 'PTB', at the start of list of audio libraries in your hardware settings.

Michael, thanks very much! I now have only ‘pyo’ and ‘sounddevice’ libraries in my hardware settings and everything is working. I still get an error message though but all of my data are and files are saved securely.
I just have one related question please. In my experiment, I want to mark the presentation of every visual stimulus with a beep sound. For that, I have created high frequency beeps that I will play with each picture.
The problem is : that beep sound never gets recorded, although I hear it when I run the experiment, and I can see that is being presented.