Cropping a speech signal in Coder

Hi,

I am using the sound.Microphone() api (in PsychoPy v2021.2.3) to record a single word uttered by my participant. I am then applying various modifications of the recorded sound, but before that, I would like to “crop” the speech signal to only keep the part of the signal between the speech onset and the speech offset (i.e., to remove the silences before and after the uttered word).

I think this could be done using voicekey (psychopy.voicekey - Real-time sound processing — PsychoPy v2022.1.4 or Can I log recording onset time when using the voice key?), but I am not sure how.

Do you know how I could do that and/or where I could find coder examples of similar tasks?

Thank you!

Ladislas

Since pyo (and therefore PsychoPy.voicekey) does not seem to work with PsychoPy on Mac OS, I am currently using this function to remove silences at the beginning and end of wav files: python - remove silence at the beginning and at the end of wave files with PyDub - Stack Overflow.

I have done something similar when extracting sound from videos - but I think it might actually be a tad more convoluted than your approach (I used Praat to first get speech onsets) - sharing github code incase useful.

1 Like