How to code the voice key

i want to record the onset of speech sound and the time of stop time,how to code the voice key

Hi. Could find a way to do it? If so, I would appreciate it if you could share it with me. Thanks. I need to do it.