Android On-Device Speech (TTS & STT) 🎤
Implementing accessible voice interfaces.
⚡ When to Use
- When handling local voice commands or reading text aloud.
🏗️ Core Rules / Pillars
1. Standard TTS initialization
- Pattern: Initialize
TextToSpeechand passOnInitListener. Always wait until initialization is successful before calling.speak().
2. SpeechRecognizer Intent
- Pattern: Use
SpeechRecognizer.createSpeechRecognizer(context)andRecognizerIntent.ACTION_RECOGNIZE_SPEECHfor local dictation.
🚧 Critical Anti-Hallucination Guards
- Trap: Ensure
RECORD_AUDIOpermission is requested before initializing the SpeechRecognizer.