forked from Future423/Python-codes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpeak.py
More file actions
23 lines (18 loc) · 670 Bytes
/
Speak.py
File metadata and controls
23 lines (18 loc) · 670 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import pyttsx3
#this module is not in-built in your python
#you had to install it using pip command
engine = pyttsx3.init('sapi5')
#sapi5, windows voice
rate = engine.getProperty('rate')
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[5].id)
#may be you have many voices inn your Pc, choose one out of them in "voices[<>]"
#Example-<engine.setProperty('voice', voices[0].id)>
engine.setProperty('rate', 125)
#rate is speed of speaking, you can change it
#inetialing a function
def spk(audio):
engine.say(audio)
engine.runAndWait()
spk('I can speak')
#write in spk(<here>),what you had to make your code speak