# espeak-ng
A Python bindings library for the [eSpeak NG](https://github.com/espeak-ng/espeak-ng?tab=readme-ov-file) utility, which is a compact open source software text-to-speech synthesizer with distributions for all major operating systems.
Platform support:
| Support | Platform | Architecture | Notes |
|---------|----------|--------------|-----------------------------|
| ✅ | MacOS | arm64 | Tested with M1 |
| ✅ | Linux | arm64 | Tested with Debian (Ubuntu) |
| | | | |
## Dependencies
This library provides Python bindings for the underlying `espeak-ng`
(or `espeak`), so obviously, you must have this library
installed. Follow instructions below for platform-specific
instructions.
**MacOS (using `brew`)**
```
$ brew tap justinokamoto/espeak-ng
$ brew install espeak-ng
```
**Debian (Ubuntu)**
```
# Install espeak library and headers, along with Python's C API headers
$ apt install libespeak-ng-dev python3-dev
```
## Installation
Provided you have installed the required dependencies described from
the previous section, you can download this Python package from the
Pythin Package Index:
```
$ pip install espeak-ng-python
```
## Usage
For all functions that this library wraps, it provides a near 1-to-1
wrapper interface, where all parameters are provided with identical
names. Only difference being that wrapper functions throw exceptions
rather than returning error codes (which is the more 'Pythonic' way of
error handling).
For more in-depth documentation you can read the comments within the
extension source code here:
[src/espeak\_ng/extension/\_espeakngmodule.c](https://github.com/justinokamoto/espeak-ng-python/blob/main/src/espeak_ng/extension/_espeakngmodule.c)
### Quick Start
#### Synchronous Mode
```python
import espeak_ng
# Initialize the espeak library
espeak_ng.initialize()
# This function will return after synthesis is complete
espeak_ng.synth("Hello, world.")
```
#### Asynchronous Mode
`espeak` offers a async interface. Below is an example snippet using
this interface:
```python
import espeak_ng
# NOTE: It's important to return 0 on success, otherwise synthesis will stop
def my_callback_func(wav: bytes, num_samples: int, event: espeak_ng.Event) -> int:
# ... my code here
return 0
# Initialize the espeak library in an asynchronous output mode
espeak_ng.initialize(output=espeak_AUDIO_OUTPUT.AUDIO_OUTPUT_PLAYBACK)
# This function will return immediately and the callback will be triggered as the synthesis
progresses
espeak_ng.set_synth_callback(my_callback_func)
```
#### Configuration
`espeak` supports various languages. To see all available options, you can list all voices:
```python
import espeak_ng
espeak_ng.list_voices()
```
To configure the voice, you can use the `set_voice_by_properties` function. Examples below:
```python
import espeak_ng
espeak_ng.set_voice_by_properties(name="en-us")
espeak_ng.set_voice_by_properties(gender=1)
espeak_ng.set_voice_by_properties(age=30)
```
## Building Locally
Install dependencies from the above "Dependencies" section. Then build this package using `pip`:
```
# Use pip to build in development (`-e` is for 'editable install')
$ pip install -e .
```
To run tests, use the helper `runtests` script:
```
$ python3 -m runtests
```
To build a local distribution archive, run:
```
$ pip wheel .
```
Raw data
{
"_id": null,
"home_page": "https://github.com/justinokamoto/espeak-ng-python",
"name": "espeak-ng-python",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "",
"keywords": "espeak pico festival tts text-to-speech",
"author": "Justin Okamoto",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/3c/e9/19ef02251746f2cff22f1e6a93af6a90ac9c2bd5ec7da5cad37ee9175708/espeak-ng-python-1.0.5.tar.gz",
"platform": null,
"description": "# espeak-ng\n\nA Python bindings library for the [eSpeak NG](https://github.com/espeak-ng/espeak-ng?tab=readme-ov-file) utility, which is a compact open source software text-to-speech synthesizer with distributions for all major operating systems.\n\nPlatform support:\n\n| Support | Platform | Architecture | Notes |\n|---------|----------|--------------|-----------------------------|\n| \u2705 | MacOS | arm64 | Tested with M1 |\n| \u2705 | Linux | arm64 | Tested with Debian (Ubuntu) |\n| | | | |\n\n## Dependencies\n\nThis library provides Python bindings for the underlying `espeak-ng`\n(or `espeak`), so obviously, you must have this library\ninstalled. Follow instructions below for platform-specific\ninstructions.\n\n**MacOS (using `brew`)**\n\n```\n$ brew tap justinokamoto/espeak-ng\n$ brew install espeak-ng\n```\n\n**Debian (Ubuntu)**\n\n```\n# Install espeak library and headers, along with Python's C API headers\n$ apt install libespeak-ng-dev python3-dev\n```\n\n## Installation\n\nProvided you have installed the required dependencies described from\nthe previous section, you can download this Python package from the\nPythin Package Index:\n\n```\n$ pip install espeak-ng-python\n```\n\n## Usage\n\nFor all functions that this library wraps, it provides a near 1-to-1\nwrapper interface, where all parameters are provided with identical\nnames. Only difference being that wrapper functions throw exceptions\nrather than returning error codes (which is the more 'Pythonic' way of\nerror handling).\n\nFor more in-depth documentation you can read the comments within the\nextension source code here:\n[src/espeak\\_ng/extension/\\_espeakngmodule.c](https://github.com/justinokamoto/espeak-ng-python/blob/main/src/espeak_ng/extension/_espeakngmodule.c)\n\n### Quick Start\n\n#### Synchronous Mode\n\n```python\nimport espeak_ng\n\n# Initialize the espeak library\nespeak_ng.initialize()\n\n# This function will return after synthesis is complete\nespeak_ng.synth(\"Hello, world.\")\n```\n\n#### Asynchronous Mode\n\n`espeak` offers a async interface. Below is an example snippet using\nthis interface:\n\n```python\nimport espeak_ng\n\n# NOTE: It's important to return 0 on success, otherwise synthesis will stop\ndef my_callback_func(wav: bytes, num_samples: int, event: espeak_ng.Event) -> int:\n # ... my code here\n return 0\n\n# Initialize the espeak library in an asynchronous output mode\nespeak_ng.initialize(output=espeak_AUDIO_OUTPUT.AUDIO_OUTPUT_PLAYBACK)\n\n# This function will return immediately and the callback will be triggered as the synthesis\nprogresses\nespeak_ng.set_synth_callback(my_callback_func)\n```\n\n#### Configuration\n\n`espeak` supports various languages. To see all available options, you can list all voices:\n\n```python\nimport espeak_ng\n\nespeak_ng.list_voices()\n```\n\nTo configure the voice, you can use the `set_voice_by_properties` function. Examples below:\n\n```python\nimport espeak_ng\n\nespeak_ng.set_voice_by_properties(name=\"en-us\")\nespeak_ng.set_voice_by_properties(gender=1)\nespeak_ng.set_voice_by_properties(age=30)\n```\n\n## Building Locally\n\nInstall dependencies from the above \"Dependencies\" section. Then build this package using `pip`:\n\n```\n# Use pip to build in development (`-e` is for 'editable install')\n$ pip install -e .\n```\n\nTo run tests, use the helper `runtests` script:\n\n```\n$ python3 -m runtests\n```\n\nTo build a local distribution archive, run:\n\n```\n$ pip wheel .\n```\n",
"bugtrack_url": null,
"license": "GPLv3",
"summary": "Python wrapper for espeak-ng.",
"version": "1.0.5",
"project_urls": {
"Homepage": "https://github.com/justinokamoto/espeak-ng-python"
},
"split_keywords": [
"espeak",
"pico",
"festival",
"tts",
"text-to-speech"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "3ce919ef02251746f2cff22f1e6a93af6a90ac9c2bd5ec7da5cad37ee9175708",
"md5": "e8a7343758c26857cb30b259bd20d1ed",
"sha256": "bb4953b632eb112e03d1d0c5230f74eb4c251824ec882e1f231521dd03f7af9c"
},
"downloads": -1,
"filename": "espeak-ng-python-1.0.5.tar.gz",
"has_sig": false,
"md5_digest": "e8a7343758c26857cb30b259bd20d1ed",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 22965,
"upload_time": "2024-03-05T23:06:47",
"upload_time_iso_8601": "2024-03-05T23:06:47.877739Z",
"url": "https://files.pythonhosted.org/packages/3c/e9/19ef02251746f2cff22f1e6a93af6a90ac9c2bd5ec7da5cad37ee9175708/espeak-ng-python-1.0.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-05 23:06:47",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "justinokamoto",
"github_project": "espeak-ng-python",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "espeak-ng-python"
}