[![Downloads](https://static.pepy.tech/personalized-badge/pyttsx4?period=total&units=international_system&left_color=black&right_color=green&left_text=downloads)](https://pepy.tech/project/pyttsx4)
[![Downloads](https://static.pepy.tech/personalized-badge/pyttsx4?period=month&units=international_system&left_color=black&right_color=green&left_text=downloads/month)](https://pepy.tech/project/pyttsx4)
the code is mostly from pyttsx3.
only because the repo pyttsx3 does not update for years and some new feature i want is not here, i cloned this repo.
feature:
# supported engines:
```
1 nsss
2 sapi5
3 espeak
4 coqui_ai_tts
```
# basic features:
1 say
```
engine = pyttsx4.init()
engine.say('this is an english text to voice test.')
engine.runAndWait()
```
2 save to file
```
import pyttsx4
engine = pyttsx4.init()
engine.save_to_file('i am Hello World, i am a programmer. i think life is short.', 'test1.wav')
engine.runAndWait()
```
# extra features:
1 memory support for sapi5, nsss, espeak.
NOTE: the memory is just raw adc data, wav header has to be added if you want to save to wav file.
```
import pyttsx4
from io import BytesIO
from pydub import AudioSegment
from pydub.playback import play
import os
import sys
engine = pyttsx4.init()
b = BytesIO()
engine.save_to_file('i am Hello World', b)
engine.runAndWait()
#the bs is raw data of the audio.
bs=b.getvalue()
# add an wav file format header
b=bytes(b'RIFF')+ (len(bs)+38).to_bytes(4, byteorder='little')+b'WAVEfmt\x20\x12\x00\x00' \
b'\x00\x01\x00\x01\x00' \
b'\x22\x56\x00\x00\x44\xac\x00\x00' +\
b'\x02\x00\x10\x00\x00\x00data' +(len(bs)).to_bytes(4, byteorder='little')+bs
# changed to BytesIO
b=BytesIO(b)
audio = AudioSegment.from_file(b, format="wav")
play(audio)
sys.exit(0)
```
2 cloning voice
```
# only coqui_ai_tts engine support cloning voice.
engine = pyttsx4.init('coqui_ai_tts')
engine.setProperty('speaker_wav', './docs/i_have_a_dream_10s.wav')
engine.say('this is an english text to voice test, listen it carefully and tell who i am.')
engine.runAndWait()
```
voice clone test1:
![speaker_wav_test_1](./docs/i_have_a_dream_10s.wav)
![the output1](./docs/test_mtk.wav)
voice clone test2:
![speaker_wav_test_2](./docs/the_ballot_or_the_bullet_15s.wav)
![the output2](./docs/test_mx.wav)
----------------
the changelog:
1. add memory support for sapi5
2. add memory support for espeak(espeak is not tested).
eg:
```
b = BytesIO()
engine.save_to_file('i am Hello World', b)
engine.runAndWait()
```
3. fix VoiceAge key error
4. fix for sapi save_to_file when it run on machine without outputsream device.
5. fix save_to_file does not work on mac os ventura error. --3.0.6
6. add pitch support for sapi5(not tested yet). --3.0.8
7. fix nsss engine: Import super from objc to fix AttributeError by @matt-oakes.
8. add tts support:
deep-learning text to voice backend:
just say:
```
engine = pyttsx4.init('coqui_ai_tts')
engine.say('this is an english text to voice test.')
engine.runAndWait()
```
cloning someones voice:
```
engine = pyttsx4.init('coqui_ai_tts')
engine.setProperty('speaker_wav', './someones_voice.wav')
engine.say('this is an english text to voice test.')
engine.runAndWait()
```
demo output:
![test2](./docs/test2.wav)
NOTE:
if save_to_file with BytesIO, there is no wav header in the BytesIO.
the format of the bytes data is that 2-bytes = one sample.
if you want to add a header, the format of the data is:
1-channel. 2-bytes of sample width. 22050-framerate.
how to add a wav header in memory:https://github.com/Jiangshan00001/pyttsx4/issues/2
# how to use:
install:
```
pip install pyttsx4
```
use:
```
import pyttsx4
engine = pyttsx4.init()
```
the other usage is the same as the pyttsx3
----------------------
### **Full documentation of the Library**
https://pyttsx3.readthedocs.io/en/latest/
#### Included TTS engines:
* sapi5
* nsss
* espeak
Feel free to wrap another text-to-speech engine for use with ``pyttsx4``.
### Project Links :
* PyPI (https://pypi.python.org)
* GitHub (https://github.com/Jiangshan00001/pyttsx4)
* Full Documentation (https://pyttsx3.readthedocs.org)
Raw data
{
"_id": null,
"home_page": "https://github.com/Jiangshan00001/pyttsx4",
"name": "pyttsx4",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "pyttsx,ivona,pyttsx for python3,TTS for python3,pyttsx4,text to speech for python,tts,text to speech,speech,speech synthesis,offline text to speech,offline tts,gtts",
"author": "Natesh M Bhat",
"author_email": "710806594@qq.com",
"download_url": "",
"platform": null,
"description": "\n\n[![Downloads](https://static.pepy.tech/personalized-badge/pyttsx4?period=total&units=international_system&left_color=black&right_color=green&left_text=downloads)](https://pepy.tech/project/pyttsx4)\n[![Downloads](https://static.pepy.tech/personalized-badge/pyttsx4?period=month&units=international_system&left_color=black&right_color=green&left_text=downloads/month)](https://pepy.tech/project/pyttsx4)\n\n\nthe code is mostly from pyttsx3.\n\nonly because the repo pyttsx3 does not update for years and some new feature i want is not here, i cloned this repo.\n\nfeature:\n\n# supported engines:\n\n```\n1 nsss\n2 sapi5\n3 espeak\n4 coqui_ai_tts\n```\n\n# basic features:\n\n1 say\n```\nengine = pyttsx4.init()\nengine.say('this is an english text to voice test.')\nengine.runAndWait()\n```\n2 save to file\n\n```\nimport pyttsx4\n\nengine = pyttsx4.init()\nengine.save_to_file('i am Hello World, i am a programmer. i think life is short.', 'test1.wav')\nengine.runAndWait()\n\n```\n\n\n# extra features:\n\n1 memory support for sapi5, nsss, espeak.\nNOTE: the memory is just raw adc data, wav header has to be added if you want to save to wav file.\n\n```\nimport pyttsx4\nfrom io import BytesIO\nfrom pydub import AudioSegment\nfrom pydub.playback import play\nimport os\nimport sys\n\nengine = pyttsx4.init()\nb = BytesIO()\nengine.save_to_file('i am Hello World', b)\nengine.runAndWait()\n#the bs is raw data of the audio.\nbs=b.getvalue()\n# add an wav file format header\nb=bytes(b'RIFF')+ (len(bs)+38).to_bytes(4, byteorder='little')+b'WAVEfmt\\x20\\x12\\x00\\x00' \\\n b'\\x00\\x01\\x00\\x01\\x00' \\\n b'\\x22\\x56\\x00\\x00\\x44\\xac\\x00\\x00' +\\\n b'\\x02\\x00\\x10\\x00\\x00\\x00data' +(len(bs)).to_bytes(4, byteorder='little')+bs\n# changed to BytesIO\nb=BytesIO(b)\naudio = AudioSegment.from_file(b, format=\"wav\")\nplay(audio)\n\nsys.exit(0)\n```\n\n\n2 cloning voice \n```\n# only coqui_ai_tts engine support cloning voice.\nengine = pyttsx4.init('coqui_ai_tts')\nengine.setProperty('speaker_wav', './docs/i_have_a_dream_10s.wav')\n\nengine.say('this is an english text to voice test, listen it carefully and tell who i am.')\nengine.runAndWait()\n\n\n```\n\nvoice clone test1:\n\n![speaker_wav_test_1](./docs/i_have_a_dream_10s.wav)\n![the output1](./docs/test_mtk.wav)\n\n\nvoice clone test2:\n\n![speaker_wav_test_2](./docs/the_ballot_or_the_bullet_15s.wav)\n![the output2](./docs/test_mx.wav)\n\n\n\n----------------\n\n\n\n\n\n\n\nthe changelog:\n\n1. add memory support for sapi5\n2. add memory support for espeak(espeak is not tested). \n eg: \n\n```\nb = BytesIO()\nengine.save_to_file('i am Hello World', b)\nengine.runAndWait()\n```\n\n3. fix VoiceAge key error\n\n\n4. fix for sapi save_to_file when it run on machine without outputsream device.\n\n5. fix save_to_file does not work on mac os ventura error. --3.0.6\n\n6. add pitch support for sapi5(not tested yet). --3.0.8\n\n7. fix nsss engine: Import super from objc to fix AttributeError by @matt-oakes.\n\n8. add tts support:\n deep-learning text to voice backend:\n\njust say:\n```\nengine = pyttsx4.init('coqui_ai_tts')\nengine.say('this is an english text to voice test.')\nengine.runAndWait()\n```\n\ncloning someones voice:\n\n```\nengine = pyttsx4.init('coqui_ai_tts')\nengine.setProperty('speaker_wav', './someones_voice.wav')\n\nengine.say('this is an english text to voice test.')\nengine.runAndWait()\n\n```\n\ndemo output:\n\n![test2](./docs/test2.wav)\n\n\n\n\n\nNOTE:\n\nif save_to_file with BytesIO, there is no wav header in the BytesIO.\nthe format of the bytes data is that 2-bytes = one sample.\n\nif you want to add a header, the format of the data is:\n1-channel. 2-bytes of sample width. 22050-framerate.\n\nhow to add a wav header in memory:https://github.com/Jiangshan00001/pyttsx4/issues/2\n\n\n# how to use:\n\ninstall:\n```\npip install pyttsx4\n```\n\nuse:\n\n```\nimport pyttsx4\nengine = pyttsx4.init()\n```\n\nthe other usage is the same as the pyttsx3\n\n\n\n----------------------\n\n\n\n### **Full documentation of the Library**\n\nhttps://pyttsx3.readthedocs.io/en/latest/\n\n\n#### Included TTS engines:\n\n* sapi5\n* nsss\n* espeak\n\nFeel free to wrap another text-to-speech engine for use with ``pyttsx4``.\n\n### Project Links :\n\n* PyPI (https://pypi.python.org)\n* GitHub (https://github.com/Jiangshan00001/pyttsx4)\n* Full Documentation (https://pyttsx3.readthedocs.org)\n\n\n\n\n",
"bugtrack_url": null,
"license": "",
"summary": "Text to Speech (TTS) library for Python 3. Works without internet connection or delay. Supports multiple TTS engines, including Sapi5, nsss, and espeak.",
"version": "3.0.14",
"project_urls": {
"Homepage": "https://github.com/Jiangshan00001/pyttsx4"
},
"split_keywords": [
"pyttsx",
"ivona",
"pyttsx for python3",
"tts for python3",
"pyttsx4",
"text to speech for python",
"tts",
"text to speech",
"speech",
"speech synthesis",
"offline text to speech",
"offline tts",
"gtts"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "03513e657d0e50097dbdef319605c451d7491d5dfb32ee3bbae17c174c9ac345",
"md5": "f4985ae4c5701917b943bee7838aa7ca",
"sha256": "e9af4e692bf850a5b67af06446639f224dbeed9fe26510e55701416deba3b2d2"
},
"downloads": -1,
"filename": "pyttsx4-3.0.14-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f4985ae4c5701917b943bee7838aa7ca",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 29417,
"upload_time": "2023-06-17T08:49:58",
"upload_time_iso_8601": "2023-06-17T08:49:58.111933Z",
"url": "https://files.pythonhosted.org/packages/03/51/3e657d0e50097dbdef319605c451d7491d5dfb32ee3bbae17c174c9ac345/pyttsx4-3.0.14-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-06-17 08:49:58",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Jiangshan00001",
"github_project": "pyttsx4",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "six",
"specs": []
}
],
"lcname": "pyttsx4"
}