Looking at detecting sound until some silence occurs, I arrived at the command rec recording.flac rate 32k silence -l 1 0.1 3% 1 3.0 3%.

I realize my specific use would be somewhat different: I do want to record until some silence is detected, but I also want an upper limit, say 10-15 seconds, of how long the recording will go on before moving on. I can just prepend a timeout 15s command, which would give me a maximum speech time of (15 seconds - leading silence, which will vary), but is there some way to tell sox I only need the first x seconds of a recording, which would give me a maximum speech time of 15 secs regardless of leading silence?

1 Answer 1


You can use the trim effect; e.g., trim 0 15 will pass through only the first 15 seconds of audio. You can put it before or after silence:

  • If before silence, that effect will only “hear” 15 seconds and possibly output less, if there was silence to be removed from that 15 seconds.
  • If after silence, trim will “hear” the audio with silence already removed and stop after 15 seconds of non-silence.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.