whisper-smith is a small Python CLI/app helper for transcribing audio files with OpenAI speech-to-text models.
- Transcribe local audio files
- CLI-first workflow for quick terminal use
- Output as
txt,json,srt, orvtt - Automatically infer output format from output file extension
- Load environment variables from
.env
No local setup needed. Open the notebook directly in Colab and run the full speaker-aligned transcript pipeline on a free T4 GPU:
The notebook covers: install → set API keys → upload audio → run pipeline → download result. Use a GPU runtime for the best diarization performance. The notebook also includes an advanced GPU pipeline for explicitly moving the pyannote model to CUDA.
- Python
3.10+ - An OpenAI API key (
OPENAI_API_KEY) - For large-file fallback: either system
ffmpeginPATH, or Python packageimageio-ffmpeg - For optional speaker diarization: a Hugging Face token (
HUGGINGFACE_TOKEN) andpyannote.audio
uv syncpip install -e .uv sync --extra diarizeor:
pip install -e ".[diarize]"Set your API key in the environment or in a .env file:
export OPENAI_API_KEY="your_api_key_here"
export HUGGINGFACE_TOKEN="your_huggingface_token_here"Or create .env in project root:
OPENAI_API_KEY=your_api_key_here
HUGGINGFACE_TOKEN=your_huggingface_token_hereBasic command:
whisper-smith <audio_path>Show help:
whisper-smith --helpwhisper-smith data/sample.m4awhisper-smith data/sample.m4a --output data/sample.txtwhisper-smith data/sample.m4a --format json --output data/sample.jsonSupported CLI formats: txt, json, srt, vtt
whisper-smith data/sample.m4a --output data/sample.srtwhisper-smith data/sample.m4a --output data/sample.txt --overwritewhisper-smith data/sample.m4a --diarize --output data/sample.diarization.jsonDiarization currently supports JSON output only. Optional speaker hints:
whisper-smith data/sample.m4a --diarize --format json --num-speakers 2Run the full pipeline from one audio file:
whisper-smith data/sample.m4a --align --output data/sample.aligned.jsonThis writes the main aligned transcript JSON to data/sample.aligned.json and
also writes intermediate artifacts beside it:
data/sample.transcript.json
data/sample.diarization.json
To put the intermediate artifacts in a separate directory:
whisper-smith data/sample.m4a --align --output data/sample.aligned.json --artifacts-dir data/artifactsTurn transcript or aligned JSON into a spreadsheet-friendly CSV:
whisper-smith json-to-csv data/sample.aligned.json --output data/sample.csvThe CSV columns are start, end, start_dttm, speaker, and text.
Use --initial-datetime to make start_dttm relative to a real recording
start time:
whisper-smith json-to-csv data/sample.aligned.json --output data/sample.csv --initial-datetime 2026-06-10T09:00:00from pathlib import Path
from whisper_smith.transcribe import transcribe_audio
from whisper_smith.exporters import export_transcript
result = transcribe_audio(Path("data/sample.m4a"))
print(result.text)
srt = export_transcript(result, "srt")
Path("data/sample.srt").write_text(srt, encoding="utf-8")from pathlib import Path
from whisper_smith.diarize import diarize_audio
result = diarize_audio(Path("data/sample.m4a"))
for segment in result.segments:
print(segment.start, segment.end, segment.speaker)diarize_audio uses HUGGINGFACE_TOKEN from the environment, or accepts
hf_token="..." explicitly.
The default local model is pyannote/speaker-diarization-3.1, which is compatible
with the Intel macOS dependency set. You may pass a different model explicitly
from Python or with --diarization-model when running on a newer platform.
- If
--outputis omitted, transcript is printed to stdout. - If
--formatis omitted, format is inferred from--outputextension when possible. - If an output file already exists, add
--overwriteto replace it. - Transcription uses a timestamp-capable OpenAI model by default so JSON, SRT, and VTT outputs have segment timestamps.
- For large audio files,
whisper-smithautomatically splits audio into chunks and merges transcript text. - If diarization fails with
torchaudiomissingAudioMetaData, refresh the optional diarization dependencies withuv lock --upgrade-package torch --upgrade-package torchaudioand thenuv sync --extra diarize.
Run tests:
pytest