Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AVSynthesiser for Mac Engine #350

Merged
merged 60 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
911b5f9
Initial work. Looks all working
willwade Oct 26, 2024
7d673f3
updating engine to check hasattr queue in setBusy
willwade Oct 27, 2024
78f470c
fix for dict method in upstream
willwade Oct 27, 2024
ee2ba9f
Merge branch 'master' into AVSynth
willwade Oct 27, 2024
081403e
make avsynth new default
willwade Oct 27, 2024
5185138
remove debug print lines
willwade Oct 27, 2024
8b0680f
remove debug print lines from driver
willwade Oct 27, 2024
c2ffcfd
switch to espeak-ng and remove ffmpeg
willwade Oct 28, 2024
8c04122
Revert "switch to espeak-ng and remove ffmpeg"
willwade Oct 28, 2024
1f30d97
Update pyttsx3/drivers/avsynth.py
willwade Nov 3, 2024
74244e9
Update README.md
willwade Nov 3, 2024
8d9f2f0
add avsynth details
willwade Nov 3, 2024
5700684
Update docs/engine.rst
willwade Nov 3, 2024
3b21038
change objc signature
willwade Nov 3, 2024
28f836f
Merge branch 'cclauss-setuptools-py2cfg'
willwade Nov 3, 2024
bac73c8
Merge remote-tracking branch 'upstream/master'
willwade Nov 3, 2024
dae7a2f
Merge branch 'master' into AVSynth
willwade Nov 3, 2024
ea24252
update driver conflicts.
willwade Nov 3, 2024
8b19cca
sorting as per @cclauss suggestion
willwade Nov 3, 2024
a5ab2f3
Update MANIFEST
willwade Nov 4, 2024
dd3e9bd
Update MANIFEST
willwade Nov 4, 2024
fccb6e4
remove copied lines from lazy merge fixing in ruff commit
willwade Nov 4, 2024
9aae58a
Merge pull request #3 from nateshmbhat/master
willwade Nov 4, 2024
1aa6019
Initial work. Looks all working
willwade Oct 26, 2024
11931bf
updating engine to check hasattr queue in setBusy
willwade Oct 27, 2024
6537f6c
fix for dict method in upstream
willwade Oct 27, 2024
2140886
make avsynth new default
willwade Oct 27, 2024
9f06c55
remove debug print lines
willwade Oct 27, 2024
1cac90f
remove debug print lines from driver
willwade Oct 27, 2024
3032338
switch to espeak-ng and remove ffmpeg
willwade Oct 28, 2024
bd1af02
Revert "switch to espeak-ng and remove ffmpeg"
willwade Oct 28, 2024
6993fb1
Update pyttsx3/drivers/avsynth.py
willwade Nov 3, 2024
f7d996b
Update README.md
willwade Nov 3, 2024
f0b8a3c
Update docs/engine.rst
willwade Nov 3, 2024
f3b5383
change objc signature
willwade Nov 3, 2024
65ea358
update driver conflicts.
willwade Nov 3, 2024
6ed0397
sorting as per @cclauss suggestion
willwade Nov 3, 2024
16cb578
Update MANIFEST
willwade Nov 4, 2024
75d45fd
Update MANIFEST
willwade Nov 4, 2024
65622dd
remove copied lines from lazy merge fixing in ruff commit
willwade Nov 4, 2024
ffe8fed
adding @cclauss test..
willwade Nov 4, 2024
8c9cb5c
Merge branch 'AVSynth' of https://github.com/willwade/pyttsx3 into AV…
willwade Nov 4, 2024
143ee3b
fix imports in avsynth.py
willwade Nov 4, 2024
4fd90a9
AVSynth->AVSpeech
willwade Nov 13, 2024
e0e8e03
making nsss default for now
willwade Nov 13, 2024
2611d02
Merge branch 'master' into AVSynth
willwade Nov 13, 2024
227afbe
fixing the merge issue
willwade Nov 13, 2024
4484364
reworking to avspeech
willwade Nov 13, 2024
f9bd477
WARNING: This MAY BREAK OTHER ENGINES!
willwade Nov 13, 2024
b83bcb5
almost working
willwade Nov 13, 2024
30e577f
Update pyttsx3/drivers/avspeech.py
willwade Nov 13, 2024
e5257e4
Update tests/test_pyttsx3.py
willwade Nov 13, 2024
abdddc5
Update tests/test_pyttsx3.py
willwade Nov 13, 2024
75e9e8c
revert changes and formatting to engine.py
willwade Nov 13, 2024
afa5548
add logging instead of print
willwade Nov 13, 2024
4348576
Update avspeech.py
willwade Nov 13, 2024
ec31b84
fixes from ruff
willwade Nov 13, 2024
35ce007
ruff fixes pt 2
willwade Nov 13, 2024
0e57646
a bit more ruff fixes - notably logging and some annotations
willwade Nov 13, 2024
6d821db
now finally running pre-commit
willwade Nov 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ pyttsx3\drivers\_espeak.py
pyttsx3\drivers\dummy.py
pyttsx3\drivers\espeak.py
pyttsx3\drivers\nsss.py
pyttsx3\drivers\avsynth.py
pyttsx3\drivers\sapi5.py
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,10 @@ https://pyttsx3.readthedocs.io/en/latest/

