Hacking Jarviz
Step by step on how to learn Python and how to create a Virtual Assistant like Alexa
------------------------------------------------------------------------------------
import speech_recognition as sr
listener = sr.Recognizer()
try:
with sr.Microphone() as source:
print('listening...')
voice = listener.listen(source)
command = listener.recognize_google(voice)
print(command)
except:
pass
return command
--------------------------------------------
sr 3.8.1
tts3 2.90
audio 0.2.11
pip 21.3.1
py 3.10.0
whatkit 5.0
wki 1.4.0
py --version
py -m pip --version
------------------------------------------------
import speech_recognition as sr
listener = sr.Recognizer()
try:
with sr.Microphone() as source:
print('listening...')
voice = listener.listen(source)
command = listener.recognize_google(voice)
command = command.lower()
if 'alexa' in command:
print(command)
except:
pass
return command
-----------------------------------------------------
import speech_recognition as sr
import pyttsx3
listener = sr.Recognizer()
engine = pyttsx3.init()
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[1].id)
engine.say('hey there')
engine.say('wats up')
engine.runAndWait()
try:
with sr.Microphone() as source:
print('waiting for response...')
voice = listener.listen(source)
command = listener.recognize_google(voice)
command = command.lower()
if 'alexa' in command:
engine.say(command)
engine.runAndWait()
print(command)
except:
pass
--------------------------------------
import speech_recognition as sr
import pyttsx3
listener = sr.Recognizer()
engine = pyttsx3.init()
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[1].id)
def talk(response):
engine.say(response)
engine.runAndWait()
try:
with sr.Microphone() as source:
print('waiting for response...')
voice = listener.listen(source)
command = listener.recognize_google(voice)
command = command.lower()
if 'alexa' in command:
talk(command)
print(command)
except:
pass
-----------------------------------------
import speech_recognition as sr
import pyttsx3
listener = sr.Recognizer()
engine = pyttsx3.init()
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[1].id)
def talk(response):
engine.say(response)
engine.runAndWait()
def take_command():
try:
with sr.Microphone() as source:
print('waiting for response...')
voice = listener.listen(source)
command = listener.recognize_google(voice)
command = command.lower()
if 'alexa' in command:
command = command.replace('alexa', '')
talk(command)
print(command)
except:
pass
return command
def run_alexa():
command = take_command()
#print(command)
if 'play' in command:
talk('playing ')
print('playing')
run_alexa()
-----------------------------------------------
import speech_recognition as sr
import pyttsx3
import pywhatkit
listener = sr.Recognizer()
engine = pyttsx3.init()
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[1].id)
def talk(response):
engine.say(response)
engine.runAndWait()
def take_command():
try:
with sr.Microphone() as source:
print('waiting for response...')
voice = listener.listen(source)
command = listener.recognize_google(voice)
command = command.lower()
if 'alexa' in command:
command = command.replace('alexa', '')
talk(command)
print(command)
except:
pass
return command
def run_alexa():
command = take_command()
#print(command)
if 'play' in command:
song = command.replace('play', '')
talk('playing ' + song)
#print(song)
pywhatkit.playonyt(song)
run_alexa()
---------------------------------------------
import speech_recognition as sr
import pyttsx3
import pywhatkit
import datetime
listener = sr.Recognizer()
engine = pyttsx3.init()
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[1].id)
def talk(response):
engine.say(response)
engine.runAndWait()
def take_command():
try:
with sr.Microphone() as source:
print('waiting for response...')
voice = listener.listen(source)
command = listener.recognize_google(voice)
command = command.lower()
if 'alexa' in command:
command = command.replace('alexa', '')
#talk(command)
#print(command)
except:
pass
return command
def run_alexa():
command = take_command()
#print(command)
if 'play' in command:
song = command.replace('play', '')
talk('playing ' + song)
pywhatkit.playonyt(song)
elif 'time' in command:
time = datetime.datetime.now().strftime('%H:%M %p')
talk('Current time is ' + time)
print('Current time is ' + time)
run_alexa()
----------------------------------------------
import speech_recognition as sr
import pyttsx3
import pywhatkit
import datetime
import wikipedia
listener = sr.Recognizer()
engine = pyttsx3.init()
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[1].id)
def talk(response):
engine.say(response)
engine.runAndWait()
def take_command():
try:
with sr.Microphone() as source:
print('waiting for response...')
voice = listener.listen(source)
command = listener.recognize_google(voice)
command = command.lower()
if 'alexa' in command:
command = command.replace('alexa', '')
#talk(command)
#print(command)
except:
pass
return command
def run_alexa():
command = take_command()
#print(command)
if 'play' in command:
song = command.replace('play', '')
talk('playing ' + song)
pywhatkit.playonyt(song)
elif 'time' in command:
time = datetime.datetime.now().strftime('%H:%M %p')
talk('Current time is ' + time)
print('Current time is ' + time)
elif 'search for' in command:
object = command.replace('search for', '')
info = wikipedia.summary(object, 1)
print(info)
talk(info)
run_alexa()
--------------------------------------------------
import speech_recognition as sr
import pyttsx3
import pywhatkit
import datetime
import wikipedia
import pyjokes
listener = sr.Recognizer()
engine = pyttsx3.init()
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[1].id)
def talk(text):
engine.say(text)
engine.runAndWait()
def take_command():
try:
with sr.Microphone() as source:
print('say something...')
voice = listener.listen(source)
command = listener.recognize_google(voice)
command = command.lower()
if 'alexa' in command:
command = command.replace('alexa', '')
#print(command)
finally:
pass
return command
def run_alexa():
command = take_command()
print(command)
if 'play' in command:
song = command.replace('play', '')
talk('playing ' + song)
pywhatkit.playonyt(song)
elif 'time' in command:
time = datetime.datetime.now().strftime('%H:%M %p')
print('Current time is ' + time)
talk('Current time is ' + time)
elif 'search for' in command:
things = command.replace('search for', '')
info = wikipedia.summary(things, 1)
print(info)
talk(info)
elif 'date' in command:
talk('sorry, I have a headache')
elif 'are you single' in command:
talk('I am in a relationship with wifi')
elif 'joke' in command:
talk(pyjokes.get_joke())
else:
talk('Please say the command again.')
while True:
run_alexa()
-------------------------------------------------
import speech_recognition as sr
import pyttsx3
import pywhatkit
import datetime
import wikipedia
import pyjokes
listener = sr.Recognizer()
engine = pyttsx3.init()
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[1].id)
def talk(text):
engine.say(text)
engine.runAndWait()
def take_command():
try:
with sr.Microphone() as source:
print('say something...')
voice = listener.listen(source)
command = listener.recognize_google(voice)
command = command.lower()
if 'ej' in command:
command = command.replace('ej', '')
# print(command)
finally:
pass
return command
def run_alexis():
command = take_command()
print(command)
if 'play' in command:
song = command.replace('play', '')
talk('playing ' + song)
pywhatkit.playonyt(song)
elif 'time' in command:
time = datetime.datetime.now().strftime('%I:%M %p')
print('Current time is ' + time)
talk('Current time is ' + time)
elif 'search for' in command:
things = command.replace('search for', '')
info = wikipedia.summary(things, 1)
print(info)
talk(info)
elif 'date' in command:
talk('sorry, I have a headache')
elif 'are you single' in command:
talk('I am in a relationship with wifi')
elif 'is ej stupid?' in command:
talk('yes ej is stupid coz his girlfriend i a wifi')
elif 'joke' in command:
talk(pyjokes.get_joke())
else:
talk('Please say the command again.')
while True:
run_alexis()
Disclaimer: We shall not be liable for any loss or damage of whatever nature - direct, indirect, consequential, or otherwise - which may arise as a result of your use of any information on this website. However, if you are interested in using any of the projects for personal or educational purposes, please inform the author by email for guidance and technical support.
Public Domain Notice: Copyright (c) 1988. All rights reserved. This article is part of a book entitled Autognorics. Copies are welcome to be shared or distributed publicly as long proper citations are observed. Please cite as follows: Inscription by Design, Joey Lawsin, 1988, USA.
Patent Pending. 2000 © ®
Comments
Post a Comment