diff --git a/engine.py b/engine.py index 96f7d3b..b8b9917 100644 --- a/engine.py +++ b/engine.py @@ -228,17 +228,25 @@ def load_model() -> bool: # Auto-configure eSpeak for Linux by finding the system-installed library elif os.name == "posix": # Linux/macOS - logger.info("Checking for system-installed eSpeak NG on Linux...") + logger.info("Checking for system-installed eSpeak NG on Linux/Mac...") # By setting the library path, we let phonemizer handle finding the data path, which is more robust. - espeak_lib_path = "/usr/lib/x86_64-linux-gnu/libespeak-ng.so" - if Path(espeak_lib_path).exists(): - os.environ["PHONEMIZER_ESPEAK_LIBRARY"] = espeak_lib_path + possible_paths = [ + Path("/usr/lib/x86_64-linux-gnu/libespeak-ng.so"), + Path("/opt/homebrew/lib/libespeak-ng.dylib"), + ] + espeak_found = False + for espeak_lib_path in possible_paths: + if not espeak_lib_path.exists(): + continue + os.environ["PHONEMIZER_ESPEAK_LIBRARY"] = str(espeak_lib_path) logger.info( f"Found and configured system eSpeak NG library: {espeak_lib_path}" ) - else: + espeak_found = True + break + if not espeak_found: logger.warning( - f"Could not find system eSpeak NG library at {espeak_lib_path}. " + f"Could not find system eSpeak NG library at {possible_paths}. " "Please ensure 'espeak-ng' is installed via your package manager." )