Voicekey didn't work

If this template helps then use it. If not then just delete and start from scratch.

OS (e.g. Win10): Win11
PsychoPy version (e.g. 1.84.x): 23.1.2
Standard Standalone? (y/n) If not then what?:
**What are you trying to achieve?:

What did you try to make it work?:

What specifically went wrong when you tried that?:
Include pasted full error message if possible. “That didn’t work” is not enough information.

Hello! Thank you reading my post :slight_smile:
I recorded the voice using a microphone component. But the sound quality of the recorded file is not good. Sounds like I’m speaking very slowly, and there’s noise. So I use ‘vociekey’ code. But It’s doesn’t work well.

my routine and loop pic

I want to show resting(10s) and in ‘tat_real’ I’m going to show each of the 6 photos for 50 seconds(The reason for 51 seconds in picture is that 1 second will show empty screen).

All I want is a voice recording for 50 seconds while looking at the picture. People can only speak for 50 seconds. ‘tat_resting’ doesn’t have to be recorded. And I’d like to have a total of 6 recordings as each photo is recorded (but if it’s not possible, a consolidated file is fine).

Here is my code :
First, ‘each frame’ code in ‘tat_real’ routine

import psychopy.voicekey as vk
vk.pyo_init(rate=44100, buffersize=32)
from psychopy.voicekey.demo_vks import DemoVoiceKeySignal as Signaler

participant_name = expInfo['participant']

vpvk = vk.OnsetVoiceKey(
    file_out='data/trial_' + participant_name +'_tat.wav')


and ‘end routine’ code in ‘tat_real’


recorded_audio = mic.getRecording()

thisExp.addData('vocal_RT', round(vpvk.event_onset, 3))
thisExp.addData('bad_baseline', vpvk.bad_baseline)
thisExp.addData('filename', vpvk.filename)

The reason why I put “mic_stop” is because I used the mic component just in case.

When running, the following error appears

Portaudio error in Pa_AbortStream (pa_stop): Unanticipated host error
Portaudio error in Pa_CloseStream (pa_deinit): PortAudio not initialized
Portaudio error in Pa_Terminate (pa_deinit): PortAudio not initialized
Pyo error: Error closing audio backend.

and sometimes,

ValueError: Baseline period is TOO quiet
wrong input channel selected? device-related initial delay?

this error appears too.
Of course, the voice file wasn’t even saved.

How can I solve this problems? Please help me…:disappointed_relieved::disappointed_relieved: