For those interested…
I ended up scrapping the microphone module (which uses pyo
) and using recording functionality from sounddevice
. The WAV file was generated using a module from scipy
.
My code is now the following:
### Init. routine
## Before exp
import sounddevice as sd
from scipy.io.wavfile import write as wav_write
## Begin routine
# Make and set directory for recordings to be saved
recordingDir = _thisDir + fr"\Data\Sound recordings\participant_{expInfo['participant']}"
os.mkdir(recordingDir)
# Set recording params
fs = 48000
sd.default.samplerate = fs
sd.default.channels = 1 # Mono sound
rec_duration = 65
### Recording routine
## Begin routine
mic_recording = sd.rec(int(rec_duration * fs))
## End routine
mic_filename = recordingDir + fr'\participant_{participant_id}_problem{problem_id}_{stimuli}_wordset{wordset}.wav'
wav_write(mic_filename, fs, mic_recording)
Seems to be working like a charm, with simple syntax/code snippets similar to the microphone module.