Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Akul2010 authored Feb 6, 2023
1 parent 5ca6e1d commit ee6ca0f
Show file tree
Hide file tree
Showing 27 changed files with 3,747 additions and 23 deletions.
394 changes: 373 additions & 21 deletions LICENSE

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions MANIFEST
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# file GENERATED by distutils, do NOT edit
setup.cfg
setup.py
pyttsx3\__init__.py
pyttsx3\driver.py
pyttsx3\engine.py
pyttsx3\six.py
pyttsx3\voice.py
pyttsx3\drivers\__init__.py
pyttsx3\drivers\_espeak.py
pyttsx3\drivers\dummy.py
pyttsx3\drivers\espeak.py
pyttsx3\drivers\nsss.py
pyttsx3\drivers\sapi5.py
110 changes: 108 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,108 @@
# rlvoice
A STT engine for AkulAI and more.
<center><b>Credits to nateshmbhat for creating the original library pyttsx3</b></center>

<h2 align="center">Offline Text To Speech (TTS) converter for Python </h2>


[![Downloads](https://pepy.tech/badge/pyttsx3)](https://pepy.tech/project/pyttsx3) ![Downloads](https://pepy.tech/badge/pyttsx3/week) [![](https://img.shields.io/github/languages/code-size/nateshmbhat/pyttsx3.svg?style=plastic)](https://github.com/nateshmbhat/pyttsx3) [![](https://img.shields.io/github/license/nateshmbhat/pyttsx3?style=plastic)](https://github.com/nateshmbhat/pyttsx3) [![](https://img.shields.io/pypi/v/pyttsx3.svg?style=plastic)](https://pypi.org/project/pyttsx3/) [![](https://img.shields.io/github/languages/top/nateshmbhat/pyttsx3.svg?style=plastic)](https://github.com/nateshmbhat/pyttsx3) [![](https://img.shields.io/badge/author-nateshmbhat-green.svg)](https://github.com/nateshmbhat)


`RLVoice` is a text-to-speech conversion library in Python. Unlike alternative libraries, **it works offline**.

## Installation :


pip install rlvoice

> If you get installation errors , make sure you first upgrade your wheel version using :
`pip install --upgrade wheel`

### Linux installation requirements :

+ If you are on a linux system and if the voice output is not working , then :

Install espeak , ffmpeg and libespeak1 as shown below:

```
sudo apt update && sudo apt install espeak ffmpeg libespeak1
```


## Features :

- ✨Fully **OFFLINE** text to speech conversion
- 🎈 Choose among different voices installed in your system
- 🎛 Control speed/rate of speech
- 🎚 Tweak Volume
- 📀 Save the speech audio as a file
- ❤️ Simple, powerful, & intuitive API


## Usage :

```python3
import rlvoice

engine = rlvoice.init()
engine.say("I will speak this text")
engine.runAndWait()
```

**Single line usage with speak function with default options**

```python3
import rlvoice

rlvoice.speak("I will speak this text")
```


**Changing Voice , Rate and Volume :**

```python3
import rlvoice

engine = rlvoice.init() # object creation

""" RATE"""
rate = engine.getProperty('rate') # getting details of current speaking rate
print(rate) # printing current voice rate
engine.setProperty('rate', 125) # setting up new voice rate

"""VOLUME"""
volume = engine.getProperty('volume') # getting to know current volume level (min=0 and max=1)
print(volume) # printing current volume level
engine.setProperty('volume', 1.0) # setting up volume level between 0 and 1

"""VOICE"""
voices = engine.getProperty('voices') # getting details of current voice
# engine.setProperty('voice', voices[0].id) #changing index, changes voices. o for male
engine.setProperty('voice', voices[1].id) # changing index, changes voices. 1 for female

engine.say("Hello World!")
engine.say('My current speaking rate is ' + str(rate))
engine.runAndWait()
engine.stop()

"""Saving Voice to a file"""
# On linux make sure that 'espeak' and 'ffmpeg' are installed
engine.save_to_file('Hello World', 'test.mp3')
engine.runAndWait()

```


Full documentation is located in the ```docs``` folder.


#### Included TTS engines:

* sapi5
* nsss
* espeak

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

### Project Links :

* PyPI (https://pypi.python.org)
* GitHub (https://github.com/Akul-AI/rlvoice)
90 changes: 90 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
*****************************************************
pyttsx3 (offline TTS for Python 3)
*****************************************************

``pyttsx3`` is a text-to-speech conversion library in Python. Unlike alternative libraries, it works offline, and is compatible with both Python 2 and 3.

Installation
************
::

pip install pyttsx3


> If you get installation errors , make sure you first upgrade your wheel version using :
`pip install --upgrade wheel`

**Linux installation requirements :**
#####################################

+ If you are on a linux system and if the voice output is not working , then :

Install espeak , ffmpeg and libespeak1 as shown below:

::

sudo apt update && sudo apt install espeak ffmpeg libespeak1


Usage :
************
::

import pyttsx3
engine = pyttsx3.init()
engine.say("I will speak this text")
engine.runAndWait()
**Changing Voice , Rate and Volume :**

::

import pyttsx3
engine = pyttsx3.init() # object creation

""" RATE"""
rate = engine.getProperty('rate') # getting details of current speaking rate
print (rate) #printing current voice rate
engine.setProperty('rate', 125) # setting up new voice rate


"""VOLUME"""
volume = engine.getProperty('volume') #getting to know current volume level (min=0 and max=1)
print (volume) #printing current volume level
engine.setProperty('volume',1.0) # setting up volume level between 0 and 1

"""VOICE"""
voices = engine.getProperty('voices') #getting details of current voice
#engine.setProperty('voice', voices[0].id) #changing index, changes voices. o for male
engine.setProperty('voice', voices[1].id) #changing index, changes voices. 1 for female

engine.say("Hello World!")
engine.say('My current speaking rate is ' + str(rate))
engine.runAndWait()
engine.stop()

"""Saving Voice to a file"""
# On linux make sure that 'espeak' and 'ffmpeg' are installed
engine.save_to_file('Hello World', 'test.mp3')
engine.runAndWait()


**Full documentation of the Library**
#####################################

See the included docs folder

Included TTS engines:
*********************
* sapi5
* nsss
* espeak

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

Project Links:
**************

* PyPI (https://pypi.python.org)
* GitHub (https://github.com/Akul-AI/rlvoice)
102 changes: 102 additions & 0 deletions docs/drivers.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
Implementing drivers
--------------------

You can implement new drivers for the :mod:`pyttsx3.Engine` by:

#. Creating a Python module with the name of your new driver.
#. Implementing the required driver factory function and class in your module.
#. Using methods on a :class:`pyttsx3.driver.DriverProxy` instance provided by the :class:`pyttsx3.Engine` to control the event queue and notify applications about events.

The Driver interface
~~~~~~~~~~~~~~~~~~~~

All drivers must implement the following factory function and driver interface.

.. module:: pyttsx3.drivers
:synopsis: The package containing the available driver implementations

.. 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
~~~~~~~~~~~~~~~~~~~~~~~~~

.. module:: pyttsx3.driver
:synopsis: The module containing the driver proxy implementation

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
Loading

0 comments on commit ee6ca0f

Please sign in to comment.