Skip to content

Commit

Permalink
main
Browse files Browse the repository at this point in the history
  • Loading branch information
bagussatoto committed Dec 31, 2023
1 parent 7897592 commit edede99
Show file tree
Hide file tree
Showing 2 changed files with 355 additions and 0 deletions.
70 changes: 70 additions & 0 deletions deploy/content/satoto_ai.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# -*- coding: utf-8 -*-
"""satoto.ai
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1wUhq51qjIG51t7IQNaFwsFDzXBjg9J5b
"""

pip install SpeechRecognition

pip install pyttsx3

conda install -c anaconda pyaudio

pip install pywhatkit

pip install wikipedia

import speech_recognition as sr
import pyttsx3
import datetime
import pywhatkit
import wikipedia
listener = sr.Recognizer()
alexa = pyttsx3.init()

voices = alexa.getProperty('voices')
alexa.setProperty('voice', voices[0].id)

def talk(text):
alexa.say(text)
alexa.runAndWait()

def take_command():

try:
with sr.Microphone() as source:
print('Alexa is listening, please speak...')
voice = listener.listen(source)
command = listener.recognize_google(voice)
command = command.lower()
if 'alexa' in command:
command = command.replace('alexa', '')
except:
pass
return command

def run_alexa():
command = take_command()

if 'time' in command:
time = datetime.datetime.now().strftime('%I:%M %p')
print('Current time is ' + time)
talk('Current time is ' + time)
elif 'play' in command:
song = command.replace('play', '')
talk('playing ' + song)
pywhatkit.playonyt(song)
elif 'tell me about' in command:
wiki = command.replace('tell me about', '')
info = wikipedia.summary(wiki, 2)
print(info)
talk(info)
else:
talk('Sorry I didnot get your question, I can search it from google')
pywhatkit.search(command)


