File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,14 @@ def set_espeak_library():
42
42
if os .environ .get ('ESPEAK_LIBRARY' ):
43
43
library = os .environ ['ESPEAK_LIBRARY' ]
44
44
elif platform .system () == 'Darwin' :
45
- library = glob ('/opt/homebrew/Cellar/espeak-ng/*/lib/*.dylib' )[0 ]
45
+ from subprocess import check_output
46
+ try :
47
+ cellar = Path (check_output (["brew" , "--cellar" ], text = True ).strip ())
48
+ pattern = cellar / "espeak-ng" / "*" / "lib" / "*.dylib"
49
+ if not (library := next (iter (glob (str (pattern ))), None )):
50
+ raise RuntimeError ("No espeak-ng library found; please set the path manually" )
51
+ except (subprocess .CalledProcessError , FileNotFoundError ) as e :
52
+ raise RuntimeError ("Cannot locate Homebrew Cellar. Is 'brew' installed and in PATH?" ) from e
46
53
elif platform .system () == 'Linux' :
47
54
library = glob ('/usr/lib/*/libespeak-ng*' )[0 ]
48
55
elif platform .system () == 'Windows' :
You can’t perform that action at this time.
0 commit comments