#### Included TTS engines:

* sapi5
* nsss
* espeak
* sapi5 (Windows)
* nsss (Mac OS)
* avsynth (Mac OS)
* espeak (Linux, Mac OS, Windows)

Feel free to wrap another text-to-speech engine for use with ``pyttsx3``.

Expand Down
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ Included TTS engines:
*********************
* sapi5
* nsss
* avsynth
* espeak

Feel free to wrap another text-to-speech engine for use with ``pyttsx3``.
Expand Down
1 change: 1 addition & 0 deletions docs/engine.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ The Engine factory

* `sapi5` - SAPI5 on Windows
* `nsss` - NSSpeechSynthesizer on Mac OS X
* `avsynth` - AVSynthesizer on Mac OS X (NSSS Is deprecated)
* `espeak` - eSpeak on every other platform

:param debug: Enable debug output or not.
Expand Down
86 changes: 43 additions & 43 deletions pyttsx3/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


class DriverProxy(object):
'''
"""
Proxy to a driver implementation.

@ivar _module: Module containing the driver implementation
Expand All @@ -23,10 +23,10 @@ class DriverProxy(object):
@type _debug: bool
@ivar _iterator: Driver iterator to invoke when in an external run loop
@type _iterator: iterator
'''
"""

def __init__(self, engine, driverName, debug):
'''
"""
Constructor.

@param engine: Reference to the engine that owns the driver
Expand All @@ -36,13 +36,13 @@ def __init__(self, engine, driverName, debug):
@type driverName: str
@param debug: Debugging output enabled or not
@type debug: bool
'''
"""
driverName = driverName or {
'darwin': 'nsss',
'win32': 'sapi5',
}.get(sys.platform, 'espeak')
"darwin": "avsynth",
"win32": "sapi5",
}.get(sys.platform, "espeak")
# import driver module
self._module = importlib.import_module(f'pyttsx3.drivers.{driverName}')
self._module = importlib.import_module(f"pyttsx3.drivers.{driverName}")
# build driver instance
self._driver = self._module.buildDriver(weakref.proxy(self))
# initialize refs
Expand All @@ -52,7 +52,7 @@ def __init__(self, engine, driverName, debug):
self._name = None
self._iterator = None
self._debug = debug
self._current_text = ''
self._current_text = ""

def __del__(self):
try:
Expand All @@ -61,7 +61,7 @@ def __del__(self):
pass

def _push(self, mtd, args, name=None):
'''
"""
Adds a command to the queue.

@param mtd: Method to invoke to process the command
Expand All @@ -70,138 +70,138 @@ def _push(self, mtd, args, name=None):
@type args: tuple
@param name: Name associated with the command
@type name: str
'''
"""
self._queue.append((mtd, args, name))
self._pump()

