Skip to content

Instantly share code, notes, and snippets.

@peterkappus
Last active March 14, 2020 11:13
Show Gist options
  • Save peterkappus/c1b8dfc621077c42019d21cf6f9ab624 to your computer and use it in GitHub Desktop.
Save peterkappus/c1b8dfc621077c42019d21cf6f9ab624 to your computer and use it in GitHub Desktop.
Bash script for recording audio with Sox on my mac
#!/bin/bash
# For recording flac & mp3 files (with compression and silence trimming)
# Prerequisite: sox
#`brew install sox --with-lame --with-flac --with-libvorbis`
# For recording flac & mp3 files.
# Grab your laptop
# Plug in your USB sound device
# Check sound settings that you're using your USB input
# open a terminal
# First time only:
# chmod +x recod.bash
# Run the following:
# ./rec.bash
# Play some music...
# After 5 seconds of silence, it automatically stops.
# You should have a slightly compressed MP3 and a FLAC file, with silence trimmed, and named after the current date (YYYY-MM-DD).
# Using ISO 8601 date-time format https://en.wikipedia.org/wiki/ISO_8601 and adding timezone (%Z)
file=$(date +%Y-%m-%dT%H%M%S%Z) && rec $file.flac silence 1 0:01 0.00599% 1 0:03 0.00599% norm compand 0.3,1 -5,-5 && sox $file.flac $file.mp3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment