← back to Voice Clone
record.sh
58 lines
#!/bin/bash
# record.sh — record a 90-second voice sample for ElevenLabs cloning.
# First run will trigger macOS mic-permission prompt (Terminal needs Microphone access).
#
# Usage: ./record.sh [seconds=90] [output=~/Projects/voice-clone/sample.wav]
#
# What to read for the best clone (60-90sec, varied tone):
# "Hi, I'm Steve. This is a voice sample for the Steve narrator voice on the
# WhoLivedThere project. I'm reading at a normal pace, with natural pauses,
# the way I'd actually narrate a product walkthrough. Open the archive for
# every house. Public records, private memories, real addresses. Editorial
# seriousness without being precious. Quick brown foxes and lazy dogs and
# forty-two and three-thousand-eight-hundred-and-twelve."
# (Add another 30-40sec of any natural speech. Whisper, normal, slightly
# excited — variety helps the clone capture range.)
set -euo pipefail
SECONDS_TO_RECORD=${1:-90}
OUT=${2:-$HOME/Projects/voice-clone/sample.wav}
mkdir -p "$(dirname "$OUT")"
# discover audio device index
AUDIO_DEV=$(ffmpeg -hide_banner -f avfoundation -list_devices true -i "" 2>&1 \
| awk '/AVFoundation audio/{found=1; next} found && /\[[0-9]+\]/{print; exit}' \
| grep -oE '\[[0-9]+\]' | head -1 | tr -d '[]')
AUDIO_DEV=${AUDIO_DEV:-0}
echo ""
echo "═════════════════════════════════════════════════════════════════"
echo " Voice sample recording — $SECONDS_TO_RECORD seconds"
echo " output: $OUT"
echo " device: avfoundation index=$AUDIO_DEV"
echo "═════════════════════════════════════════════════════════════════"
echo ""
echo "Tips for a great ElevenLabs clone:"
echo " • Quiet room, no fan/AC noise, no echo"
echo " • Same distance from mic the whole time (~6 inches)"
echo " • Natural pace — read like you're narrating a walkthrough"
echo " • Vary tone: matter-of-fact, slightly excited, calm explanatory"
echo " • 60-90sec total, English only for first clone"
echo ""
read -p "Press ENTER to start recording (3-sec countdown), Ctrl-C to abort... "
for n in 3 2 1; do echo -n "$n... "; sleep 1; done
echo "RECORDING — speak now."
echo ""
ffmpeg -hide_banner -loglevel warning \
-f avfoundation -i ":$AUDIO_DEV" \
-t "$SECONDS_TO_RECORD" -ac 1 -ar 44100 -c:a pcm_s16le \
-y "$OUT"
echo ""
echo "✓ Saved: $OUT ($(du -h "$OUT" | awk '{print $1}'))"
echo ""
echo "Listen back: afplay '$OUT'"
echo "If happy: ./clone.sh"
echo "If not: ./record.sh # try again"