├── .gitignore ├── .idea ├── .gitignore ├── AsistenteVirtual.iml ├── inspectionProfiles │ └── profiles_settings.xml ├── misc.xml ├── modules.xml └── vcs.xml ├── README.md ├── asistenteVirtual.py ├── driver └── edgedriver.exe └── resource ├── abrirwts.mp3 ├── audio └── voz.mp3 ├── chiste1.mp3 ├── chiste2.mp3 ├── errorRespuesta.mp3 ├── leer.txt ├── obligame.mp3 └── valida.mp3 /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /.idea/AsistenteVirtual.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## ASISTENTE VIRTUAL 🤖 2 | 3 | Asistente virtual que realiza tareas por comando de voz que programes, El limite es tu imaginacion ;) 4 | 5 | 6 | ### Pre-requisitos 📋 7 | 8 | 1. Instalar librerias, si ejecutas el siguiente comando en la consola de tu sistema operativo se descargara automaticamente: 9 | > pip install selenium 10 | 11 | > pip install gtts 12 | 13 | > pip install playsound 14 | 15 | > pip install speech_recognition 16 | 17 | 1. Instalar pyAudio, si ejecutas el siguiente comando en la consola de tu sistema operativo se descargara automaticamente: 18 | > pip install pipwin 19 | 20 | > pipwin install PyAudio 21 | 22 | 1. Descargar el webDriver que corresponda a su browser preferido 23 | > Web Drivers 24 | 25 | Chrome: 26 | https://sites.google.com/a/chromium.org/chromedriver/downloads 27 | 28 | Edge: 29 | https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/ 30 | 31 | Mozzilla: 32 | https://github.com/mozilla/geckodriver/releases 33 | 34 | Safari: 35 | https://webkit.org/blog/6900/webdriver-support-in-safari-10/ 36 | 37 | ### Ejecución 🔧 38 | 39 | _Procedemos a ejecutar el siguiente comando para levantar el proyecto_ 40 | 41 | ``` 42 | python .\asistenteVirtual.py 43 | ``` 44 | 45 | 65 | 66 | 69 | 70 | ## Construido con 🛠️ 71 | 72 | * [VS CODE](https://code.visualstudio.com/) - Editor de texto 73 | * [Python](https://www.python.org/) - Lenguaje de Programación 74 | 75 | ## Versionado 📌 76 | 77 | Usamos [SemVer](http://semver.org/) para el versionado. Para todas las versiones disponibles, mira los [tags en este repositorio](https://github.com/Strange-Code/DetectorRostro/tags). 78 | 79 | ## Autores ✒️ 80 | 81 | * **Renato Ponce** - *Desarrollo* - [renato-ponce98](https://github.com/renato-ponce98) 82 | * **Gustavo Jimenez** - *Desarrollo* - [Strngrwrld](https://github.com/Strngrwrld) 83 | 84 | También puedes mirar la lista de todos los [contribuyentes](https://github.com/Strange-Code/DetectorRostro/contributors) quíenes han participado en este proyecto. 85 | 86 | 87 | ## Expresiones de Gratitud 🎁 88 | 89 | * Comenta a otros sobre este proyecto 📢 90 | * Invita una cerveza 🍺 o un café ☕ a alguien del equipo. 91 | * Da las gracias públicamente 🤓. 92 | * etc. 93 | 94 | ## [Strange Code](https://github.com/Strange-Code) 😊 95 | 96 | ![](https://avatars.githubusercontent.com/u/79027421?s=200&v=4) 97 | -------------------------------------------------------------------------------- /asistenteVirtual.py: -------------------------------------------------------------------------------- 1 | from selenium import webdriver 2 | import time 3 | from speech_recognition import Microphone, Recognizer, AudioFile, UnknownValueError, RequestError 4 | from gtts import gTTS 5 | from playsound import playsound 6 | import random 7 | 8 | #DECLARAR VARIABLES UNIVERSALES 9 | validaAuth = False 10 | browser = webdriver 11 | 12 | 13 | def validaQR(): 14 | try: 15 | element = browser.find_element_by_tag_name("canvas") 16 | except: 17 | return False 18 | return True 19 | 20 | def buscarChat(nombreChat : str): 21 | print("BUSCANDO CHAT : ", nombreChat) 22 | elements = browser.find_elements_by_tag_name("span") 23 | for element in elements: 24 | print("CHAT ENCONTRADO : " + str(element.text).lower()) 25 | if element.text !='' and nombreChat.__contains__(str(element.text).lower()): 26 | element.click() 27 | return 28 | print("NO ENCONTRO CHAT") 29 | 30 | def escribir(texto): 31 | print("escribiendo...") 32 | cajitaDeTexto = browser.find_element_by_xpath('//*[@id="main"]/footer/div[1]/div[2]/div/div[2]') 33 | cajitaDeTexto.send_keys(texto) 34 | 35 | def enviar(): 36 | print("enviado...") 37 | enviar = browser.find_element_by_xpath('//*[@id="main"]/footer/div[1]/div[3]') 38 | enviar.click() 39 | 40 | def bootWhatsapp(): 41 | browser.get("https://web.whatsapp.com/") 42 | time.sleep(5) 43 | 44 | ##variable de espera 45 | espera = True 46 | print("AUTENTICATE POR FAVOR") 47 | 48 | while espera: 49 | espera = validaQR() 50 | time.sleep(2) 51 | if espera == False: 52 | global validaAuth 53 | validaAuth = True 54 | print("SE AUTENTICO") 55 | break 56 | 57 | def activarAsistente(): 58 | escuchar() 59 | while True: 60 | time.sleep(1) 61 | 62 | def escuchar(): 63 | print("Escuchando...") 64 | recognizer = Recognizer() 65 | microfono = Microphone() 66 | 67 | with microfono: 68 | recognizer.adjust_for_ambient_noise(microfono) 69 | 70 | recognizer.listen_in_background(microfono,callback) 71 | 72 | def callback(recognizer, source): 73 | print("Reconociendo...") 74 | 75 | try: 76 | reconocer = recognizer.recognize_google(source, language='es-ES') 77 | texto = str(reconocer).lower() 78 | print("Escuche : ", texto) 79 | if(texto.__contains__("eva")): 80 | print("Llamo a eva") 81 | texto = texto.replace("eva","") 82 | accion(texto) 83 | return 84 | 85 | except RequestError as exc: 86 | print("Error al escuhar : ", exc) 87 | except UnknownValueError: 88 | print("No entendi :c") 89 | playsound('./resource/errorRespuesta.mp3') 90 | time.sleep(1) 91 | 92 | def accion(texto: str): 93 | 94 | print("Reconociendo accion...") 95 | 96 | if(texto.__contains__("abrir whatsapp")): 97 | print("Abriendo whatsapp...") 98 | playsound('./resource/abrirwts.mp3') 99 | time.sleep(1) 100 | global browser 101 | browser = webdriver.Edge(executable_path="./driver/edgedriver") 102 | bootWhatsapp() 103 | 104 | if(texto.__contains__("enviar mensaje a")): 105 | if(validaAuth == False): 106 | 107 | print("Autenticate por favor") 108 | playsound('./resource/abrirwts.mp3') 109 | time.sleep(1) 110 | return 111 | 112 | texto = texto.replace("enviar mensaje a", "") 113 | buscarChat(texto) 114 | return 115 | 116 | if(texto.__contains__("escribir")): 117 | texto = texto.replace("escribir", "") 118 | escribir(texto) 119 | return 120 | 121 | if(texto.__contains__("enviar")): 122 | enviar() 123 | return 124 | 125 | if(texto.__contains__("cuenta un chiste")): 126 | chiste() 127 | return 128 | 129 | if(texto.__contains__("cerrar explorador")): 130 | print("cerrando browser...") 131 | browser.close() 132 | return 133 | 134 | print("Accion no encontrada...") 135 | return 136 | 137 | def chiste(): 138 | print("CONTANDO CHISTE...") 139 | aleatorio = random.randrange(2) 140 | 141 | print("CONTANDO CHISTE : ", str(aleatorio)) 142 | 143 | if(aleatorio == 1): 144 | playsound('./resource/obligame.mp3') 145 | #playsound('./resource/chiste1.mp3') 146 | else: 147 | playsound('./resource/chiste2.mp3') 148 | 149 | time.sleep(1) 150 | return 151 | 152 | def hablar(texto: str): 153 | print("Hablando...") 154 | audio = gTTS(text=texto,lang='es-us',slow=False) 155 | audio.save('./resource/obligame.mp3') 156 | #time.sleep(1) 157 | #playsound('./resource/chiste1.mp3') 158 | return 159 | 160 | 161 | 162 | activarAsistente() 163 | #hablar('obligame perro') -------------------------------------------------------------------------------- /driver/edgedriver.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Strange-Code/AsistenteVirtual/d1ce086e354a42bd7cd89782f43d3f21bfc5c69f/driver/edgedriver.exe -------------------------------------------------------------------------------- /resource/abrirwts.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Strange-Code/AsistenteVirtual/d1ce086e354a42bd7cd89782f43d3f21bfc5c69f/resource/abrirwts.mp3 -------------------------------------------------------------------------------- /resource/audio/voz.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Strange-Code/AsistenteVirtual/d1ce086e354a42bd7cd89782f43d3f21bfc5c69f/resource/audio/voz.mp3 -------------------------------------------------------------------------------- /resource/chiste1.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Strange-Code/AsistenteVirtual/d1ce086e354a42bd7cd89782f43d3f21bfc5c69f/resource/chiste1.mp3 -------------------------------------------------------------------------------- /resource/chiste2.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Strange-Code/AsistenteVirtual/d1ce086e354a42bd7cd89782f43d3f21bfc5c69f/resource/chiste2.mp3 -------------------------------------------------------------------------------- /resource/errorRespuesta.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Strange-Code/AsistenteVirtual/d1ce086e354a42bd7cd89782f43d3f21bfc5c69f/resource/errorRespuesta.mp3 -------------------------------------------------------------------------------- /resource/leer.txt: -------------------------------------------------------------------------------- 1 | SIGUENOS EN 2 | YOUTUBE: https://www.youtube.com/channel/UCl24Q__MfUNDMhNWBluHcTg 3 | INSTAGRAN: https://www.instagram.com/strngcode/ 4 | TIKTOK: https://www.tiktok.com/@strange_code?lang=es -------------------------------------------------------------------------------- /resource/obligame.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Strange-Code/AsistenteVirtual/d1ce086e354a42bd7cd89782f43d3f21bfc5c69f/resource/obligame.mp3 -------------------------------------------------------------------------------- /resource/valida.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Strange-Code/AsistenteVirtual/d1ce086e354a42bd7cd89782f43d3f21bfc5c69f/resource/valida.mp3 --------------------------------------------------------------------------------