Google Assitance using Python

import speech_recognition as sr

#for window the engine is sapi5

#for mac or linux engine is nsss

engine = pyttsx3.init(‘espeak’)

client = wolframalpha.Client(‘Your Client Id’)

voices = engine.getProperty(‘voices’)

rate = engine.getProperty(‘rate’)

engine.setProperty(‘rate’, rate-25)

currentH = int(

speak(‘Hello Sir, I am your digital assistant Cortana!’)

speak(‘How may I help you?’)

r.energy_threshold = 3093.7084974832646

with sr.Microphone() as source:

query = r.recognize_google(audio, language=’en-in’)

except sr.UnknownValueError:‘')‘')‘')

‘I am nice and full of energy’]


speak(‘Who is the recipient? ‘)

speak(‘What should I say? ‘)

server = smtplib.SMTP(‘’, 587)

server.login(“Your_Username”, ‘Your_Password’)

server.sendmail(‘Your_Username’, “Recipient_Username”,

speak(‘Sorry Sir! I am unable to send your message at this moment!’)

speak(‘Bye Sir, have a good day.’)

speak(‘Bye Sir, have a good day.’)

music_folder = Your_music_folder_path

music = [music1, music2, music3, music4, music5]

random_music = music_folder + random.choice(music) + ‘.mp3’

speak(‘Okay, here is your music! Enjoy!’)

res = client.query(query)

results = next(res.results).text

speak(‘WOLFRAM-ALPHA says — ‘)

results = wikipedia.summary(query, sentences=2)

speak(‘WIKIPEDIA says — ‘)‘')

speak(‘Next Command! Sir!’)

Originally published at