# Voice Implementation Plan (Phases 6 & 7) ## Research Summary ### OpenAI Whisper API (STT) **Key Findings:** - **No Native Streaming Support**: OpenAI Whisper API does NOT support real-time streaming transcription - **Batch Processing Only**: Must send complete audio files after recording stops - **Supported Formats**: flac, m4a, mp3, mp4, mpeg, mpga, oga, ogg, wav, webm - **File Size Limit**: 25 MB maximum - **API Endpoint**: `/v1/audio/transcriptions` - **Strategy**: Push-to-talk (click to record, click to stop, then transcribe) **Alternative Considered:** - OpenAI Realtime API provides true streaming STT+LLM+TTS in one WebSocket connection - However, it's a different architecture (conversational AI vs tool-calling assistant) - For this phase, we'll use Whisper API with push-to-talk model ### OpenAI TTS API **Key Findings:** - **Streaming Supported**: Yes, via chunk transfer encoding - **Supported Formats**: mp3, opus, aac, flac, wav, pcm - **Available Voices**: alloy, echo, fable, onyx, nova, shimmer - **Quality Models**: - `tts-1`: Faster, lower latency, normal quality - `tts-1-hd`: Higher quality, slower - **API Endpoint**: `/v1/audio/speech` - **Default Format**: MP3 ### Browser Audio APIs **MediaRecorder API (Audio Capture):** - **Widely Supported**: Chrome, Firefox, Safari, Edge (since 2021) - **Format Support Varies**: - Chrome/Opera: `audio/webm;codecs=opus` - Firefox: `audio/ogg;codecs=opus` (also supports webm since Firefox 63) - Need to check `MediaRecorder.isTypeSupported()` at runtime - **Recommended Approach**: Capture as WebM/Opus, convert if needed - **Events**: `dataavailable` for chunks, `stop` for complete recording **Web Audio API (Audio Playback):** - **Challenge**: `decodeAudioData()` requires complete files, not chunks - **Solution Options**: 1. Use `