I am creating a fMRI Experiment with the Psychopy Libary in Phycharm and need to implement Sound from .wav files and play them.
This is my Code:
import numpy as np
from scipy.io.wavfile import read, write
from psychopy import prefs
prefs.hardware['audioLib'] = ['PTB']
from psychopy import sound
AMP = .1
audio_path = r'*PATH*/IRN_61.7354Hz.wav' #The Path where I saved the .wavfile
sr, data = read(audio_path)
data_1=data*(AMP/np.max(np.abs(data)))
acoustic_stim = sound.Sound(bytes(data_1),sr, stereo=True)
acoustic_stim.play(when=1)
#------------------------------------------------------------------------------ And I always get this Error: File "PATH", line 20, in acoustic_stim.play() File "PATH\venv\lib\site-packages\psychopy\sound\backend_ptb.py", line 544, in play self.track.start(repetitions=loops, when=when)
AttributeError: 'NoneType' object has no attribute 'start' #------------------------------------------------------------------------------ No Matter how i change this argument in acoustic_stim.play() i get the same error. i even tried to make something happen with creating a window and win.flip() but it doesn't work.