|
4 | 4 | <h2 align="center">Offline Text To Speech (TTS) converter for Python </h2>
|
5 | 5 |
|
6 | 6 |
|
7 |
| -[](https://pepy.tech/project/pyttsx3)  [](https://github.com/nateshmbhat/pyttsx3) [](https://github.com/nateshmbhat/pyttsx3) [](https://pypi.org/project/pyttsx3/) [](https://github.com/nateshmbhat/pyttsx3) [](https://github.com/nateshmbhat) |
| 7 | +[](https://pepy.tech/badge/py3-tts) |
| 8 | +[](https://pepy.tech/badge/py3-tts/month) |
8 | 9 |
|
| 10 | +[](https://github.com/thevickypedia/py3-tts) |
| 11 | +[](https://github.com/thevickypedia/py3-tts) |
9 | 12 |
|
10 |
| -`pyttsx3` is a text-to-speech conversion library in Python. Unlike alternative libraries, **it works offline**. |
| 13 | +[](https://pypi.org/project/py3-tts/) |
11 | 14 |
|
12 |
| -<a class="bmc-button" target="_blank" href="https://www.buymeacoffee.com/nateshmbhat"><img src="https://cdn.buymeacoffee.com/buttons/bmc-new-btn-logo.svg" alt="Buy me a coffee 😇"><span style="margin-left:5px;font-size:19px !important;">Buy me a coffee 😇</span></a> |
| 15 | +[](https://github.com/thevickypedia/py3-tts) |
13 | 16 |
|
14 |
| -## Installation : |
| 17 | +[](https://github.com/thevickypedia) |
15 | 18 |
|
| 19 | +`py3-tts` is a text-to-speech conversion library in Python. Unlike alternative libraries, **it works offline**. |
16 | 20 |
|
17 |
| - pip install py3-tts |
| 21 | +## Installation |
18 | 22 |
|
19 |
| -> If you get installation errors , make sure you first upgrade your wheel version using : |
20 |
| -`pip install --upgrade wheel` |
| 23 | +```shell |
| 24 | +pip install py3-tts |
| 25 | +``` |
| 26 | + |
| 27 | +> If you get installation errors, make sure you first upgrade your wheel version using |
21 | 28 |
|
22 |
| -### Linux installation requirements : |
| 29 | +```shell |
| 30 | +pip install --upgrade wheel |
| 31 | +``` |
23 | 32 |
|
24 |
| -+ If you are on a linux system and if the voice output is not working , then : |
| 33 | +### Linux installation requirements |
25 | 34 |
|
26 |
| - Install espeak , ffmpeg and libespeak1 as shown below: |
| 35 | ++ If you are on a linux system and if the voice output is not working, |
27 | 36 |
|
28 |
| - ``` |
29 |
| - sudo apt update && sudo apt install espeak ffmpeg libespeak1 |
30 |
| - ``` |
| 37 | + Install `espeak`, `ffmpeg` and `libespeak1` as shown below |
31 | 38 |
|
| 39 | + ```shell |
| 40 | + sudo apt update && sudo apt install espeak ffmpeg libespeak1 |
| 41 | + ``` |
32 | 42 |
|
33 |
| -## Features : |
| 43 | +## Features |
34 | 44 |
|
35 | 45 | - ✨Fully **OFFLINE** text to speech conversion
|
36 | 46 | - 🎈 Choose among different voices installed in your system
|
|
39 | 49 | - 📀 Save the speech audio as a file
|
40 | 50 | - ❤️ Simple, powerful, & intuitive API
|
41 | 51 |
|
| 52 | +## Usage |
42 | 53 |
|
43 |
| -## Usage : |
44 |
| - |
45 |
| -```python3 |
| 54 | +```python |
46 | 55 | import pyttsx3
|
| 56 | + |
47 | 57 | engine = pyttsx3.init()
|
48 | 58 | engine.say("I will speak this text")
|
49 | 59 | engine.runAndWait()
|
50 | 60 | ```
|
51 | 61 |
|
52 | 62 | **Single line usage with speak function with default options**
|
53 | 63 |
|
54 |
| -```python3 |
| 64 | +```python |
55 | 65 | import pyttsx3
|
| 66 | + |
56 | 67 | pyttsx3.speak("I will speak this text")
|
57 | 68 | ```
|
58 | 69 |
|
59 |
| - |
60 |
| -**Changing Voice , Rate and Volume :** |
| 70 | +**Changing Voice, Rate and Volume** |
61 | 71 |
|
62 |
| -```python3 |
| 72 | +```python |
63 | 73 | import pyttsx3
|
64 |
| -engine = pyttsx3.init() # object creation |
65 | 74 |
|
66 |
| -""" RATE""" |
67 |
| -rate = engine.getProperty('rate') # getting details of current speaking rate |
68 |
| -print (rate) #printing current voice rate |
69 |
| -engine.setProperty('rate', 125) # setting up new voice rate |
| 75 | +engine = pyttsx3.init() # object creation |
70 | 76 |
|
| 77 | +""" RATE""" |
| 78 | +rate = engine.getProperty('rate') # getting details of current speaking rate |
| 79 | +print(rate) # printing current voice rate |
| 80 | +engine.setProperty('rate', 125) # setting up new voice rate |
71 | 81 |
|
72 | 82 | """VOLUME"""
|
73 |
| -volume = engine.getProperty('volume') #getting to know current volume level (min=0 and max=1) |
74 |
| -print (volume) #printing current volume level |
75 |
| -engine.setProperty('volume',1.0) # setting up volume level between 0 and 1 |
| 83 | +volume = engine.getProperty('volume') # getting to know current volume level (min=0 and max=1) |
| 84 | +print(volume) # printing current volume level |
| 85 | +engine.setProperty('volume', 1.0) # setting up volume level between 0 and 1 |
76 | 86 |
|
77 | 87 | """VOICE"""
|
78 |
| -voices = engine.getProperty('voices') #getting details of current voice |
79 |
| -#engine.setProperty('voice', voices[0].id) #changing index, changes voices. o for male |
80 |
| -engine.setProperty('voice', voices[1].id) #changing index, changes voices. 1 for female |
| 88 | +voices = engine.getProperty('voices') # getting details of current voice |
| 89 | +# engine.setProperty('voice', voices[0].id) #changing index, changes voices. o for male |
| 90 | +engine.setProperty('voice', voices[1].id) # changing index, changes voices. 1 for female |
81 | 91 |
|
82 | 92 | engine.say("Hello World!")
|
83 | 93 | engine.say('My current speaking rate is ' + str(rate))
|
84 | 94 | engine.runAndWait()
|
85 | 95 | engine.stop()
|
86 | 96 |
|
87 |
| - |
88 | 97 | """Saving Voice to a file"""
|
89 | 98 | # On linux make sure that 'espeak' and 'ffmpeg' are installed
|
90 | 99 | engine.save_to_file('Hello World', 'test.mp3')
|
91 | 100 | engine.runAndWait()
|
92 | 101 |
|
93 | 102 | ```
|
94 | 103 |
|
95 |
| - |
96 |
| - |
97 |
| - |
98 |
| -### **Full documentation of the Library** |
| 104 | +### Full documentation of the Library |
99 | 105 |
|
100 | 106 | https://pyttsx3.readthedocs.io/en/latest/
|
101 | 107 |
|
102 |
| - |
103 |
| -#### Included TTS engines: |
| 108 | +#### Included TTS engines |
104 | 109 |
|
105 | 110 | * sapi5
|
106 | 111 | * nsss
|
107 | 112 | * espeak
|
108 | 113 |
|
109 | 114 | Feel free to wrap another text-to-speech engine for use with ``pyttsx3``.
|
110 | 115 |
|
111 |
| -### Project Links : |
| 116 | +### Project Links |
112 | 117 |
|
113 |
| -* PyPI (https://pypi.python.org) |
114 |
| -* GitHub (https://github.com/nateshmbhat/pyttsx3) |
| 118 | +* PyPI (https://pypi.org/project/py3-tts/) |
| 119 | +* GitHub (https://github.com/thevickypedia/py3-tts) |
115 | 120 | * Full Documentation (https://pyttsx3.readthedocs.org)
|
| 121 | + |
| 122 | +### Credits |
| 123 | + |
| 124 | +**[nateshmbhat](https://github.com/nateshmbhat)** for the original code [pyttsx3](https://pypi.org/project/pyttsx3/) |
0 commit comments