run_alexa()
285 changes: 285 additions & 0 deletions deploy/satoto_ai.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,285 @@
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": []
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
},
"cells": [
{
"cell_type": "code",
"metadata": {
"id": "hDyC6RPHiRO7",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "03ea3cd4-12d2-4e1e-d2fd-d99f34a43029"
},
"source": [
"pip install SpeechRecognition"
],
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Collecting SpeechRecognition\n",
" Downloading SpeechRecognition-3.10.1-py2.py3-none-any.whl (32.8 MB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m32.8/32.8 MB\u001b[0m \u001b[31m18.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hRequirement already satisfied: requests>=2.26.0 in /usr/local/lib/python3.10/dist-packages (from SpeechRecognition) (2.31.0)\n",
"Requirement already satisfied: typing-extensions in /usr/local/lib/python3.10/dist-packages (from SpeechRecognition) (4.5.0)\n",
"Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests>=2.26.0->SpeechRecognition) (3.3.2)\n",
"Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests>=2.26.0->SpeechRecognition) (3.6)\n",
"Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests>=2.26.0->SpeechRecognition) (2.0.7)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests>=2.26.0->SpeechRecognition) (2023.11.17)\n",
"Installing collected packages: SpeechRecognition\n",
"Successfully installed SpeechRecognition-3.10.1\n"
]
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "OmxPM1eqiZvj",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "c09a8961-b7a4-4443-e467-252555a4e72f"
},
"source": [
"pip install pyttsx3"
],
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Collecting pyttsx3\n",
" Downloading pyttsx3-2.90-py3-none-any.whl (39 kB)\n",
"Installing collected packages: pyttsx3\n",
"Successfully installed pyttsx3-2.90\n"
]
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "noTfcWENiZ4C"
},
"source": [
"conda install -c anaconda pyaudio"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "3hBf-rCwiZ-f",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "a4cb754b-48d7-42da-8651-71278e8399fa"
},
"source": [
"pip install pywhatkit"
],
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Collecting pywhatkit\n",
" Downloading pywhatkit-5.4-py3-none-any.whl (15 kB)\n",
"Requirement already satisfied: Pillow in /usr/local/lib/python3.10/dist-packages (from pywhatkit) (9.4.0)\n",
"Collecting pyautogui (from pywhatkit)\n",
" Downloading PyAutoGUI-0.9.54.tar.gz (61 kB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m61.2/61.2 kB\u001b[0m \u001b[31m2.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25h Installing build dependencies ... \u001b[?25l\u001b[?25hdone\n",
" Getting requirements to build wheel ... \u001b[?25l\u001b[?25hdone\n",
" Preparing metadata (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n",
"Requirement already satisfied: requests in /usr/local/lib/python3.10/dist-packages (from pywhatkit) (2.31.0)\n",
"Collecting wikipedia (from pywhatkit)\n",
" Downloading wikipedia-1.4.0.tar.gz (27 kB)\n",
" Preparing metadata (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
"Requirement already satisfied: Flask in /usr/local/lib/python3.10/dist-packages (from pywhatkit) (2.2.5)\n",
"Requirement already satisfied: Werkzeug>=2.2.2 in /usr/local/lib/python3.10/dist-packages (from Flask->pywhatkit) (3.0.1)\n",
"Requirement already satisfied: Jinja2>=3.0 in /usr/local/lib/python3.10/dist-packages (from Flask->pywhatkit) (3.1.2)\n",
"Requirement already satisfied: itsdangerous>=2.0 in /usr/local/lib/python3.10/dist-packages (from Flask->pywhatkit) (2.1.2)\n",
"Requirement already satisfied: click>=8.0 in /usr/local/lib/python3.10/dist-packages (from Flask->pywhatkit) (8.1.7)\n",
"Collecting pymsgbox (from pyautogui->pywhatkit)\n",
" Downloading PyMsgBox-1.0.9.tar.gz (18 kB)\n",
" Installing build dependencies ... \u001b[?25l\u001b[?25hdone\n",
" Getting requirements to build wheel ... \u001b[?25l\u001b[?25hdone\n",
" Preparing metadata (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n",
"Collecting pytweening>=1.0.4 (from pyautogui->pywhatkit)\n",
" Downloading pytweening-1.0.7.tar.gz (168 kB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m168.2/168.2 kB\u001b[0m \u001b[31m8.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25h Preparing metadata (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
"Collecting pyscreeze>=0.1.21 (from pyautogui->pywhatkit)\n",
" Downloading PyScreeze-0.1.30.tar.gz (27 kB)\n",
" Installing build dependencies ... \u001b[?25l\u001b[?25hdone\n",
" Getting requirements to build wheel ... \u001b[?25l\u001b[?25hdone\n",
" Preparing metadata (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n",
"Collecting pygetwindow>=0.0.5 (from pyautogui->pywhatkit)\n",
" Downloading PyGetWindow-0.0.9.tar.gz (9.7 kB)\n",
" Preparing metadata (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
"Collecting mouseinfo (from pyautogui->pywhatkit)\n",
" Downloading MouseInfo-0.1.3.tar.gz (10 kB)\n",
" Preparing metadata (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
"Collecting python3-Xlib (from pyautogui->pywhatkit)\n",
" Downloading python3-xlib-0.15.tar.gz (132 kB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m132.8/132.8 kB\u001b[0m \u001b[31m11.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25h Preparing metadata (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
"Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests->pywhatkit) (3.3.2)\n",
"Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests->pywhatkit) (3.6)\n",
"Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests->pywhatkit) (2.0.7)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests->pywhatkit) (2023.11.17)\n",
"Requirement already satisfied: beautifulsoup4 in /usr/local/lib/python3.10/dist-packages (from wikipedia->pywhatkit) (4.11.2)\n",
"Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.10/dist-packages (from Jinja2>=3.0->Flask->pywhatkit) (2.1.3)\n",
"Collecting pyrect (from pygetwindow>=0.0.5->pyautogui->pywhatkit)\n",
" Downloading PyRect-0.2.0.tar.gz (17 kB)\n",
" Preparing metadata (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
"Requirement already satisfied: soupsieve>1.2 in /usr/local/lib/python3.10/dist-packages (from beautifulsoup4->wikipedia->pywhatkit) (2.5)\n",
"Requirement already satisfied: pyperclip in /usr/local/lib/python3.10/dist-packages (from mouseinfo->pyautogui->pywhatkit) (1.8.2)\n",
"Building wheels for collected packages: pyautogui, wikipedia, pygetwindow, pyscreeze, pytweening, mouseinfo, pymsgbox, python3-Xlib, pyrect\n",
" Building wheel for pyautogui (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n",
" Created wheel for pyautogui: filename=PyAutoGUI-0.9.54-py3-none-any.whl size=37576 sha256=0b942a87ec2a4c7240a6bf5694c8811054d5048b1acc8b0eedf2fbc155ca5a3f\n",
" Stored in directory: /root/.cache/pip/wheels/23/a7/1c/5a51aaff3bbe110be4ddf766d429cc9d2fae7a72fc1b843e56\n",
" Building wheel for wikipedia (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
" Created wheel for wikipedia: filename=wikipedia-1.4.0-py3-none-any.whl size=11678 sha256=c5c65ec0710a2d24fc967f375ef4fab9942f4cbf3e84e0970d7b88896bcca8b2\n",
" Stored in directory: /root/.cache/pip/wheels/5e/b6/c5/93f3dec388ae76edc830cb42901bb0232504dfc0df02fc50de\n",
" Building wheel for pygetwindow (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
" Created wheel for pygetwindow: filename=PyGetWindow-0.0.9-py3-none-any.whl size=11062 sha256=47eac2c5a78b3d466ae46c34f9ab47e17c4537e3f8f14c1eef1363db0d3714be\n",
" Stored in directory: /root/.cache/pip/wheels/02/f6/64/c5d427819f80553df2398bfecc351e94e00371c1dcb6edb24e\n",
" Building wheel for pyscreeze (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n",
" Created wheel for pyscreeze: filename=PyScreeze-0.1.30-py3-none-any.whl size=14382 sha256=7b55952ddd48f0b2f782d5455466727c016b8c8d8b561b0c407b501f96f8d721\n",
" Stored in directory: /root/.cache/pip/wheels/c4/46/42/d3613adf9880c8b4a780c07a8cf85df12ca04a9a0ca77c6c02\n",
" Building wheel for pytweening (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
" Created wheel for pytweening: filename=pytweening-1.0.7-py3-none-any.whl size=6197 sha256=6eb807ea22eb13b928a6bae62b11585e90ac629804f0c9680fdd05b93ef10c2d\n",
" Stored in directory: /root/.cache/pip/wheels/ae/a3/d7/36c45539416215425b3247e37b691a98a03b1db7b13b7f9632\n",
" Building wheel for mouseinfo (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
" Created wheel for mouseinfo: filename=MouseInfo-0.1.3-py3-none-any.whl size=10890 sha256=81d7c22b512437b572c6c59a60cce0f0496c7298f19ffe0a7147cc0092acbb4f\n",
" Stored in directory: /root/.cache/pip/wheels/6e/d5/27/2f1be84b3e6ccee99c82f50e3fe7fe6360dd30417109b49a72\n",
" Building wheel for pymsgbox (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n",
" Created wheel for pymsgbox: filename=PyMsgBox-1.0.9-py3-none-any.whl size=7406 sha256=8cf1a723181b11e072d7b705559595bef786f73a03717d480afbf063094000c3\n",
" Stored in directory: /root/.cache/pip/wheels/b9/6a/ba/be2d7d78166ec8018c21d07241dffa54446c09652a267759ae\n",
" Building wheel for python3-Xlib (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
" Created wheel for python3-Xlib: filename=python3_xlib-0.15-py3-none-any.whl size=109500 sha256=70d933439ebca3c7bed4dec52fd7a42010aed85842343702fec729502442ba82\n",
" Stored in directory: /root/.cache/pip/wheels/9c/8e/c5/8a93a3415a4a2065f31750a3244db61482b9e508f04ee56e82\n",
" Building wheel for pyrect (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
" Created wheel for pyrect: filename=PyRect-0.2.0-py2.py3-none-any.whl size=11179 sha256=a8e7ded036bd1e80542cf205daa0914df6ef2c5c8f36b7096239f3b7779e9559\n",
" Stored in directory: /root/.cache/pip/wheels/d5/4c/bd/42e4e23641afcd185d4e932784da37e6e04505da0cf3f7b832\n",
"Successfully built pyautogui wikipedia pygetwindow pyscreeze pytweening mouseinfo pymsgbox python3-Xlib pyrect\n",
"Installing collected packages: pytweening, python3-Xlib, pyrect, pymsgbox, pyscreeze, pygetwindow, mouseinfo, wikipedia, pyautogui, pywhatkit\n",
"Successfully installed mouseinfo-0.1.3 pyautogui-0.9.54 pygetwindow-0.0.9 pymsgbox-1.0.9 pyrect-0.2.0 pyscreeze-0.1.30 python3-Xlib-0.15 pytweening-1.0.7 pywhatkit-5.4 wikipedia-1.4.0\n"
]
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "CQSgpTROil3z",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "f6250a8d-512f-4a2e-8427-0273170e9db7"
},
"source": [
"pip install wikipedia"
],
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Requirement already satisfied: wikipedia in /usr/local/lib/python3.10/dist-packages (1.4.0)\n",
"Requirement already satisfied: beautifulsoup4 in /usr/local/lib/python3.10/dist-packages (from wikipedia) (4.11.2)\n",
"Requirement already satisfied: requests<3.0.0,>=2.0.0 in /usr/local/lib/python3.10/dist-packages (from wikipedia) (2.31.0)\n",
"Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests<3.0.0,>=2.0.0->wikipedia) (3.3.2)\n",
"Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests<3.0.0,>=2.0.0->wikipedia) (3.6)\n",
"Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests<3.0.0,>=2.0.0->wikipedia) (2.0.7)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests<3.0.0,>=2.0.0->wikipedia) (2023.11.17)\n",
"Requirement already satisfied: soupsieve>1.2 in /usr/local/lib/python3.10/dist-packages (from beautifulsoup4->wikipedia) (2.5)\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"import speech_recognition as sr\n",
"import pyttsx3\n",
"import datetime\n",
"import pywhatkit\n",
"import wikipedia\n",
"listener = sr.Recognizer()\n",
"alexa = pyttsx3.init()\n",
"\n",
"voices = alexa.getProperty('voices')\n",
"alexa.setProperty('voice', voices[0].id)\n",
"\n",
"def talk(text):\n",
" alexa.say(text)\n",
" alexa.runAndWait()\n",
"\n",
"def take_command():\n",
"\n",
" try:\n",
" with sr.Microphone() as source:\n",
" print('Alexa is listening, please speak...')\n",
" voice = listener.listen(source)\n",
" command = listener.recognize_google(voice)\n",
" command = command.lower()\n",
" if 'alexa' in command:\n",
" command = command.replace('alexa', '')\n",
" except:\n",
" pass\n",
" return command\n",
"\n",
"def run_alexa():\n",
" command = take_command()\n",
"\n",
" if 'time' in command:\n",
" time = datetime.datetime.now().strftime('%I:%M %p')\n",
" print('Current time is ' + time)\n",
" talk('Current time is ' + time)\n",
" elif 'play' in command:\n",
" song = command.replace('play', '')\n",
" talk('playing ' + song)\n",
" pywhatkit.playonyt(song)\n",
" elif 'tell me about' in command:\n",
" wiki = command.replace('tell me about', '')\n",
" info = wikipedia.summary(wiki, 2)\n",
" print(info)\n",
" talk(info)\n",
" else:\n",
" talk('Sorry I didnot get your question, I can search it from google')\n",
" pywhatkit.search(command)\n",
"\n",
"\n",
"run_alexa()"
],
"metadata": {
"id": "TVFJ4EvUNUz0"
},
"execution_count": null,
"outputs": []
}
]
}

0 comments on commit edede99

Please sign in to comment.