alpha
Login
or
Join now
lass.pds.lassul.us
/
superconfig
Star
0
Fork
1
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
This repository has no description
Star
0
Fork
1
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Overview
Issues
Pulls
1
Pipelines
tools: add mic-to-text
author
lassulus
date
11 months ago
(Oct 27, 2025, 1:33 PM CET)
commit
19eafe17
19eafe17d05458b7c586a868e9c628eb235184fc
parent
4b3d0dc4
4b3d0dc4f1dcb2eaa54d7225191d9a6461631630
+43
2 changed files
Expand all
Collapse all
Unified
Split
tools
mic-to-text
flake-module.nix
mic-to-text.sh
+15
tools/mic-to-text/flake-module.nix
View file
Reviewed
···
1
1
+
{ ... }:
2
2
+
{
3
3
+
perSystem =
4
4
+
{ pkgs, ... }:
5
5
+
{
6
6
+
packages.mic-to-text = pkgs.writeShellApplication {
7
7
+
name = "mic-to-text";
8
8
+
runtimeInputs = [
9
9
+
pkgs.sox
10
10
+
pkgs.whisper-cpp
11
11
+
];
12
12
+
text = builtins.readFile ./mic-to-text.sh;
13
13
+
};
14
14
+
};
15
15
+
}
+28
tools/mic-to-text/mic-to-text.sh
View file
Reviewed
···
1
1
+
#!/usr/bin/env bash
2
2
+
set -euo pipefail
3
3
+
4
4
+
# Default recording duration in seconds
5
5
+
DURATION=${1:-5}
6
6
+
7
7
+
# Temporary file for audio recording
8
8
+
TEMP_AUDIO=$(mktemp /tmp/mic-to-text-XXXXXX.wav)
9
9
+
trap 'rm -f "$TEMP_AUDIO"' EXIT
10
10
+
11
11
+
echo "Recording for $DURATION seconds... (press Ctrl+C to stop early)" >&2
12
12
+
13
13
+
# Record audio from default microphone
14
14
+
# -r 16000: sample rate 16kHz (optimal for speech recognition)
15
15
+
# -c 1: mono channel
16
16
+
# -b 16: 16-bit audio
17
17
+
rec -q -r 16000 -c 1 -b 16 "$TEMP_AUDIO" trim 0 "$DURATION" || true
18
18
+
19
19
+
if [ ! -s "$TEMP_AUDIO" ]; then
20
20
+
echo "Error: No audio recorded" >&2
21
21
+
exit 1
22
22
+
fi
23
23
+
24
24
+
echo "Transcribing locally..." >&2
25
25
+
26
26
+
# Transcribe using whisper.cpp (runs locally, no API calls)
27
27
+
# Uses the base model by default, you can override with WHISPER_MODEL env var
28
28
+
whisper-cpp -m "${WHISPER_MODEL:-base.en}" -f "$TEMP_AUDIO" --no-timestamps --output-txt