Silence auto-stop: consider both system audio and mic#13
Conversation
Add silence timeout feature that auto-stops recording after sustained silence. The Swift helper monitors audio levels from both system audio and mic (when --mic is used), only triggering timeout when both sources are silent. Mic uses a higher noise threshold (1e-2) to filter ambient room noise. Muted mic counts as silence. Also adds sounddevice backend support for silence timeout, README docs, and config option (silence_timeout = 300 default).
There was a problem hiding this comment.
Pull request overview
Adds an auto-stop-on-silence feature to the recording pipeline, including support for combined system-audio + mic recording where the timeout only triggers once both sources have been quiet long enough.
Changes:
- Adds silence level tracking + a periodic silence-timeout check to the Swift CoreAudio helper (system + mic aware).
- Plumbs
silence_timeoutthrough Python config/CLI into both CoreAudio and SoundDevice backends, and updates pipeline UX messaging/looping. - Documents the new feature and configuration defaults in README/config template.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| swift/Sources/AudioCapture.swift | Tracks “last loud” for mic + system audio and adds a silence-timeout timer; wires shutdown path + new CLI arg parsing. |
| src/ownscribe/pipeline.py | Passes silence_timeout into recorders; updates recording hints/loop to end when recorder stops. |
| src/ownscribe/config.py | Introduces audio.silence_timeout config default (300s) and documents it in the config template. |
| src/ownscribe/cli.py | Adds --silence-timeout CLI flag and maps it into config. |
| src/ownscribe/audio/sounddevice_recorder.py | Implements silence timeout tracking for the sounddevice backend and exposes is_recording. |
| src/ownscribe/audio/coreaudio.py | Passes --silence-timeout to Swift helper; tracks/filters [SILENCE_TIMEOUT]; exposes is_recording. |
| src/ownscribe/audio/base.py | Adds a common is_recording property on the recorder interface. |
| README.md | Documents silence auto-stop and adds config/usage examples; adds a table of contents. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
- Fix data race: init lastLoudTime before startCapture() in Swift - Cancel silence timer in stop() to prevent firing during shutdown - Add --silence-timeout to Swift helper usage text - Use silence_timed_out property for stop message instead of stop_event - Raise sd.CallbackStop in sounddevice backend on silence timeout - Add silence_timed_out property to SoundDeviceRecorder - Fix lint: split long --silence-timeout CLI option line - Add tests: config default, CLI flag, recorder passthrough
|
@copilot review |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
…ix test label - Call recorder.stop() before checking silence_timed_out so CoreAudio stderr is parsed before the flag is read - Replace Date() with DispatchTime.now().uptimeNanoseconds in Swift silence timing to avoid wall-clock jumps from NTP sync or sleep/wake - Fix test_silence_timeout_passed_to_sounddevice to use "sounddevice" backend for clarity
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
…tion, code cleanup - Make is_recording abstract on AudioRecorder base class - Filter SILENCE_WARNING lines from Swift stderr, print clean Python-side message - Check stream.active in SoundDeviceRecorder.is_recording - Validate --silence-timeout as non-negative (click.IntRange in Python, explicit check in Swift) - Fix time formatting to show "Xm Ys" instead of truncating to whole minutes - Extract computePeakLevel() helper and named threshold constants in Swift - Add comments explaining silence timer logic
The Swift helper writes SILENCE_WARNING to stderr during capture, and piped stderr passes it through in real time. Filtering it in stop() and replacing with a Python message would delay it until after recording finishes, defeating its purpose.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Summary
--silence-timeoutorsilence_timeoutconfig)--micis used, monitors both system audio and mic levels — only triggers timeout when both sources are silentTest plan
swift/build.shcompilesuv run pytest— 221 tests passownscribe --mic --silence-timeout 10— speaking into mic with no system audio does NOT trigger timeout