Skip to content

mic-record

by rob

Record audio from microphone for a fixed duration

# mic-record - Record Audio from Microphone

Record audio from microphone for a fixed duration. Outputs file path to stdout.

## Usage

```bash
mic-record --duration 10
mic-record --duration 5 --file recording.wav
mic-record --device plughw:Device --duration 10
```

## Arguments

| Flag | Default | Description |
|------|---------|-------------|
| `--duration` | 5 | Recording duration in seconds |
| `--device` | default | ALSA audio device |
| `--file` | (auto) | Output file path (default: temp file) |
| `--rate` | 16000 | Sample rate in Hz |

## Output

Outputs the recorded file path to stdout. Status messages go to stderr.

```bash
$ mic-record --duration 3
Recording for 3 seconds... (speak now)    # stderr
Recording complete: /tmp/xyz.wav          # stderr
/tmp/xyz.wav                              # stdout
```

## Devices

List available devices:
```bash
arecord -l
```

Common device formats:
- `default` - System default
- `plughw:0,0` - First sound card
- `plughw:2,0` - USB device (card 2)
- `plughw:Device` - By card name (stable across reconnects)

## Requirements

- `arecord` (ALSA utils): `sudo apt install alsa-utils`

## Examples

```bash
# Record and transcribe
mic-record --duration 10 | xargs -I {} sh -c 'cat {} | transcribe'

# Record to specific file
mic-record --duration 30 --file meeting.wav

# Use USB microphone
mic-record --device plughw:Device --duration 5

# Higher quality recording
mic-record --rate 44100 --duration 10 --file hifi.wav
```

## Extensibility

This tool handles fixed-duration recording. Future variants:
- `mic-record-ptt` - Push-to-talk (record while key held)
- `mic-record-vox` - Voice-activated (stop on silence)
- `mic-record-wake` - Wake word triggered

No reviews yet.

Issues

No issues reported for this tool.