0% found this document useful (0 votes)
31 views

Project Documentation: Muhammad Munib Muhammad Afaaf

This document contains details of a voice assistant project created by Muhammad Munib and Muhammad Afaaf. It includes their names, registration IDs, section, and the name of the instructor being emailed. It then lists 9 functions the assistant can perform, such as providing the location, date, time, sending WhatsApp messages, searching Wikipedia, playing videos on YouTube, and telling jokes. The main code imports various libraries and defines functions for speech synthesis, recognition, and responding to user commands to carry out the listed tasks.

Uploaded by

MUHAMMAD MUNIB
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

Project Documentation: Muhammad Munib Muhammad Afaaf

This document contains details of a voice assistant project created by Muhammad Munib and Muhammad Afaaf. It includes their names, registration IDs, section, and the name of the instructor being emailed. It then lists 9 functions the assistant can perform, such as providing the location, date, time, sending WhatsApp messages, searching Wikipedia, playing videos on YouTube, and telling jokes. The main code imports various libraries and defines functions for speech synthesis, recognition, and responding to user commands to carry out the listed tasks.

Uploaded by

MUHAMMAD MUNIB
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Project Documentation

Name:
Muhammad Munib
Muhammad Afaaf
Registration ID:
70068112
70067969
Section:
S
To:
Ma’am Rabia Younas

Department of Software Engineering


Working:
1. Location
2. Date
3. Time
4. Whatsapp Messages
5. Weather
6. Wikipedia search
7. Name
8. Play video on youtube
9. Jokes

Project :

import pyttsx3 #pip install pyttsx3


import speech_recognition as sr #pip install speechRecognition
import datetime
import wikipedia #pip install wikipedia
import webbrowser
import smtplib
import pywhatkit
import pyjokes
import requests

engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[0].id)

def speak(audio):
engine.say(audio)
engine.runAndWait()

def wishMe():
speak("I am Jarvis Sir. Please tell me how may I help you")

def takeCommand():
#It takes microphone input from the user and returns string output

r = sr.Recognizer()
with sr.Microphone() as source:
print("Listening...")
r.pause_threshold = 1
audio = r.listen(source)

try:
print("Recognizing...")
query = r.recognize_google(audio, language='en-in')
print(f"User said: {query}\n")

except Exception as e:
# print(e)
print("Say that again please...")
return "None"
return query

if __name__ == "__main__":
wishMe()
while True:
# if 1:
query = takeCommand().lower()

# Logic for executing tasks based on query


if 'sir' in query:
speak('Searching Wikipedia...')
query = query.replace("wikipedia", "")
results = wikipedia.summary(query, sentences=2)
speak("According to Wikipedia")
print(results)
speak(results)

elif 'play' in query:


pywhatkit.playonyt("Python")

elif 'weather' in query:


api_address =
'http://api.openweathermap.org/data/2.5/weather?appid=304d7869d
b0e56cdc03fe87a974b90f0&q='
city = 'lahore'
url = api_address + city
json_data = requests.get(url).json()
format_add = json_data['weather'][0]['description']
print(format_add)
speak('in lahore have ' + format_add)

elif 'date' in query:


speak('sorry, I have a headache')

elif 'jokes' in query:


speak(pyjokes.get_joke())
elif 'are you single' in query:
speak('I am in a relationship with my work Affaf')
elif 'time' in query:
strTime = datetime.datetime.now().strftime("%H:%M:%S")
speak(f"Sir, the time is {strTime}")

elif 'message' in query:


pywhatkit.sendwhatmsg("+923008136366", "i send this mesg
using coding just for checking that working or not!",
2, 10)
elif 'Muhammad fateh' in query:
speak("Muhammad fateh is the youngest son of Asad zafar")
speak("he was born second december in lahore")
speak("he is cutest baby in the world")
else:
speak('Please say the command again.')

Screenshot:

You might also like