Skip to content

Commit

Permalink
Merge pull request #343 from cclauss/dict-lookup-of-driver-by-sys.pla…
Browse files Browse the repository at this point in the history
…tform
  • Loading branch information
willwade authored Oct 27, 2024
2 parents d2c9427 + be2aca6 commit da247c1
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions pyttsx3/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,12 @@ def __init__(self, engine, driverName, debug):
@param debug: Debugging output enabled or not
@type debug: bool
'''
if driverName is None:
# pick default driver for common platforms
if sys.platform == 'darwin':
driverName = 'nsss'
elif sys.platform == 'win32':
driverName = 'sapi5'
else:
driverName = 'espeak'
driverName = driverName or {
'darwin': 'nsss',
'win32': 'sapi5',
}.get(sys.platform, 'espeak')
# import driver module
name = 'pyttsx3.drivers.%s' % driverName
self._module = importlib.import_module(name)
self._module = importlib.import_module(f'pyttsx3.drivers.{driverName}')
# build driver instance
self._driver = self._module.buildDriver(weakref.proxy(self))
# initialize refs
Expand Down

0 comments on commit da247c1

Please sign in to comment.