From 33aa37cf38c0ffbe4e753c19999675c9dafd9e89 Mon Sep 17 00:00:00 2001 From: Emil Lerch Date: Wed, 10 Sep 2025 18:05:51 -0700 Subject: [PATCH] switch to alsa default device and ask users to configure through alsa.conf --- README.md | 14 ++++++++++++++ alsa.conf | 6 ++++++ src/main.zig | 2 +- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fe604b5..463e70a 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,20 @@ This project implements a minimal real-time speech-to-text application using Vosk and Zig. +## Audio Device Configuration + +The application uses ALSA's default device, which is configured in `alsa.conf`. To use a different audio device: + +1. Find your audio devices: `aplay -l` or `arecord -l` +2. Edit `alsa.conf` and update the `pcm.!default` section: + ``` + pcm.!default { + type hw + card 3 # Change to your card number + device 0 # Change to your device number + } + ``` +3. Rebuild and run the application ### Prerequisites - Zig 0.15.1 (configured via mise) diff --git a/alsa.conf b/alsa.conf index 2ba34e2..ef78ac7 100644 --- a/alsa.conf +++ b/alsa.conf @@ -1,3 +1,9 @@ +pcm.!default { + type hw + card 3 + device 0 +} + pcm.hw { @args [ CARD DEV SUBDEV ] @args.CARD { diff --git a/src/main.zig b/src/main.zig index 3a5c352..196f85c 100644 --- a/src/main.zig +++ b/src/main.zig @@ -168,7 +168,7 @@ pub fn main() !void { // These parameters maintain the existing working behavior const options = stt.SttOptions{ .model_path = "zig-out/bin/vosk-model-small-en-us-0.15", - .audio_device = "hw:3,0", // Maintain existing audio device configuration + .audio_device = "default", // Use ALSA default device from alsa.conf .event_handler = speech_handler, .sample_rate = 16000, // Standard sample rate for speech recognition .channels = 2, // Stereo input (will be converted to mono internally)