def _pump(self):
'''
"""
Attempts to process the next command in the queue if one exists and the
driver is not currently busy.
'''
"""
while (not self._busy) and len(self._queue):
cmd = self._queue.pop(0)
self._name = cmd[2]
try:
cmd[0](*cmd[1])
except Exception as e:
self.notify('error', exception=e)
self.notify("error", exception=e)
if self._debug:
traceback.print_exc()

def notify(self, topic, **kwargs):
'''
"""
Sends a notification to the engine from the driver.

@param topic: Notification topic
@type topic: str
@param kwargs: Arbitrary keyword arguments
@type kwargs: dict
'''
if 'name' not in kwargs or kwargs['name'] is None: # Avoid overwriting
kwargs['name'] = self._name
"""
if "name" not in kwargs or kwargs["name"] is None: # Avoid overwriting
kwargs["name"] = self._name
self._engine._notify(topic, **kwargs)

def setBusy(self, busy):
'''
"""
Called by the driver to indicate it is busy.

@param busy: True when busy, false when idle
@type busy: bool
'''
"""
self._busy = busy
if not self._busy:
if not self._busy and hasattr(self, "_queue"):
self._pump()

def isBusy(self):
'''
"""
@return: True if the driver is busy, false if not
@rtype: bool
'''
"""
return self._busy

def say(self, text, name):
'''
"""
Called by the engine to push a say command onto the queue.

@param text: Text to speak
@type text: unicode
@param name: Name to associate with the utterance
@type name: str
'''
"""
self._current_text = text
self._push(self._driver.say, (text,), name)

def stop(self):
'''
"""
Called by the engine to stop the current utterance and clear the queue
of commands.
'''
"""
# clear queue up to first end loop command
while(True):
while True:
try:
mtd, args, name = self._queue[0]
except IndexError:
break
if(mtd == self._engine.endLoop):
if mtd == self._engine.endLoop:
break
self._queue.pop(0)
self._driver.stop()

def save_to_file(self, text, filename, name):
'''
"""
Called by the engine to push a say command onto the queue.

@param text: Text to speak
@type text: unicode
@param name: Name to associate with the utterance
@type name: str
'''
"""
self._push(self._driver.save_to_file, (text, filename), name)

def getProperty(self, name):
'''
"""
Called by the engine to get a driver property value.

@param name: Name of the property
@type name: str
@return: Property value
@rtype: object
'''
"""
return self._driver.getProperty(name)

def setProperty(self, name, value):
'''
"""
Called by the engine to set a driver property value.

@param name: Name of the property
@type name: str
@param value: Property value
@type value: object
'''
"""
self._push(self._driver.setProperty, (name, value))

def runAndWait(self):
'''
"""
Called by the engine to start an event loop, process all commands in
the queue at the start of the loop, and then exit the loop.
'''
"""
self._push(self._engine.endLoop, tuple())
self._driver.startLoop()

def startLoop(self, useDriverLoop):
'''
"""
Called by the engine to start an event loop.
'''
"""
if useDriverLoop:
self._driver.startLoop()
else:
self._iterator = self._driver.iterate()

def endLoop(self, useDriverLoop):
'''
"""
Called by the engine to stop an event loop.
'''
"""
self._queue = []
self._driver.stop()
if useDriverLoop:
Expand All @@ -211,10 +211,10 @@ def endLoop(self, useDriverLoop):
self.setBusy(True)

def iterate(self):
'''
"""
Called by the engine to iterate driver commands and notifications from
within an external event loop.
'''
"""
try:
next(self._iterator)
except StopIteration:
Expand Down
Loading
Loading