mirror of
https://github.com/santinic/audiblez.git
synced 2025-04-13 09:38:57 +00:00
Merge pull request #74 from liiyee/main
Dynamically retrieves the Homebrew Cellar path
This commit is contained in:
commit
28a3f85a79
1 changed files with 8 additions and 1 deletions
|
@ -42,7 +42,14 @@ def set_espeak_library():
|
|||
if os.environ.get('ESPEAK_LIBRARY'):
|
||||
library = os.environ['ESPEAK_LIBRARY']
|
||||
elif platform.system() == 'Darwin':
|
||||
library = glob('/opt/homebrew/Cellar/espeak-ng/*/lib/*.dylib')[0]
|
||||
from subprocess import check_output
|
||||
try:
|
||||
cellar = Path(check_output(["brew", "--cellar"], text=True).strip())
|
||||
pattern = cellar / "espeak-ng" / "*" / "lib" / "*.dylib"
|
||||
if not (library := next(iter(glob(str(pattern))), None)):
|
||||
raise RuntimeError("No espeak-ng library found; please set the path manually")
|
||||
except (subprocess.CalledProcessError, FileNotFoundError) as e:
|
||||
raise RuntimeError("Cannot locate Homebrew Cellar. Is 'brew' installed and in PATH?") from e
|
||||
elif platform.system() == 'Linux':
|
||||
library = glob('/usr/lib/*/libespeak-ng*')[0]
|
||||
elif platform.system() == 'Windows':
|
||||
|
|
Loading…
Add table
Reference in a new issue