-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtext2speech.py
More file actions
33 lines (28 loc) · 941 Bytes
/
text2speech.py
File metadata and controls
33 lines (28 loc) · 941 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import pyttsx3
engine = pyttsx3.init()
voices = engine.getProperty('voices')
for i, v in enumerate(voices):
if v.id.lower() == 'english':
print(i)
print(v.id)
print(v.gender)
print(v.languages)
print(v.name)
print("---------------------")
# engine.setProperty('voice', voices[61].id) # Russian
engine.setProperty('voice', voices[12].id) # English
# 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
# Russian
# engine.say("Привет всем!")
# engine.say('Я говорю на скорости ' + str(rate))
# engine.runAndWait()
print(engine.isBusy())
# English
engine.say("Hello everybody!")
print(engine.isBusy())
engine.say('I"m speaking with speed ' + str(rate))
engine.runAndWait()
print(engine.isBusy())