Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thresholds #65

Open
ericmittler opened this issue Aug 22, 2022 · 0 comments
Open

Thresholds #65

ericmittler opened this issue Aug 22, 2022 · 0 comments

Comments

@ericmittler
Copy link

ericmittler commented Aug 22, 2022

Can someone point me to the documentation on thresholds?
I am trying to get a recording to stop after a (configurable) moment of silence (say 2 seconds). I don't see any example of this, but it appears that it is possible with "endOnSilence" and thresholds.

Here's a bit of code that I would have thought would start after some 0.5 threshold (whatever that means) and ends after 1 second of silence meeting a thresholdEnd of 0.2 (whatever that means). But it just records forever.

import fs from 'fs'
import recorder from 'node-record-lpcm16'
const localAudioFileName = `/tmp/lpcm16recording.mp3`
const file = fs.createWriteStream(localAudioFileName, { encoding: 'binary' })
const recording = recorder.record({
  sampleRate: 16000, recordProgram: 'sox',
  thresholdStart: 0.5, thresholdEnd: 0.2, silence: 1.0, endOnSilence: true
}).stream().pipe(file)

What changes to this code would I have to make to have the recording stop when it detects silence?

UPDATE: I played with the thresholds and a different microphone and it seems to work. I would still like to see some docs on thresholds as I'm guessing what they do and I'd rather not guess. Is it also possible that 'rec' ignores thresholds and 'sox' implements them?

Thanks
+Eric

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant