-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
50 lines (40 loc) · 1.11 KB
/
main.py
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import speech_recognition as sr
import pyttsx3
import pywhatkit
name = 'eva'
listener = sr.Recognizer()
engine = pyttsx3.init()
engine.setProperty('rate', 120)
engine.setProperty('voice', 'spanish')
engine.setProperty('volume', 1.3)
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[0].id)
def talk(text):
engine.say(text)
engine.runAndWait()
def listen():
try:
with sr.Microphone() as source:
print("Escuchando...")
pc = listener.listen(source)
rec = listener.recognize_google(pc)
rec = rec.lower()
if name in rec:
rec = rec.replace(name, '')
except:
pass
return rec
def run_eva():
while True:
try:
rec = listen()
except UnboundLocalError:
print("No te entendí, intenta de nuevo")
continue
if 'reproduce' in rec:
music = rec.replace('reproduce', '')
print("Reproduciendo " + music)
talk("Reproduciendo " + music)
pywhatkit.playonyt(music)
if __name__ == '__main__':
run_eva()