summaryrefslogtreecommitdiff
path: root/extra/stt.go
diff options
context:
space:
mode:
authorGrail Finder <wohilas@gmail.com>2025-11-12 12:20:55 +0300
committerGrail Finder <wohilas@gmail.com>2025-11-12 12:20:55 +0300
commit2695cf437e127ce6cdb33d4ea51a612d47934257 (patch)
treea7171da5d847b240813111e23b53eb1507dc880e /extra/stt.go
parente1b260c474e321c7a414a17ad4347b60a5531bb2 (diff)
Fix: supressed alsa warnings
Diffstat (limited to 'extra/stt.go')
-rw-r--r--extra/stt.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/extra/stt.go b/extra/stt.go
index 3809487..fd9e419 100644
--- a/extra/stt.go
+++ b/extra/stt.go
@@ -12,6 +12,7 @@ import (
"net/http"
"regexp"
"strings"
+ "syscall"
"github.com/gordonklaus/portaudio"
)
@@ -145,6 +146,21 @@ func (stt *WhisperServer) IsRecording() bool {
}
func (stt *WhisperServer) microphoneStream(sampleRate int) error {
+ // Temporarily redirect stderr to suppress ALSA warnings during PortAudio init
+ origStderr, err := syscall.Dup(syscall.Stderr)
+ nullFD, err := syscall.Open("/dev/null", syscall.O_WRONLY, 0)
+ if err != nil {
+ return fmt.Errorf("failed to open /dev/null: %w", err)
+ }
+ // redirect stderr
+ syscall.Dup2(nullFD, syscall.Stderr)
+ // Initialize PortAudio (this is where ALSA warnings occur)
+ defer func() {
+ // Restore stderr
+ syscall.Dup2(origStderr, syscall.Stderr)
+ syscall.Close(origStderr)
+ syscall.Close(nullFD)
+ }()
if err := portaudio.Initialize(); err != nil {
return fmt.Errorf("portaudio init failed: %w", err)
}