I am new to psychopy and python, so please excuse my lack of knowledge. I am working in the Builder (v1.90.1, Windows 7).
I am attempting to program an experiment which presents a fixation cross and various audio stimuli. There will be another visual stimuli after the offset of the audio stimuli (in another routine). There are 28 audio files that are randomly called upon through the conditions file. Each audio file is a different length of time. I am attempting to make the offset of the fixation cross and audio stimuli depend on the offset of the audio stimuli. I cannot use a fixed duration (e.g., 10 sec) as the “stop” value for the audio component because all audio files are different in length (although this allows the program to at least run). I have tried a couple solutions with no luck.
If I leave the stop duration value blank in the audio component I receive the following error: (ValueError: could not convert string to float: None).
I tried adding a variable to the conditions file (Duration) which indicates the duration of each audio file. I then added “$Duration” as the stop time of both the audio component and fixation cross. I received the following error: (ValueError: could not convert string to float: $Duration).
I tried using “Soundfile .getDuration()” as the stop time of both the audio component and fixation cross. I received the following error: (ValueError: could not convert string to float: Soundfile .getDuration() ).
I am not really sure what else I should try. Any help would be greatly appreciated. Thanks.
I appreciate the quick response. I added the “soundcomponent.status == FINISHED” to the stop value of the fixation stimulus, but this did not solve the error. You stated that the sound component should not need a duration value; however, when I leave it empty I receive this error: (ValueError: could not convert string to float: None). If I enter an arbitrary value for the stop duration (e.g., 10 s), the program will run. The problem with this is that I need the offset of the routine with the audio component to be dependent on the actual audio file duration (which vary from 8-ish to 12-ish s). The only reason I attempted to use the “$Duration” and “SoundFile.getDuration()” solutions was because leaving the audio component duration blank led to the error (ValueError: could not convert string to float: None).
I believe Dawid_Czech had a similar issue (Problem with the offset of a sound component) to which dvbrigdes provided a solution. The problem is that I am not sure how to implement his coding solution in the builder viewer.
OK, so the behaviour you are seeing is definitely unexpected and is a bug. David fixed it at the time so I’d suggest you simply upgrade PsychoPy to the latest version, to get the benefit of that and many subsequent fixes and new features: