Skip to content

Commit

Permalink
Update documentation and README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
dormant-user committed Sep 10, 2023
1 parent 34c3346 commit 9335b33
Show file tree
Hide file tree
Showing 20 changed files with 267 additions and 273 deletions.
Binary file added .github/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<p align="center">
<img src="https://raw.githubusercontent.com/thevickypedia/py3-tts/master/.github/logo.svg?sanitize=true" width="200px" height="200px">
<img src="https://raw.githubusercontent.com/thevickypedia/py3-tts/master/.github/logo.png?sanitize=true" width="200px" height="200px">
</p>
<h2 align="center">Offline Text To Speech (TTS) converter for Python </h2>

Expand Down
56 changes: 28 additions & 28 deletions doc_generator/drivers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,58 +18,58 @@ All drivers must implement the following factory function and driver interface.
.. function:: buildDriver(proxy : pyttsx3.driver.DriverProxy) -> pyttsx3.drivers.DriverDelegate

Instantiates delegate subclass declared in this module.

:param proxy: Proxy instance provided by a :class:`pyttsx3.Engine` instance.

.. class:: DriverDelegate

.. note:: The :class:`DriverDelegate` class is not actually declared in :mod:`pyttsx3.drivers` and cannot serve as a base class. It is only here for the purpose of documenting the interface all drivers must implement.

.. method:: __init__(proxy : pyttsx3.drivers.DriverProxy, *args, **kwargs) -> None

Constructor. Must store the proxy reference.

:param proxy: Proxy instance provided by the :func:`buildDriver` function.

.. method:: destroy() ->

Optional. Invoked by the :class:`pyttsx3.driver.DriverProxy` when it is being destroyed so this delegate can clean up any synthesizer resources. If not implemented, the proxy proceeds safely.

.. method:: endLoop() -> None

Immediately ends a running driver event loop.

.. method:: getProperty(name : string) -> object

Immediately gets the named property value. At least those properties listed in the :meth:`pyttsx3.Engine.getProperty` documentation must be supported.

:param name: Name of the property to query.
:return: Value of the property at the time of this invocation.

.. method:: say(text : unicode, name : string) -> None

Immediately speaks an utterance. The speech must be output according to the current property values applied at the time of this invocation. Before this method returns, it must invoke :meth:`pyttsx3.driver.DriverProxy.setBusy` with value :const:`True` to stall further processing of the command queue until the output completes or is interrupted.

This method must trigger one and only one `started-utterance` notification when output begins, one `started-word` notification at the start of each word in the utterance, and a `finished-utterance` notification when output completes.

:param text: Text to speak.
:param name: Name to associate with the utterance. Included in notifications about this utterance.

.. method:: setProperty(name : string, value : object) -> None

Immediately sets the named property value. At least those properties listed in the :meth:`pyttsx3.Engine.setProperty` documentation must be supported. After setting the property, the driver must invoke :meth:`pyttsx3.driver.DriverProxy.setBusy` with value :const:`False` to pump the command queue.

:param name: Name of the property to change.
:param value: Value to set.

.. method:: startLoop()

Immediately starts an event loop. The loop is responsible for sending notifications about utterances and pumping the command queue by using methods on the :class:`pyttsx3.driver.DriverProxy` object given to the factory function that created this object.

.. method:: stop()

Immediately stops the current utterance output. This method must trigger a `finished-utterance` notification if called during on-going output. It must trigger no notification if there is no ongoing output.

After stopping the output and sending any required notification, the driver must invoke :meth:`pyttsx3.driver.DriverProxy.setBusy` with value :const:`False` to pump the command queue.

The DriverProxy interface
Expand All @@ -81,22 +81,22 @@ The DriverProxy interface
The :func:`pyttsx3.drivers.buildDriver` factory receives an instance of a :class:`DriverProxy` class and provides it to the :class:`pyttsx3.drivers.DriverDelegate` it constructs. The driver delegate can invoke the following public methods on the proxy instance. All other public methods found in the code are reserved for use by an :class:`pyttsx3.Engine` instance.

.. class:: DriverProxy

.. method:: isBusy() -> bool

Gets if the proxy is busy and cannot process the next command in the queue or not.

:return: True means busy, False means idle.

.. method:: notify(topic : string, **kwargs) -> None

Fires a notification.

:param topic: The name of the notification.
:kwargs: Name/value pairs associated with the topic.

.. method:: setBusy(busy : bool) -> None

Sets the proxy to busy so it cannot continue to pump the command queue or idle so it can process the next command.

:param busy: True to set busy, false to set idle
125 changes: 61 additions & 64 deletions doc_generator/engine.rst
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ Speaking text
engine.say('The quick brown fox jumped over the lazy dog.')
engine.runAndWait()


Saving voice to a file
######################

Expand All @@ -217,107 +216,105 @@ Saving voice to a file
engine.save_to_file('Hello World' , 'test.mp3')
engine.runAndWait()



Listening for events
####################

.. sourcecode:: python

import pyttsx3
def onStart(name):
print 'starting', name
def onWord(name, location, length):
print 'word', name, location, length
def onEnd(name, completed):
print 'finishing', name, completed
engine = pyttsx3.init()
engine.connect('started-utterance', onStart)
engine.connect('started-word', onWord)
engine.connect('finished-utterance', onEnd)
engine.say('The quick brown fox jumped over the lazy dog.')
engine.runAndWait()
import pyttsx3
def onStart(name):
print 'starting', name
def onWord(name, location, length):
print 'word', name, location, length
def onEnd(name, completed):
print 'finishing', name, completed
engine = pyttsx3.init()
engine.connect('started-utterance', onStart)
engine.connect('started-word', onWord)
engine.connect('finished-utterance', onEnd)
engine.say('The quick brown fox jumped over the lazy dog.', 'fox')
engine.runAndWait()

Interrupting an utterance
#########################

.. sourcecode:: python

import pyttsx3
def onWord(name, location, length):
print 'word', name, location, length
if location > 10:
engine.stop()
engine = pyttsx3.init()
engine.connect('started-word', onWord)
engine.say('The quick brown fox jumped over the lazy dog.')
engine.runAndWait()
import pyttsx3
def onWord(name, location, length):
print 'word', name, location, length
if location > 10:
engine.stop()
engine = pyttsx3.init()
engine.connect('started-word', onWord)
engine.say('The quick brown fox jumped over the lazy dog.', 'fox')
engine.runAndWait()

Changing voices
###############

.. sourcecode:: python

engine = pyttsx3.init()
voices = engine.getProperty('voices')
for voice in voices:
engine.setProperty('voice', voice.id)
engine.say('The quick brown fox jumped over the lazy dog.')
engine.runAndWait()
engine = pyttsx3.init()
voices = engine.getProperty('voices')
for voice in voices:
engine.setProperty('voice', voice.id)
engine.say('The quick brown fox jumped over the lazy dog.')
engine.runAndWait()

Changing speech rate
####################

.. sourcecode:: python

engine = pyttsx3.init()
rate = engine.getProperty('rate')
engine.setProperty('rate', rate+50)
engine.say('The quick brown fox jumped over the lazy dog.')
engine.runAndWait()
engine = pyttsx3.init()
rate = engine.getProperty('rate')
engine.setProperty('rate', rate+50)
engine.say('The quick brown fox jumped over the lazy dog.')
engine.runAndWait()

Changing volume
###############

.. sourcecode:: python

engine = pyttsx3.init()
volume = engine.getProperty('volume')
engine.setProperty('volume', volume-0.25)
engine.say('The quick brown fox jumped over the lazy dog.')
engine.runAndWait()
engine = pyttsx3.init()
volume = engine.getProperty('volume')
engine.setProperty('volume', volume-0.25)
engine.say('The quick brown fox jumped over the lazy dog.')
engine.runAndWait()

Running a driver event loop
###########################

.. sourcecode:: python

engine = pyttsx3.init()
def onStart(name):
print 'starting', name
def onWord(name, location, length):
print 'word', name, location, length
def onEnd(name, completed):
print 'finishing', name, completed
if name == 'fox':
engine.say('What a lazy dog!', 'dog')
elif name == 'dog':
engine.endLoop()
engine = pyttsx3.init()
engine.connect('started-utterance', onStart)
engine.connect('started-word', onWord)
engine.connect('finished-utterance', onEnd)
engine.say('The quick brown fox jumped over the lazy dog.', 'fox')
engine.startLoop()
engine = pyttsx3.init()
def onStart(name):
print 'starting', name
def onWord(name, location, length):
print 'word', name, location, length
def onEnd(name, completed):
print 'finishing', name, completed
if name == 'fox':
engine.say('What a lazy dog!', 'dog')
elif name == 'dog':
engine.endLoop()
engine = pyttsx3.init()
engine.connect('started-utterance', onStart)
engine.connect('started-word', onWord)
engine.connect('finished-utterance', onEnd)
engine.say('The quick brown fox jumped over the lazy dog.', 'fox')
engine.startLoop()

Using an external event loop
############################

.. sourcecode:: python

engine = pyttsx3.init()
engine.say('The quick brown fox jumped over the lazy dog.', 'fox')
engine.startLoop(False)
# engine.iterate() must be called inside externalLoop()
externalLoop()
engine.endLoop()
engine = pyttsx3.init()
engine.say('The quick brown fox jumped over the lazy dog.', 'fox')
engine.startLoop(False)
# engine.iterate() must be called inside externalLoop()
externalLoop()
engine.endLoop()
52 changes: 26 additions & 26 deletions doc_generator/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ First install the `pywin32-extensions <http://sourceforge.net/projects/pywin32/f

.. code-block:: bash
$ pip install py3-tts
$ pip install py3-tts
On OSX or Linux
###############

.. code-block:: bash
$ sudo pip install py3-tts
$ sudo pip install py3-tts
Using pip to install in a virtualenv
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand All @@ -45,12 +45,12 @@ You'll need to install the `pywin32-extensions <http://sourceforge.net/projects/

.. code-block:: bash
$ virtualenv --system-site-packages myproj
New python executable in myproj/bin/python
Installing setuptools............done.
Installing pip...............done.
$ myproj\Scripts\activate
(myproj)$ pip install py3-tts
$ virtualenv --system-site-packages myproj
New python executable in myproj/bin/python
Installing setuptools............done.
Installing pip...............done.
$ myproj\Scripts\activate
(myproj)$ pip install py3-tts
On OSX
######
Expand All @@ -59,15 +59,15 @@ Unless you wish to compile your own version of pyobjc (a lengthy process), you w

.. code-block:: bash
$ virtualenv --system-site-packages myproj
New python executable in myproj/bin/python
Installing setuptools............done.
Installing pip...............done.
$ . myproj/bin/activate
(myproj)$ pip install py3-tts
...
Successfully installed py3-tts
Cleaning up...
$ virtualenv --system-site-packages myproj
New python executable in myproj/bin/python
Installing setuptools............done.
Installing pip...............done.
$ . myproj/bin/activate
(myproj)$ pip install py3-tts
...
Successfully installed py3-tts
Cleaning up...
On Linux
########
Expand All @@ -76,15 +76,15 @@ pyttsx3 requires no Python dependencies on Linux. You can cut-off the pyttsx3 vi

.. code-block:: bash
$ virtualenv --no-site-packages myproj
New python executable in myproj/bin/python
Installing setuptools............done.
Installing pip...............done.
$ . myproj/bin/activate
(myproj)$ pip install py3-tts
...
Successfully installed py3-tts
Cleaning up...
$ virtualenv --no-site-packages myproj
New python executable in myproj/bin/python
Installing setuptools............done.
Installing pip...............done.
$ . myproj/bin/activate
(myproj)$ pip install py3-tts
...
Successfully installed py3-tts
Cleaning up...
.. _espeak: http://espeak.sourceforge.net/
Expand Down
2 changes: 1 addition & 1 deletion doc_generator/support.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Supported synthesizers
Supported Synthesizers
----------------------

Version |version| of py3-tts includes drivers for the following text-to-speech synthesizers. Only operating systems on which a driver is tested and known to work are listed. The drivers may work on other systems.
Expand Down
Loading

0 comments on commit 9335b33

Please sign in to comment.