Hi everybody,
I have been trying to solve the following problem for the last couple of months, but as of yet have not succeeded. I have been successfully running several experiments using an external voicekey (Reacsys vkms-1) and the parallel port with varying PsychoPy versions. Since the voicekey only registers the latency of the response, and the content and the accuracy has to be coded from experimenters (which is far from an easy task), we want to double-check the accuracy of the coding. Thus, in addition to the parallel port voicekey, we wanted to record the trials. We were thus really happy with the development of the voicekey()-function. However, in a large number of sessions, the experiment randomly crashes. Most of the times, we only get the windows message âpythonw.exe has stopped workingâ. Rarely, at least when we end the experiment prematurely, we get the following error message:
portaudio error in Pa_AbortStream: Wait timed out
portaudio error in Pa_AbortStream: PortAudio not initialized
portaudio error in Pa_CloseStream: PortAudio not initialized
portaudio error in Pa_Terminate: PortAudio not initialized
Error closing audio backend.
Exception TypeError: ââNoneTypeâ object is not callableâ in <bound method Server.del of pyolib.server.Server object at 0x17FD5F30 ignored
Importantly, in the majority of sessions, the experiment works well and the PsychoPy recordings and the results from the external voicekey converge rather nicely. We are now using PsychoPy 1.84.2 on a Windows 7 SP1 pc, but the problem also occurs with older PsychoPy and Windows versions.
Oh, and I am under the impression that the experiment is especially likely to crash when there are noises before the initialization of vk.start(). I have played around with starting voicekey.pyo.init() later, but that didnât do the trick either.
From other threads, I get the impression that this might be caused by pyo â but in this case, I canât change that to pygame, correct?
I would very much appreciate any help! I have attached the relevant pieces of code below (hopefully- I have deliberately only deleted some parts of the runTrial() to enable a better understanding- if this is still too much, let me know and I will delete more).
Best,
Manuel
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from psychopy import visual
from psychopy import core, event, misc, logging, gui, data, parallel, monitors, voicekey
from psychopy import sound, microphone
from operator import itemgetter
import fragebogen, vragenlijst
import pyglet
import os, itertools
import codecs
import random
import copy
#...
if mode==1:
port = parallel.PParallelInpOut32(address=0xD010)
#...
def voice_key():
return port.readPin(10)
def get_code():
quit=0
response = event.waitKeys(maxWait='inf',keyList=["num_1","num_2","num_3","num_4","num_5","lctrl"], timeStamped=False)[0]
# response = event.waitKeys(maxWait='inf', timeStamped=False)[0]
if response=="lctrl":
response=event.waitKeys(maxWait='inf',keyList=["num_1","num_2","num_3","num_4","num_5","b","q"], timeStamped=False)[0]
if response=="b":
quit=-1
elif response=="q":
core.quit()
return response,quit
def runTrial(trial,count):
ITI=random.randint(500,1500)
ITI_in_SEC=float(ITI)/1000.0
for frameN in range(all_time+1):
if trial["onset"]==0:
if frameN==all_time:
if trial["type"]==0:
blue.draw()
else:
green.draw()
else:
if frameN<=all_time:
if trial["type"]==0:
blue.draw()
else:
green.draw()
if frameN<fix:
fixation.draw()
if frameN==all_time:
target.draw()
myWin.flip()
if frameN==all_time:
print count
trialClock.reset()
vk.start()
while (trialClock.getTime()<3.0) and (trial["rt"]==-1):
if mode == 1:
if voice_key()==1:
trial["rt"]=trialClock.getTime()
elif mode== 0:
event.waitKeys(maxWait= 3.0,keyList="space")
trial["rt"]=trialClock.getTime()
if trial["rt"]==-1:
trial["rt"]=3.0
blue.setAutoDraw(False)
green.setAutoDraw(False)
myWin.flip()
event.clearEvents()
response,quit=get_code()
trial["resp"] = list(response)[-1]
print vk.event_detected, vk.event_onset, trialClock.getTime()
trial["virt"]=vk.event_onset
minT=0
if vk.event_onset < 0.1:
minT=1.5
else:
minT=1.0
while trialClock.getTime() - vk.event_onset < minT:
qx=0
trialClock.reset()
print trial
vk.stop()
return quit