fix(@scripts): 🐛 update audio input to use configurable device
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
5a4633cef6
commit
0590b8b07d
1 changed files with 12 additions and 3 deletions
15
bin/rvoice
15
bin/rvoice
|
|
@ -28,6 +28,10 @@
|
||||||
# RVOICE_AUTOSEND=1 (append Enter; default 0)
|
# RVOICE_AUTOSEND=1 (append Enter; default 0)
|
||||||
# RVOICE_MIN_MS=200 (ignore taps shorter than this)
|
# RVOICE_MIN_MS=200 (ignore taps shorter than this)
|
||||||
# RVOICE_MAX_S=60 (hard cap on recording length)
|
# RVOICE_MAX_S=60 (hard cap on recording length)
|
||||||
|
# RVOICE_AUDIO_INPUT=":default" (avfoundation input; numeric
|
||||||
|
# index or "default". List devices
|
||||||
|
# with: ffmpeg -f avfoundation
|
||||||
|
# -list_devices true -i "")
|
||||||
#
|
#
|
||||||
# State lives in $TMPDIR/rvoice/ — one recording at a time.
|
# State lives in $TMPDIR/rvoice/ — one recording at a time.
|
||||||
|
|
||||||
|
|
@ -42,6 +46,10 @@ LANG_HINT=${RVOICE_LANG:-en}
|
||||||
AUTOSEND=${RVOICE_AUTOSEND:-0}
|
AUTOSEND=${RVOICE_AUTOSEND:-0}
|
||||||
MIN_MS=${RVOICE_MIN_MS:-200}
|
MIN_MS=${RVOICE_MIN_MS:-200}
|
||||||
MAX_S=${RVOICE_MAX_S:-60}
|
MAX_S=${RVOICE_MAX_S:-60}
|
||||||
|
# avfoundation input spec. ":default" → macOS system default input
|
||||||
|
# (controlled via Sound Settings / Control Center → Sound). Numeric ":N"
|
||||||
|
# pins to a specific device index from `ffmpeg -f avfoundation -list_devices`.
|
||||||
|
AUDIO_INPUT=${RVOICE_AUDIO_INPUT:-:default}
|
||||||
|
|
||||||
STATE_DIR=${TMPDIR:-/tmp}/rvoice
|
STATE_DIR=${TMPDIR:-/tmp}/rvoice
|
||||||
mkdir -p "$STATE_DIR"
|
mkdir -p "$STATE_DIR"
|
||||||
|
|
@ -111,10 +119,11 @@ cmd_start() {
|
||||||
_start_ts=$(now_ms)
|
_start_ts=$(now_ms)
|
||||||
printf '%s' "$_start_ts" > "${START_FILE}.tmp"
|
printf '%s' "$_start_ts" > "${START_FILE}.tmp"
|
||||||
mv -f "${START_FILE}.tmp" "$START_FILE"
|
mv -f "${START_FILE}.tmp" "$START_FILE"
|
||||||
# 16kHz mono PCM, capped at MAX_S. Device "0" is the default macOS input;
|
# 16kHz mono PCM, capped at MAX_S. AUDIO_INPUT defaults to ":default"
|
||||||
# change with AVFoundation list if you have multiple mics.
|
# which honors the macOS system default input (configurable via Sound
|
||||||
|
# Settings / Control Center). Numeric ":N" pins a specific device.
|
||||||
nohup ffmpeg -hide_banner -loglevel error -nostdin \
|
nohup ffmpeg -hide_banner -loglevel error -nostdin \
|
||||||
-f avfoundation -i ":0" \
|
-f avfoundation -i "$AUDIO_INPUT" \
|
||||||
-ac 1 -ar 16000 -t "$MAX_S" \
|
-ac 1 -ar 16000 -t "$MAX_S" \
|
||||||
-y "$WAV_FILE" >/dev/null 2>>"$LOG_FILE" &
|
-y "$WAV_FILE" >/dev/null 2>>"$LOG_FILE" &
|
||||||
echo $! > "$PID_FILE"
|
echo $! > "$PID_FILE"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue