-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.py
More file actions
39 lines (27 loc) · 1.08 KB
/
index.py
File metadata and controls
39 lines (27 loc) · 1.08 KB
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
import speech_recognition as sr
import re
import pyttsx3
nome = ""
while(True):
mic = sr.Recognizer()
with sr.Microphone() as source:
engine = pyttsx3.int()
engine.setProperty('voice', "com.apple.speech.synthesis.voice.luciana")
mic.adjust_for_ambient_noise(source)
print("Vamos começar, fale alguma coisa...")
audio = mic.listen(source)
try:
frase = mic.recognize_google(audio, language='pt-BR')
if(re.search(r'\b'+ "ajudar"+r'\b', format(frase))):
engine.say("Ajuda")
engine.runAndWait()
print("Algo relacionado a ajuda.")
elif(re.search(r'\b'+ "meu nome é "+r'\b', format(frase))):
t = re.search('meu nome é (.*)', format(frase))
nome = t.group(1)
print("Seu nome é "+nome)
engine.say("Nome falado foi "+nome);
engine.sunAndwait()
print("Você falou: "+frase)
except sr.UnknownValueError:
print("ops, algo deu errado.")