Build A Virtual Assistant Using Python

preview_player
Показать описание
Build A Virtual Assistant Using Python

⭐Please Subscribe !⭐

⭐Support the channel and/or get the code by becoming a supporter on Patreon:

⭐Websites:

⭐Helpful Programming Books
► Python (Hands-Machine-Learning-Scikit-Learn-TensorFlow):

► Learning Python:

►Head First Python:

► C-Programming :

► Head First Java:

#VirtualAssistant #Python
Рекомендации по теме
Комментарии
Автор

Jesus Christ he has PyCharm on light mode

leomtz
Автор

that's crazy 'cause he record this at december the 13th 2019 and i just realized that today is december the 13th 2020 ;-; LOL

joaopedromayrink
Автор

This tutorial is well done. Everything worked and the code is easy to follow along with.

BronzeKneecaps
Автор


i was so usfull
you learned me so much more than just how to make a virtual assistant!!!
and I wrote a similar code




from random import choice
import datetime
import webbrowser
import gtts
from time import sleep
import os
from pynput.keyboard import Key, Controller
import warnings
import speech_recognition as sr
keyboard=Controller()


def record():
try:
# Create a recognizer object named r
r = sr.Recognizer()
# Open the microphone and start recording
#NOTE: # The with statement itself ensures proper acquisition and release of resources
with sr.Microphone() as source: # Creates a new Microphone instance, which represents a physical microphone on the computer
print('Say something!')
audio = r.listen(source)# Records a single phrase

# Speech recognition using Google's Speech Recognition
data = ''
try: #Try to get google to recognize the audio NOTE: The try block lets you test a block of code for errors
data = r.recognize_google(audio)
print('You said: ' + data)
except sr.UnknownValueError: # Check for unknown errors, NOTE: The except block lets you handle the error.
print('')
except sr.RequestError as e: # Check for request error
print('cant understand the words ' + e)

return data
except Exception as e:
return str(e)

def assistant_say(text):
print(text)

# Convert the text to speech
myobj = gtts.gTTS(text=text, lang='en', slow=False)

# Save the converted audio to a file
myobj.save('say.mp3')

# Play the converted file
os.system('say.mp3')

def wake_word(text): #if wake word in text return True
wake_words=['hey computer', 'wake up computer', 'siri', 'alexa', 'okay google', 'hey google']
text=text.lower()
for i in wake_words:
if i in text:
return True
return False

def calcul(text):
try:
if 'how much is' in text:
return text[11:] +' is '+str(eval(text[11:]))
else:
return text[7:] +' is '+str(eval(text[7:]))
except:
return "can't calculate roots and Powers"

def date():
return 'today is '+str(datetime.date.today())

def time():
r=datetime.datetime.now()
if r.hour >12:
return "it's "+ str(r.hour)+' pm.'
else:
return "it's "+ str(r.hour)+' am.'

def google(text):
sleep(1)
keyboard.type(text[4:])
return 'press enter'

def make_response(text):
greetings=['hi', 'hey', 'hello', 'greetings', 'hola']
greetings2=['hey there', 'howdy', 'wassup', 'holla', 'hello']
res='i do not have that feacher'
if 'open' in text.split():
return google(text)

for i in text.split():
if i in greetings:
res=choice(greetings2)+' '
if 'date' in text.split():
res = date()
if 'time' in text.split():
res =time()
if 'how much is' in text:
res=calcul(text)
return res




try:
while True:
text=record()
if wake_word(text):
assistant_say('hey there')
while True:
text=record()
while text=='':

if text=='quit':


ZeroDivisionError
t=make_response(text)
assistant_say(t)
sleep(2)
except Exception as e:
print(e)

input()

roiepeles
Автор

Thank you so much im working on an ai for my home automation and this is the most pefect foundation, thank you so much !!

lasagne
Автор

bro thanks bro. i have been searching everywhere for wake word detection

aeaxplayz
Автор

This is awesome, thanks! glad to see another black bro doing code

awkb
Автор

Instructions unclear, ended up making Ultron 2.0

victora
Автор

I like your tutorial, step by step instructions are great and I can't wait to.give it a try

Kasterborus
Автор

3:40 Last I checked this wasn't an essay tutorial, But thanks. Great Vid.

chcyber
Автор

Hello :) Thank you for the tutorial. Is there any way to speed up the response times?

hlumisa.mazomba
Автор

Great video! Thanks you so much, from 🇦🇷

facundomiranda
Автор

Thank for the tutorial. I had to install Homebrew before I could pip install pyaudio. So far so good. Fingers crossed!

hannahkat
Автор

Great!!! Thanks brother. Keep continuing ...

xwrbm
Автор

Nice video! The only "problem" i noted is when the assistant speak. It has to open a speaker program. Bur veru good!.

gugasevero
Автор

for people using ubuntu
you can use ffplay
just replace it to be :
os.system("ffplay assistant_response.mp3")
this should work

anshumansharma
Автор

What would I use for the Mac system instead of windows start

jabedmiah
Автор

Sir, please also make an animated GUI for this virtual Please, Please

debasishborah
Автор

Gracias, muy buen tutorial =). Es el mejor en esto, espero ver más vídeos de este estilo.

JohanMosqueraYT
Автор

myobj.system('start assistant_response.mp3') would only work on windows platform. However, I installed another package called playsound 'pip install playsound', then imported it using 'import playsound' and then under the assistantResponse(text) function I used:
playsound.playsound(filename) instead of ('start assistant_response.mp3') and it did not open any software to play the audio file. I found that a better alternative

FINTHRTD
welcome to shbcf.ru