Skip to content

Commit 5367613

Browse files
committed
fix: keepalive as configurable, to prevent hung indicators
1 parent 8586d42 commit 5367613

3 files changed

Lines changed: 38 additions & 1 deletion

File tree

docs/CONFIGURATION.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,24 @@ Custom sounds:
655655
- **Supported formats**: `.ogg`, `.wav`, `.mp3`
656656
- **Fallback**: Uses defaults if custom files don't exist
657657

658+
### Audio stream keepalive
659+
660+
By default hyprwhspr opens the microphone only while recording.
661+
662+
On some hardware (certain USB mics on raw ALSA), the first recording after an idle period fails with a `paTimedOut` error because the audio device suspends between uses.
663+
664+
If you see this, enable the keepalive stream:
665+
666+
```json
667+
{
668+
"keepalive_stream": true
669+
}
670+
```
671+
672+
This holds a silent input stream open in the background so the device stays warm.
673+
674+
**Leave this off unless you need it** — an open input stream triggers the microphone-in-use indicator on most desktops (GNOME, KDE, Ubuntu, etc.), making it appear as though hyprwhspr is always listening. It's not!
675+
658676
### Audio ducking
659677

660678
Quiet system volume on record:
@@ -1080,6 +1098,18 @@ pactl list short sources
10801098
systemctl --user restart pipewire
10811099
```
10821100

1101+
#### Microphone indicator shows on while idle
1102+
1103+
If your desktop (GNOME, Ubuntu, etc.) shows the microphone as active whenever the hyprwhspr service is running, you likely have `keepalive_stream` enabled. Disable it:
1104+
1105+
```json
1106+
{
1107+
"keepalive_stream": false
1108+
}
1109+
```
1110+
1111+
This is the default. If you previously enabled it to fix `paTimedOut` errors, see [Audio stream keepalive](#audio-stream-keepalive) for the trade-off.
1112+
10831113
#### Audio feedback not working
10841114

10851115
```bash

lib/src/audio_capture.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,8 @@ def _start_keepalive(self, _attempt: int = 0):
237237
with self._keepalive_lock:
238238
if self._keepalive_stream is not None or self.device_id is None:
239239
return
240+
if self.config is None or not self.config.get_setting('keepalive_stream', False):
241+
return
240242
if not self._is_multiplexed_audio_server():
241243
return
242244
stream = None

lib/src/config_manager.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,12 @@ def __init__(self):
116116
# Audio stream cold-start recovery
117117
# How long (seconds) to wait between stream.start() retries when PortAudio times out.
118118
# Increase this if your USB mic frequently fails on the first recording after idle.
119-
'stream_start_retry_delay': 1.5
119+
'stream_start_retry_delay': 1.5,
120+
# Keep a silent audio stream open between recordings to prevent ALSA cold-start
121+
# timeouts on some hardware. Disabled by default because active input streams
122+
# trigger the microphone-in-use indicator on many desktops (GNOME, Ubuntu, etc.).
123+
# Enable only if you see paTimedOut errors on your first recording after idle.
124+
'keepalive_stream': False
120125
}
121126

122127
# Set up config directory and file path

0 commit comments

Comments
 (0)