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