-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
73 lines (54 loc) · 1.99 KB
/
main.py
File metadata and controls
73 lines (54 loc) · 1.99 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import speech_recognition as sr
import pyttsx3
import datetime
import wikipedia
import webbrowser
audio = sr.Recognizer()
maquina = pyttsx3.init()
vozes = maquina.getProperty('voices')
maquina.setProperty('voice', vozes[0].id)
def executa_comando():
try:
with sr.Microphone() as source:
print('Ouvindo..')
audio.adjust_for_ambient_noise(source)
voz = audio.listen(source)
comando = audio.recognize_google(voz, language='pt-BR')
comando = comando.lower()
if 'artemis' in comando:
comando = comando.replace('artemis', '')
maquina.say(comando)
maquina.runAndWait()
except:
print('Microfone não está funcionando corretamente')
return comando
def comando_voz_usuario():
comando = executa_comando()
if 'horas' in comando:
hora = datetime.datetime.now().strftime('%H:%M')
maquina.say('Agora são' + hora)
maquina.runAndWait()
elif 'procure por' in comando:
procurar = comando.replace('procure por', '')
wikipedia.set_lang('pt')
resultado = wikipedia.summary(procurar, 2)
resposta = "claro"
print(resultado)
maquina.say(resposta)
maquina.say(resultado)
maquina.runAndWait()
elif 'abrir google' in comando:
comando.replace('abrir google', '')
google = f"https://google.com/"
resposta = "claro senhor"
maquina.say(resposta)
maquina.runAndWait()
webbrowser.open(google)
elif 'pesquisar por' in comando:
pesquisa = comando.replace('pesquisar por', '')
google_pesquisa = f"https://www.google.com/search?q={pesquisa}"
resposta = "claro senhor"
maquina.say(resposta)
maquina.runAndWait()
webbrowser.open(google_pesquisa)
comando_voz_usuario()