Streaming speech recognition with whisper-tiny on CPU
CPU · your Macscript120 minrequiredGoal · A chunked streaming transcriber built on whisper-tiny that reports real-time factor, latency to first partial transcript, and the accuracy cost of smaller chunks.
- 1pip install torch transformers datasets librosa jiwer; load openai/whisper-tiny with the transformers automatic-speech-recognition pipeline; build a 60-second English clip by concatenating LibriSpeech test-clean utterances from the datasets library (or use any 60-second English recording).
- 2Transcribe the full clip with the pipeline using chunk_length_s=30 and record wall time; compute RTF as wall time divided by 60 seconds. Keep this transcript as the reference.
- 3Write stream_transcribe(audio, chunk_s, overlap_s) that feeds consecutive chunks of chunk_s seconds with overlap_s seconds of overlap, runs the model on each, and merges text by dropping the overlapped prefix.
- 4Simulate live arrival by sleeping until each chunk would have been recorded; record the latency from chunk end to transcript emission for every chunk, and the time to the first partial transcript.
- 5Run chunk_s in 2, 5, 10 with overlap_s 0.5 and compute word error rate against the reference transcript with jiwer.
- 6Repeat the full-clip transcription with batch_size 8 over eight copies of the clip and compute audio seconds processed per wall second to see encoder batching.
- 7Write a short table of chunk size, RTF, first-partial latency and WER, and one paragraph on which setting you would ship for live captions.
- Deliverable
- stream_transcribe.py plus the results table and paragraph.
- Check
- RTF for the full clip is below 1.0 on your CPU; first-partial latency with chunk_s 2 is under 3 seconds; WER against the 30-second-chunk reference falls as chunk_s grows.