-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
86 lines (68 loc) · 1.77 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import subprocess
import wolframalpha
import pyttsx3
import tkinter
import json
import random
import operator
import speech_recognition as sr
import datetime
import wikipedia
import webbrowser
import os
import winshell
import smtplib
import feedparser
import time
import requests
import shutil
from twilio.rest import Client
from clint.textui import progress
from ecapture import ecapture as ec
from bs4 import BeautifulSoup
import win32com.client as wincl
from urllib.request import urlopen
engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[2].id)
wikipedia.set_lang("pt")
def speak(audio):
engine.say(audio)
engine.runAndWait()
def escutar():
hora = int(datetime.datetime.now().hour)
if hora >= 0 and hora < 12:
speak("Bom dia")
elif hora >= 12 and hora < 18:
speak("Boa tarde")
else:
speak("Boa noite")
def comandos():
r = sr.Recognizer()
with sr.Microphone() as source:
print("Escutando")
r.pause_threshold = 1
audio = r.listen(source)
try:
print("Recognizando...")
query = r.recognize_google(audio, language="pt-BR")
print(f"Usuário disse: {query}")
except Exception as e:
print(e)
print("Não consigo escutar sua voz")
return "None"
return query
## MAIN ##
if __name__ == '__main__':
clear = lambda: os.system('cls')
clear()
escutar()
while True:
query = comandos().lower()
##### BUSCA NA WIKI ###
if 'buscar sobre' in query:
query = query.replace("buscar sobre", "")
speak(f"Buscando sobre {query}")
results = wikipedia.summary(query, sentences = 3)
print(results)
speak(results)