problem with recording sounds with mic

151 views
Skip to first unread message

Du DU

unread,
Apr 14, 2016, 10:14:07 AM4/14/16
to psychopy-users
Hi there!

I am using PsychoPy v1.83.04 on OS X 10.8. I set up an experiment in builder that involves using a mic to record the responses of my test persons automatically from the onset of the related items.

I receive the following error when trying to run the experiment:

############## Running: /Users/apple/Desktop/probe_mic_lastrun.py ##############
2016-04-14 16:07:16.496 python[12312:707] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to /var/folders/13/b151w6fn5jv4_mfclzl95xt80000gn/T/org.psychopy.PsychoPy2.savedState
Traceback (most recent call last):
  File "/Users/apple/Desktop/probe_mic_lastrun.py", line 11, in <module>
    from psychopy import locale_setup, visual, core, data, event, logging, sound, gui, microphone
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/microphone.py", line 1015
    if pyo.serverCreated():
     ^
SyntaxError: invalid syntax

This is the related code:

    # imports pyo, creates sound.pyoSndServer using sound.initPyo() if not yet created
    t0 = core.getTime()
    try:
        global pyo
        import pyo
        global haveMic
        haveMic = True
    if pyo.serverCreated():
        sound.pyoSndServer.setSamplingRate(sampleRate)
    else:
        #sound.initPyo() will create pyoSndServer. We want there only ever to be one server
        sound.initPyo(rate=sampleRate) #will automatically use duplex=1 and stereo if poss
    if outputDevice:
        sound.pyoSndServer.setOutputDevice(outputDevice)
    if bufferSize:
        sound.pyoSndServer.setBufferSize(bufferSize)
    logging.exp('%s: switch on (%dhz) took %.3fs' % (__file__.strip('.py'), sampleRate, core.getTime() - t0))

Could someone tell me how can I fix the problem since I have no idee what is wrong with the syntax?

Thanks in advance for any thoughts!!

Dudu

Jeremy Gray

unread,
Apr 14, 2016, 10:26:07 AM4/14/16
to psychop...@googlegroups.com
That's quite odd. It looks like your copy of the file microphone.py has been corrupted somehow, and is missing a few lines. The syntax error is that the code has a try: statement with no corresponding except: statement.

The missing lines are

except ImportError:  # pragma: no cover
msg = ('Microphone class not available, needs pyo; '
'see http://code.google.com/p/pyo/')
logging.error(msg)
raise ImportError(msg)

You can edit the file to add those lines back in, or download the whole file from here: https://raw.githubusercontent.com/psychopy/psychopy/master/psychopy/microphone.py. Or just re-install PsychoPy if that's easier.

--Jeremy

--
You received this message because you are subscribed to the Google Groups "psychopy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to psychopy-user...@googlegroups.com.
To post to this group, send email to psychop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/psychopy-users/797e4660-7a86-45ee-8692-8aad2a903981%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages