Restored TTS functionality from the old hal_main.py so HAL now speaks responses out loud.
File: hal_voice_assistant.py:13
import pyttsx3File: hal_voice_assistant.py:67
tts_engine = None # TTS engineFile: hal_voice_assistant.py:109-134
Initializes pyttsx3 engine with configuration from config file:
- Sets speech rate from
config.TTS_RATE - Sets volume from
config.TTS_VOLUME - Optionally sets voice from
config.TTS_VOICE
File: hal_voice_assistant.py:137-150
Simple function to speak text:
def speak(text):
"""Speak text using TTS (non-blocking)"""
tts_engine.say(text)
tts_engine.runAndWait()File: hal_voice_assistant.py:171-176
Added to initialize_system():
# Initialize TTS
eel_log("🔊 Initializing text-to-speech...")
if initialize_tts():
eel_log("✅ TTS ready")
else:
eel_log("⚠️ TTS initialization failed (will continue without speech)")File: hal_voice_assistant.py:251-253
After processing command and getting response:
# Speak response using TTS
loop = asyncio.get_event_loop()
await loop.run_in_executor(None, speak, response)Uses run_in_executor to run the blocking TTS call without blocking the async event loop.
TTS settings are in .env or config.py:
TTS_ENGINE=pyttsx3
TTS_RATE=150 # Words per minute
TTS_VOLUME=0.9 # 0.0 to 1.0
TTS_VOICE= # Leave empty for default voiceTo test TTS separately:
python test_tts.pyThis runs comprehensive TTS tests to verify audio output.
- User says wake word + command
- System transcribes speech to text
- Command is processed (MCP tool or LLM)
- Response text is displayed in GUI
- Response is spoken using TTS ✨
- System returns to listening
- TTS runs in thread executor to avoid blocking async event loop
- If TTS fails to initialize, system continues without speech (graceful degradation)
- Uses espeak backend on Linux (pyttsx3 default)
- Speech rate and volume are configurable