This guide explains how to set up and run the continuous_audio_recorder.py
script on macOS. The script continuously records audio until stopped (via Ctrl+C
), saving files as 128kbps stereo MP3s in daily folders. Each filename includes the date, start time, stop time, timezone offset, and recording number.
- macOS: Tested on macOS Ventura, Sonoma.
- Homebrew: macOS package manager. Install if not already present.
- Admin Access: Required for installations.
- Audio Hardware: Microphone and system audio for aggregate device setup.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Add Homebrew to your shell path:
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zshrc
source ~/.zshrc
Verify:
brew --version
brew install python@3.12
python3.12 --version # Should output Python 3.12.x
Note: Python path is typically /opt/homebrew/bin/python3.12
.
brew install ffmpeg
ffmpeg -version # Verify installation
/opt/homebrew/bin/python3.12 -m venv ~/codexaudio/venv
source ~/codexaudio/venv/bin/activate # Activate the environment
Install PortAudio (required for PyAudio):
brew install portaudio
pip install pyaudio pydub
Verify:
pip show pyaudio
pip show pydub
pyaudio
: For audio recordingpydub
: For converting WAV to MP3
- Open Audio MIDI Setup via Spotlight.
- Click ➕ and choose Create Aggregate Device.
- Rename it to
System + Mic
. - Add:
- Your microphone
- System output (e.g., Built-in Output, Soundflower, or BlackHole)
- Ensure:
- At least 3 input channels
- Sample rate:
44100 Hz
Note:
To capture system audio, install BlackHole:brew install blackhole-2ch
Add BlackHole to your aggregate device via Audio MIDI Setup.
- Save
continuous_audio_recorder.py
to your project directory, e.g.:
mkdir -p ~/codexaudio
mv continuous_audio_recorder.py ~/codexaudio/
- Edit the script:
base_dir = "/Users/viszya/audio_recordings" # Update with your preferred path
- Ensure the directory exists and is writable:
mkdir -p /Users/viszya/audio_recordings
chmod -R u+w /Users/viszya/audio_recordings
cd ~/codexaudio
source venv/bin/activate
python continuous_audio_recorder.py
The script will display:
Recording started. Press Ctrl+C to stop.
Audio files are saved in:
/Users/viszya/audio_recordings/YYYY-MM-DD/
e.g.,20250707_150000-0700_to_151000-0700_1.mp3
- Ensure
base_dir
is writable. - Run:
chmod -R u+w /Users/viszya/audio_recordings
- Recheck the "System + Mic" setup in Audio MIDI Setup.
- Confirm name and channel count in script.
- Check FFmpeg accessibility:
which ffmpeg
- If not found, reinstall or update your PATH.
- Confirm mic/system audio are active and included in the aggregate device.
- Test input via Audio MIDI Setup.
- For long recordings, consider limiting session time to avoid RAM issues.
-
Location:
base_dir/YYYY-MM-DD/
e.g.,/Users/viszya/audio_recordings/2025-07-07/
-
Filename Format:
YYYYMMDD_HHMMSS±HHMM_to_HHMMSS±HHMM_N.mp3
Example:20250707_150000-0700_to_151000-0700_1.mp3
-
Format:
128kbps stereo MP3
, converted from a temporary WAV file.
Category | Requirement |
---|---|
Software | Homebrew, Python 3.12, FFmpeg, BlackHole (optional) |
Python Packages | pyaudio , pydub |
Hardware | Microphone, optional loopback for system audio |
macOS Config | Aggregate device: "System + Mic" , ≥3 input channels |
For help, contact the script maintainer or consult Python and FFmpeg documentation.
This script automatically transcribes .mp3
files in a recordings
folder using OpenAI Whisper and outputs the results as JSON files. It only processes files that do not already have a corresponding transcript.
- Processes all
.mp3
files in therecordings
directory that do not have a corresponding_transcript.json
file. - Outputs only the transcript as a JSON file per MP3 (e.g.,
yourfile_transcript.json
). - Skips files that have already been transcribed.
- Shows a progress bar and live elapsed time for each file.
- Estimates processing time for new files based on previous runs (if
.transcribe_stats.json
is present). - Optionally displays MP3 duration if
mutagen
is installed. - Exits automatically when done.
- Download and install Python from python.org if you don't already have it.
- On macOS, the official installer is recommended.
git clone <your-repo-url>
cd <your-repo-directory>
mkdir recordings
Place your .mp3
files inside this folder.
It is recommended to use a virtual environment:
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
Then install dependencies:
pip install openai-whisper tqdm
pip install mutagen
python3 Transcribe.py
- The script will process all
.mp3
files in therecordings
folder that do not already have a_transcript.json
file. - Transcripts will be saved as
<originalfilename>_transcript.json
in the same folder. - The script will estimate processing time for new files based on previous runs if
.transcribe_stats.json
is present (created automatically after processing qualifying files).
- The first run will download the Whisper model (can be several GBs, requires internet connection).
- For best results, use short, clear audio files.
- If you add new
.mp3
files later, just re-run the script. - The
.transcribe_stats.json
file is used for time estimation and is created/updated automatically.
- If you see SSL certificate errors on macOS, run the
Install Certificates.command
script in your/Applications/Python 3.x/
folder. - If you see missing package errors, ensure you are using the correct Python environment and have installed all dependencies.
- If you want MP3 duration display, install
mutagen
as shown above.
MIT