# src/pyttsx3_client.py # TTS client for pyttsx3 (Windows SAPI5 backend). # Baseline rule-based system — no neural net, no GPU. import pyttsx3 import time def synthesize(text: str, output_path: str, rate: int = 150, volume: float = 1.0) -> dict: """ Synthesize text to a .wav file using pyttsx3. Args: text: the string to synthesize output_path: where to save the .wav file rate: speaking rate in words per minute (default 150) volume: volume level 0.0 to 1.0 (default 1.0) Returns: dict with keys: output_path, latency_seconds, engine """ engine = pyttsx3.init() engine.setProperty("rate", rate) engine.setProperty("volume", volume) start = time.time() engine.save_to_file(text, output_path) engine.runAndWait() latency = time.time() - start engine.stop() return { "output_path": output_path, "latency_seconds": round(latency, 3), "engine": "pyttsx3", }