How do you build offline AI speech recognition and text-to-speech systems?
Offline speech systems process audio entirely on-device. Speech-to-text: Whisper by OpenAI (multiple sizes from tiny at 39M to large-v3 at 1.5B parameters) provides state-of-the-art accuracy for 99 languages. Deployment: use whisper.cpp (C++ port with GGML) for CPU inference achieving real-time factor of 0.5-2x (processes audio faster than real-time on modern CPUs), faster-whisper (CTranslate2 backend, 4x faster than original), or Whisper ONNX for cross-platform deployment. Optimization: use VAD (Voice Activity Detection) to skip silence, implement streaming chunked transcription for real-time use, quantize to INT8 for 2x speed with minimal accuracy loss, and use beam size 1 for fastest inference. Text-to-speech: Piper TTS provides high-quality offline synthesis with voices for 30+ languages (each voice model is 15-60MB), Coqui TTS offers more natural prosody with larger models, and Microsoft SpeechT5 provides a versatile encoder-decoder architecture. Pipeline: audio capture with noise suppression, VAD for endpoint detection, speech recognition, optional NLU processing (intent classification, entity extraction), response generation, and TTS synthesis. On-device considerations: audio preprocessing (resampling to 16kHz mono for Whisper), buffer management for streaming input, and thermal management for continuous operation. Applications: meeting transcription, voice-controlled interfaces, accessibility tools, dictation systems, and call center analytics. Metrics: word error rate (WER) for STT accuracy, mean opinion score (MOS) for TTS quality, and processing latency for real-time suitability.