The idea is small and a bit stubborn. During a work call you should be able to pick the client you are talking to, hear both sides of the conversation, and get a short line you can actually say out loud. That line has to come from the conversations you already had in ChatGPT about that client. If the history does not contain the answer, the copilot should say so and stop. No invented budgets, no invented dates, no invented “we agreed”.
ChatGPT itself does not hand a third-party app your chat history just because you are signed in. The first version does not try to sneak around that. You export the conversations you care about, the app indexes them locally under a profile, and after the call it writes a review packet you can paste back into the right ChatGPT thread. The memory stays yours. The call stays on the machine.
This is a Python desktop application for macOS. Python is the language the whole program is written in. Install it with Homebrew (brew install python), then let ai_assistant/setup.sh create a virtual environment and install the Python packages. You run the app from that environment, not from the system Python.
01. How a Call Moves Through the Program
One phrase takes a fixed path. Nothing clever happens off to the side.
- Two input streams stay open for the whole call: your microphone, and the meeting audio.
- Each stream keeps its own energy tracker. A pause closes a phrase. The capture thread only queues that phrase.
- A background worker resamples the phrase, levels it, and transcribes it on the CPU.
- If the other stream just heard the same sentence, the second copy is dropped.
- The participant’s line is embedded and compared with the active profile’s stored chunks. The top matches are pasted into the system prompt.
- A local or remote chat model writes one or two sentences. Your own lines are shown in the transcript, and they trigger a suggestion only when there is no separate meeting stream.
- Stop writes a Markdown review packet under
~/.context_assistant/review_packets/.
Profiles never share a vector collection. Settings live in ~/.context_assistant/config.json and survive a restart: provider, model, spoken language, system prompt, temperature, token cap, and the silence setting.
There are two windows over that same pipeline. app.py is the Tkinter edition. app_aurora.py is the Aurora edition. Shared behavior sits in speech_audio.py, audio_devices.py, and call_export.py.
app_aurora.py (Aurora UI Rust/Skia edition) during a live call, displaying the descending dialogue stream, 48 kHz → 16 kHz resampling badge, grounded reply, and Top-3 ChromaDB source chunks.
app.py (Elevated Tkinter edition) running the exact same pipeline and answering a timeline question strictly from Default_Client memory chunks.
02. The Tools, Introduced Once
BlackHole is a virtual audio driver. macOS will not give an ordinary app the other person’s voice once you are on headphones, because that voice is playing inside the meeting app. You build a Multi-Output Device in Audio MIDI Setup that sends the meeting both to your headphones and to BlackHole. The copilot records BlackHole. Install the driver from its releases, then reboot so Core Audio sees it. In a meeting app, set the output to that Multi-Output Device.
sounddevice is the Python binding for PortAudio, the cross-platform library that opens real input devices. import sounddevice as sd, then sd.query_devices() lists what PortAudio can see and sd.InputStream(...) starts a callback. It is in requirements.txt: pip install sounddevice. PortAudio does not list Multi-Output devices as inputs, because they are output-only. That gap is handled in our own code, below.
NumPy is the array library the audio path actually speaks. Samples are float32 vectors. Install with pip install numpy. Energy, peak, and resampling all run on those arrays.
SciPy supplies scipy.signal.resample_poly, an anti-aliased resampler. It is optional. If the import fails, the same function falls back to linear interpolation with numpy.interp. Install it with pip install scipy when you want the cleaner resample.
faster-whisper runs OpenAI’s Whisper speech model through CTranslate2, which is a fast inference runtime for Transformer models. You construct WhisperModel(name, device="cpu", compute_type="int8_float32") and call model.transcribe(audio). The default checkpoint in this project is small.en. The package downloads weights on first use. pip install faster-whisper.
ChromaDB is a local vector database. chromadb.PersistentClient(path=...) stores embeddings on disk. collection.add(documents=..., ids=...) indexes text, and collection.query(query_texts=..., n_results=...) returns the nearest chunks. The default embedding function ships with the library, so the app does not call out to a separate embedding API. pip install chromadb. The database directory is ~/.context_assistant/vector_db.
Ollama is a local model server. After brew install ollama you pull a chat model with ollama pull llama3.1:8b and leave the server on http://localhost:11434. The OpenAI-compatible route is http://localhost:11434/v1. The copilot also reads GET /api/tags to fill the model dropdown. The default provider is Ollama and the default model is llama3.1:8b.
The OpenAI Python SDK is the client used for every provider, including Ollama and any other server that speaks the same chat API. OpenAI(base_url=..., api_key=...) then client.chat.completions.create(...). Official OpenAI is optional and billed per token. A custom base URL covers LM Studio, vLLM, and similar servers. pip install openai. If you use the official API, set OPENAI_API_KEY.
Tkinter comes with CPython. import tkinter as tk builds the classic window: sidebar, copilot page, profiles, review packets, settings. No extra install. ./setup.sh --tkinter launches that edition.
Aurora UI (aurora-ui on PyPI) is a Python desktop toolkit whose layout and drawing run in a Rust core. Rust is the systems language that core is written in. Drawing goes through Skia, Google’s 2D graphics library, and layout goes through Taffy, a flexbox layout crate. In Python you build a tree of column, row, text, and Signal values, and the toolkit redraws when a signal changes. pip install aurora-ui, or ./setup.sh with no flag, which installs requirements_aurora.txt.
Pillow reads and draws raster images. The Tkinter edition uses it to turn icons into ImageTk.PhotoImage objects. pip install pillow.
PyObjC exposes Apple’s AppKit framework to Python. The Tkinter edition imports AppKit when it needs to wake the window or rasterize an SVG. It is optional: the icon path falls back to Pillow drawing if AppKit is missing. pip install pyobjc.
03. Finding the Meeting When PortAudio Cannot See It
audio_devices.py asks Core Audio, through the standard-library ctypes module, for aggregate devices and their members. A Multi-Output Device shows up there even though PortAudio hid it. The function prefers a member whose name contains “blackhole”, then returns that member’s PortAudio input index. The meeting selector stores the choice as multi:<device name>. On the next launch, resolve_meeting_device turns that string back into an input index.
ordered = sorted(
member_names,
key=lambda item: (0 if "blackhole" in item.lower() else 1, item.lower()),
)
Auto mode does the same search without a saved Multi-Output name: first BlackHole input PortAudio already lists. Device names are never hardcoded as the only option. If BlackHole is absent, the meeting selector can still point at any other input.
04. Opening Both Streams Without Blocking the Window
start_session refuses to begin while Whisper is still loading. It then resolves two sources, microphone and meeting, and opens one InputStream per source at that device’s own sample rate. Callbacks run every 250 ms (blocksize = samplerate * 0.25). The meeting stream asks for two channels when the device has them, because loopback is often stereo. The callback itself only does to_mono and a queue put. The channel with more energy is the one kept, so a quiet side-channel does not become the transcript.
Transcription never runs inside the audio callback. A separate thread pulls chunks, runs the phrase detector, and put_nowaits a finished phrase onto a single worker queue. The worker checks a generation counter, so audio left over from the previous call is ignored after you press Start again.
When you press Stop, the streams close, the phrase thread is joined, and the worker is asked to finish whatever is already queued. The review packet is written only after that worker returns, on the UI thread. The window does not sit frozen while the last phrase transcribes.
05. When a Sentence Is Actually Over
take_speech_phrase in speech_audio.py is a small state machine per speaker. While nobody is talking it keeps a 350 ms pre-roll, so the start of a word is not clipped, and it tracks a noise floor with a slow average. Speech has to sit above that floor, and it has to last about 200 ms, before a phrase opens. A single click does not count.
Once speech has opened, quiet has to last 0.7 seconds before the phrase closes. A breath in the middle of a sentence stays inside the buffer. The phrase also closes if it reaches 8 seconds, so a monologue cannot stall the queue. Anything shorter than 0.4 seconds is thrown away.
ended = state["silent_frames"] >= int(sr * 0.7) or len(buffer) >= int(sr * 8.0)
prepare_speech_audio then decides whether the clip is worth a model call. Frames of 20 ms are scored by RMS. If the loud part of the clip is still room hiss, the function returns an empty array. Whisper will invent “Bye.” and “Thanks for watching” if you hand it amplified silence, so the empty array is the guard. Real speech is trimmed to the voiced middle, with a short pad, because a quiet tail is where those fake endings get appended.
The resampler converts whatever the hardware used (often 48 kHz, sometimes 16 kHz on a Bluetooth headset) to 16 kHz mono. That is the rate the speech model expects. Leveling pushes the phrase toward a peak of 0.95, with gain capped at 6. If a few samples are much louder than the rest of the phrase, a click, the gain is taken from a high quantile instead of that click, and the result is clipped so the waveform does not wrap.
06. What the Transcript Is Allowed to Say
transcribe_speech skips clips shorter than 350 ms. Language is None when the setting is auto-detect, otherwise the chosen code. Distilled checkpoints are decoded with beam_size=5. small.en and the other full checkpoints use a single beam, because a wider beam on a medium model spends seconds on one sentence. Temperature is 0. Timestamps are off. The library’s own VAD filter is off, because the phrase was already cut by the energy detector. Conditioning on previous text is off, so one bad line cannot drag the next one.
Each segment is dropped when it looks like non-speech, when its average log probability is worse than -1.1, or when its compression ratio is high enough to smell like a loop. The joined text is dropped again if it is a known hallucination (“thanks for watching”, “subscribe”), a stutter of hyphens, or a short line that repeats the same few words.
is_cross_talk_echo compares the new line with the previous line from the other speaker. SequenceMatcher ratio at or above 0.72 means the microphone and the loopback heard the same sentence. A person repeating themselves is kept, because the speaker label matches. A one- or two-word echo that is only words from the previous line is dropped too.
07. Asking One Profile, Then Refusing to Guess
On import, a ChatGPT conversations.json (or the zip export that contains it) is walked as a tree. Each message node with a text part longer than 15 characters becomes a chunk of the form [Thread: title] (role): text. Plain Markdown or text is split on blank lines. Chunks are added to the collection of the profile selected in the sidebar.
Collection names are prof_ plus a slug of the profile name. Chroma allows 3–63 characters from [a-zA-Z0-9_-], so the slug is cleaned with a regex and truncated. Default_Client and Other_Client cannot see each other’s chunks. Wiping a profile deletes that collection and creates an empty one. The exported files on disk are not the index. You can re-import after a reset.
generate_contextual_suggestion queries with the new line, and with the previous line glued on when there is one, so “what about the date we mentioned?” still has a chance to hit the right chunk. Six neighbors come back per query. Duplicates are removed. The survivors are numbered as DOCUMENTED MEMORY blocks and substituted for {context} in the system prompt. If you delete that placeholder, the blocks are appended anyway.
The user message is short: a couple of recent turns, then either “Participant said” or “I said”. The chat call uses the temperature and max tokens captured when the session started, so editing settings mid-call does not change a phrase already in flight. The reply is read from response.choices[0].message.content. An empty reply is replaced with the refusal line:
“I don’t have that documented in our prior work history, but let me check and follow up.”
That same sentence is the instruction inside the default system prompt. The model is told to speak in the first person, stay inside one or two sentences, and add a follow-up in brackets only when it helps. Temperature defaults to 0.
Default_Client ChromaDB fragments.
08. After the Call, and What a Resume Is Allowed to Contain
export_post_call_packet writes review_packet_<timestamp>.md. The top of the file is a fenced block that starts with UPDATE_WORKSPACE_MEMORY_PROTOCOL_INIT, names the profile, and pastes the verbatim turns. You copy that block into the ChatGPT thread for that client. The app does not post it for you.
A separate export, in call_export.py, can save the full dialogue or a meeting resume as Markdown, text, or CSV. The resume lists who spoke, how many turns, and the lines that were captured. Suggested replies are included under their own heading and labeled as suggestions. The resume does not promote them into decisions. If a line was not transcribed, it is not in the file.
lines.append(
"This resume restates the captured transcript. "
"It does not add agreements, dates, or decisions that were not spoken."
)
UPDATE_WORKSPACE_MEMORY_PROTOCOL_INIT and 1-click sync prompt copy.
09. Two Interfaces, Same Buttons in Different Clothes
The Tkinter edition keeps a thread-safe queue. Audio and model threads push UI updates onto it, and the main loop drains it. Calling widget methods from those threads is how Tk crashes on macOS, so the queue is the rule. Buttons are Label widgets with their own hover and release handling, because flat Tk buttons on recent macOS builds often swallow the click. The window is pulled forward with AppKit after it maps, for the same platform quirk.
The Aurora edition keeps the same session methods and stores view state in signals. Toasts take color tokens that start with $, such as $success. Icons there are SVG bytes from ui_icons.py. The Tkinter edition rasters those SVGs, trying AppKit first.
Both editions load Whisper on a daemon thread behind one lock, so two switches of the language dropdown cannot load two models at once. English offers the .en checkpoints. Other languages and auto-detect offer the multilingual ones. If the chosen checkpoint fails to load, the code tries base.en or base.
test_workflow.py and the headless UI tests exercise retrieval and the refusal line without you having to talk at the laptop.
10. Checking One Input Before a Call
test_audio.py is a terminal meter for a single input. The live app opens the microphone and the meeting stream together. This script opens one of them, so a silent side is obvious. Run it with python3 test_audio.py from ai_assistant/, or ./setup.sh --test.
It starts with sd.query_devices() and prints every device that reports input channels. Each line shows the PortAudio index, the channel count, and the device’s default sample rate. The system default input is marked. A name containing “BlackHole” is marked as the virtual loopback, and that index is remembered. If no such device exists, the script says so and points at brew install blackhole-2ch.
You then choose which device to open. In a terminal, Enter selects the default microphone (sd.default.device[0], or the first input if that default is missing). blackhole selects the loopback index. b, bh, and loopback mean the same thing. A number selects that PortAudio index, and it has to be one of the inputs just printed. q quits. The same tokens work as the first argument, so these skip the prompt:
python3 test_audio.py mic
python3 test_audio.py blackhole
python3 test_audio.py 2
If stdin is not a terminal, there is no prompt. The script monitors the default microphone and prints that choice. An unknown token or an output-only index exits without opening a stream. --help prints the usage and stops before the device scan.
run_diagnostics opens sd.InputStream on the chosen device for eight seconds. The stream is one channel, at that device’s own sample rate, with a block of 250 ms (blocksize = samplerate * 0.25). The callback computes the RMS and the absolute peak of the block with NumPy, keeps the highest peak seen, and redraws a 40-character bar on the same line. The bar fills in proportion to RMS times ten, so a quiet room stays near the left and speech or playback moves it. A | marks the peak hold.
rms = float(np.sqrt(np.mean(indata**2)))
peak = float(np.max(np.abs(indata)))
fill_len = int(bar_len * min(amplitude * 10, 1.0))
Ctrl+C stops the meter early and still prints the result. When the window ends, a peak below 0.005 is reported as silence. For a physical microphone that usually means Terminal does not have microphone permission under System Settings → Privacy & Security → Microphone. A higher peak means that input is delivering samples the capture path can hear. The script does not resample, transcribe, or query the vector store. It only answers whether the chosen device is moving. Run it once for the microphone and once for BlackHole when you want both sides checked.
11. References
- Python: docs.python.org/3
- Tkinter: tkinter
- ctypes: ctypes
- NumPy: numpy.org/doc
- SciPy
resample_poly: scipy.signal.resample_poly - sounddevice: python-sounddevice.readthedocs.io
- PortAudio: portaudio.com/docs
- Core Audio: Apple documentation
- BlackHole: ExistentialAudio/BlackHole
- faster-whisper: SYSTRAN/faster-whisper
- CTranslate2: OpenNMT/CTranslate2
- Whisper: openai/whisper
- ChromaDB: docs.trychroma.com
- OpenAI Python SDK: openai/openai-python
- Chat Completions API: platform.openai.com
- Ollama: ollama.com and the API docs
- Aurora UI: YoshiLoL0526/aurora
- Skia: skia.org/docs
- Taffy: docs.rs/taffy
- Pillow: pillow.readthedocs.io
- PyObjC: pyobjc.readthedocs.io
Open-Source Code & Interactive Project Showcase
Explore the full project showcase with all 12 high-resolution captures of the Aurora UI and Tkinter editions, or clone the source repository on GitHub:
Félix Pupo Pérez
Over 20 years of experience building bare-metal firmware, real-time audio and speech pipelines, industrial IoT telemetries, and grounded AI systems.