Project 1: Iron Man Jarvis AI Desktop Voice Assistant | Python Tutorials For Absolute Beginners #120

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
Guys in this video I will teach you how to create Jarvis AI With the help of python This video will be the best video of the channel till now Because we will create an AI system A virtual assistant that will work for you So if someone misses this video He/she will miss a lot of things Please don't miss this video Guys you might have seen AI-powered bots in movies/tv-shows It has been shown frequently in tb/movues And they show you How an AI is doing tasks for humans automatically And this automation makes the lives of humans easier Todays video is based on that only We will see how we can make AI Jarvis with python And this will be the first project in Beginner python series Guys when we used to watch movies 10 years ago The we used to think that whatever fiction we are seeing That's not less than magic But the way technology is enhancing and new thing are being released Researches are done mainly in AI and ML We can see that The things that we used to see in movies 10 years age That things are being done in reality This video is an attempt to touch those topics I want you all to be motivated after watching this video That in todays world computer can easily automate your tasks Guys few months ago I started this Python Beginner course And I didn't thought I will get this much response And millions will be involved and will be influenced by this If by any chance you haven't accessed this course playlist So please access it in a new tab from the link in description Do to this what will happen is that If you all haven't seen those videos Then you can schedule and complete to later Whatever things we will be needing I will tell you on the go So the prerequisite is that you should know basic python Guys whenever I create a course Then I ensure that I should complete it And along with that I try to tell you things Like this video is about a mega project This type of video was a compulsion for me So by working on this project I will deliver something good and valuable So for me to present something new and exciting That's why I have made this video on a project This Jarvis will automate your computer tasks Like the tasks that you do daily Like I use Visual studio code daily Or I use YouTube daily I use google daily I listen to music daily I send emails daily Along with that I do more things... I will try to automate those things using Jarvis So that you all can rest on couch and Command Jarvis Like Jarvis do this, Jarvis do that... And Jarvis will handle everything for you I will write each and every line And will explain how everything is working And which element works in what way So if you are a student and you are looking for a project And you all are looking for a project that That you can use a final year project Or you are looking for a course completion project The you can take inspiration from this project Guys when I was in my early stage of programming career Then I used to have a question That will AI and ML make human jobs obsolete? Will AI and Ml automate every human jobs? And humans won't have to do anything 10 years ago the answer would've been straight no But as the time passes the answer is changing It is converting from no to yes Even with todays standard the answer is not a solid yes Not all tasks have been automated completely but the way we are going ahead in time We can see things that were impossible 5 years ago We have done that in a time span of 5 year If we talk about Google, Microsoft, and reputed universities So every year they do some research That we thought of as impossible and how they have done it And they also show demo So we don't know Where AI and ML will be in 10 years What do you think, please let me know in comments That will AI and ML steal all humans jobs or not Before I start this course I want you all to like this video And comment you name and where are you from I will enrol you in this course And if there is any related resource like this Then I will reply you in the comments So please drop your name and city in the comments This is very important So guys I won't take much of your time I will take you all I'm Visual Studio code That is an IDE that we will use To code todays project And I will show you how we will code our AI Jarvis I will show you each and every line Lets go to our computer screen and start with a demo In which I will show what we are going to make How does it work And how it can make your life easier And then we will see how we can make it And what are the modules what lines of code, constructs, functions that we will use In Todays project So lets go to our computer So before coding we will see a little demo of Jarvis Like how does it work And what I will do I will just simply run it here So the moment I run this So it is greeting me Good Afternoon So greeting message can be anything And now it is listening whatever I say it will be listening So.. I have said a lot of things to it So I will check other iteration whether it will listen to me or not "PLAY MUSIC" So it started playing music You all can see that And along with that it is listening for other commands too So I will close the music "SEND EMAIL TO HARRY" *Jarvis Responds* "I AM A VERY GOOD BOY, THIS TUTORIAL IS THE BEST" *Jarvis Responds* "OPEN GOOGLE" So it opened YouTube instead google Because I have made a mistake, I will just fix it I change this from YouTube.com to google.com I will stop the program now I will show you whether it has sent email or not So if I take you to my inbox So see "I AM A VERY GOOD BOY, THIS TUTORIAL IS THE BEST" You can see this email in my inbox So guys I am in my gmail's inbox Zero minutes ago I can see this email I will show you how to do all of these things This was just a demo, I was just showing how this works Now if I run this and say "OPEN GOOGLE" Then it will open google only. Now I will tun this "OPEN GOOGLE" "OPEN YOUTUBE" So it has opened YouTube here "WHATS THE TIME" *Jarvis tells time* "WHO ARE YOU" *Jarvis Introduction* "SALMAN KHAN WIKIPEDIA" *JARVIS READS SALMAN KHAN'S WIKIPEDIA* "OPEN CODE" It has opened VS code When I told him to open code And this is a very good functionality the moment I said open code and Jarvis opened it Now lets see how to develop it This was just a small demo "JARVIS QUIT" *Jarvis Responds* So the program has quitted itself And you can see here how it.. That it is recognising whatever I am saying It opened the VS code We can also make it in Hindi Like I showed you here Whatever I will show you ill make it in English We will develop it here in English But you all can develop it in Hindi too And along with that I have added some functionalities Those functionalities is the start of this AI It is just the start of AI You can develop it further And along with that what features you can add the limit for that is sky, Sky is the limit my friends So I hope everyone enjoyed demo Everyone is ensured that whatever they are going to code It is really a good project I want to mention something This video is a part of my python series So if you haven't seen my Python series by any chance So please access my playlist You can see the playlist Python tutorials for absolute beginners And if you don't know python then please start from the first video After going through this course I can guarantee you You will learn python properly Along with That you will not face any problem When it comes to learn Python Writing python and Will be a job ready Python developer If you are in school then also you can do this course I have added many practice problems I have made 103 videos after that I have added many practice problems and mega projects This project is a part of course I will come in my visual studio code And I will show coding there By any chance if you have an installed visual studio code you can search for visual studio code on Google And just install it You can use PyCharm also I will not force you to use any particular IDE you have to download and install visual studio code after that you have to install python you can install python from python.org If you search for Python install You will reach to python.org and you can install it So guys now I am in a directory in my computer Whose name is dudes, I will create an new folder here And I will name It Jarvis And then I will browse into Jarvis And I will open PowerShell window using right click and shift And I will write here code .(dot) With this VS code will be opened in this folder Sometimes what happens is You want to use something different suppose you want to use pycharm or some other IDE That is totally fine with me I am not particularly suggesting VS code But I like this because it is helpful in Web development And in some other things too. What I will do here I will create a program named Jarvis.py And now what we will do here First simply we will write our speak function Because what does out AI needs first is that it should speak So what's the first thing Jarvis will do; It will speak. So I will write here def speak: And whatever argument this will take This will speak it I will give it an audio argument Will it do? it will pronounce that audio. Now where will this audio come from We will look into it But what I will do here first Here you have to install a module I am importing it here The name of module is pyttxx3 You can install this module with the help of PIP The end of this video I will show you which modules to install I will let you know whenever I will install a new module pyttxx3 was already installed So I imported it If you haven't installed it Then what you will do You will write here pip install pyttxx3 You all will write like this I already have my requirement satisfied Yours will be installed to This was our first step Now I will do some work here I am writing here engine is equal to pyttxx3.init() Inside that I will write sapi5 What is this? If I Google search sapi 5 Now what is sapi5 if you want to learn about it so you can read it here on this Microsoft's page But for now just keep in mind that You are going to use it To take the voices Windows has given us an API Through which you can take the voices f You can use the inbuilt voice in Windows I will write voices is equal to engine.getProperty() If I write gp then get property will automatically come This is the intellisense If I write GP then it will suggest me getProperty I clicked enter and took the suggestion Now see what I am writing here I am writing voices If I print hear voices And then if I run the program Then see there are two voices in my computer You can Install additional voices But for now I will use one of the two voices One is male and one is female You can use anyone of them Now how do you have to set voice You have to write engine.setproperty After that you have to say That you have to set voice property of engine and after that you have to write voices and after that I am writing [0].id So voices[0].id If I print voices[0].id And run this so can you see what you did The name of the voice is David And if I change that to 1 So what's the name David is a boy And along with that Zira. Zira is a girl. So if you want boys voice Then write voices[0].id Or else write voices[1].id Check what Voices are available in your computer by printing voices What that will do You can see what voices are available in your computer and you can use it So here I have simply written speak function So let's just write main method And test it Whether the speak function that we are going to write here Will it work or not For that we have to write speak function first so Inside this speak function what I will do I will write here engine.say(audio) So whatever audio is fed then engine will speak it engine.runAandWait() is a function Now what I will do; I will run it. You can see it said "Harry is a good boy", once more. So it just said Harry is a good boy That means our speak function It is speaking properly This thing I have shown you in my other videos also If you have seen this course I have talked about speak function somewhere here I cannot search it here But I am damn sure I talked about it You can go through it I have talked about speak function in one of these I guess it was a exercise In which I told you to read newspaper and news... I cannot search it here for some reason You all just go through it It was something related to Reading newspaper So exercise 9 was the one in which I used speak function I will go back to visual studio Our speak function is ready It was an important part for our Jarvis Because our Jarvis he needs to speak Speaking is very important for him Now I will write a function here named wish me now what is wish me function will do So if I write a function named wishMe here so what it will do it will wish me What respect it will wish me With respect to time And how it will wish me It will use speak function to wish me so what I will do I will take an hour I will say hour is equal to int of datetime. Now I has to import datetime module You don't need to install it, it is built-in So I will write here datetime.now() and .hour(dot hour) So I will get the hour and I have typecasted it into int So I can get the hour I will get to from 0-24 Yes good. Now what I will do here I have taken the hour here And I will write here If hour is greater than equal to 0 and hour is less than 12 What does this mean from 0-12 means it is morning that means you will do good morning So you will write like this speak good morning And along with that what you will do you will write here elif hour is greater than 12 lets change it to greater than equal to Greater than equal to 12 and you will write hour is less than 18 This means between 12-18 it is afternoon So I will write here speak good afternoon That means afternoon is going on and in else I will write good evening Else our Jarvis will say good evening These 3 things it will definitely say But along with this what it will do After wishing me it will talk about itself I will say I am Jarvis So I will write one more speak function I will write speak "I am Jarvis sir" "Please tell me how may I help you" So I will write how may I help you So I have written here the wish me function So just see what all things we did We have created a main function here I am just formatting the code We have created a main function here After main function what we have done We wrote 2 functions What does wish do, It wishes you The moment out program is starting I will call wishme here I will save it and run it "I am Jarvis sir, Please tell me how may I help you" So it says "I am Jarvis sir, Please tell me how may I help you" Now the voice that I printed I just wanted to show you that I will just comment it out, you all can remove it Its not a good practice to keep this print statements I am keeping it because I want to give you the code So we have created this much here We have created the wishme and speak function beautifully Now what we will do here We will write a function named take command And for this you have to install speak recognition module So everyone write here pip install speech recognition type exactly as me pip install speech recognition and your module will start installing my installation hasn't started yet, why? because mine was already installed Alright now I will import here speech recognition as sr I will import it with name sr After importing speech recognition what I will do I will write a function named take command Now what dos this take will do? You all should include a docstring in your programs I have shown you doctoring in python programming They are string like this and they show that in program what a function is doing But I am skipping it But I have shown this in my python course So you can understand it there and implement it Now I am just writing a comment that it takes microphone input from the user and returns string output so the string will be its output I will explain this to you I won't leave it So what I have done here I have written a function named take command So I will do one thing I will write here Hour is equal to and I will write here sr.recogniser So this recogniser class of ours This will help us to recognise audio now I will write here with sr.microphone And I will write here as source I will use this as source microphone and I will write a print statement here And I will write listening Why did I write listening So that it should be known that the program is being used He/She should know Jarvis is listening I will change here r.pause_threshold And I will make it 1 I will click here control and take you here Now what is pause threshold This has explained what Is paused threshold Seconds of non speaking period before a phase is considered complete I will just toggle word wrap Now you all can see the page Here some other arguments are also given energy threshold, dynamic energy threshold, dynamic energy adjustment dampening This are all things you can change And details about that is given here You all can read it here That what is our non speaking duration phrase threshold and along with it What is dynamic energy ratio? And I have changed the pause threshold and made it 1 Why did I changed it to 1? Because I wanted to increase seconds of non speaking audio Before a phase is considered complete I wanted to increase it To give it time for 1 second That if I am taking gap of one second while speaking Then it should not complete the phrase So I hope you all understood this Understanding is important Code and be found easily But if you want to be a good python programmer And if you have done this course My full focus is to teach python I don't what you all to memorise it Or just running the code No that is not our focus Our focus is to learn python Lets come back here and write code further And I will write here audio is equal to r.listen source And where is this all coming from This is coming from speech recognition module So if you click control and choose listen Then it will take you here You can do this in pycharm too pycharm will also take you to the course file I did toggle word wrap so that it wouldn't overflow You can read about it here Many things about it Is given here And it has also said here that What all thing you can do many things are given in detail here I don't want to discuss all that I don't want to take much of your time Now what I will do here is I will write here try Now what will happen When we use try? When we think an error can occur So I will write here recognising Now it is recognising the command It will recognise the command And whatever the query there is I will write here recognising bing or google recognise google, google cloud and many things are available I will use recognise google If I take you here by using control So just see recognise google, bing and many more And it is showing the name and what engine it is using and it will use google cloud engine if you recognise google cloud But as of now, recognise google works properly So we don't have to be stressed out After that I will write English India EN-IN And after that I will write here print And I will write here user said, whatever user said and query, okay? I could've used fstring but I am not What I will do here Let me use fstring here So kets use fstring here So I will just write query here I will remove the comma and write /n So I hope you understood everything till here We are recognising the audio here Whatever audio is typed I will use tab+enter and to get correct indent level I will write except exceptions Exception as e I will print e And along with that what I will do I will write "Say that again please" So I will write print "Say that again please" and I will return return... I am returning here None Now you might be thinking why I used string This none Is not python's none I am just returning None string Just keep that in mind Now you might want error should not be in console So don't write this use control + / And remove that exception Or else whatever the error is coming it will be printed here and it does not look good So suppose an error occurred While recognising You said something that it couldn't recognise Then what will happen It will go into this exception block. And after going into that block What it will do? You can print the exception here Or what else it will do "Say that again". It will return none And here I am going to run a while loop infinitely What this will do It will listen, listen, listen and keep on listening That's good Now here, how fast you speak You can control it here If I open this pause threshold here So just see here If you increase the energy threshold So the least audio energy is needed more Then you have to shout a little So if you all want If there is noise in your house 24hr And if you want your AI to not listen to that Your Jarvis should not listen to that To their voices So just increase the energy threshold and experiment with this Experiment wit h all of these parameters Just like I have increased the pause threshold You all can also change all the parameters I hope you all understood this clearly Now what I will do here I will write here that I will write a while loop here So what I just did here One thing here We haven't returned the query here Then we will return the query here Now what is this function doing Take command function is getting the audio It is taking the audio from microphone And it is converting it into string and returning it It is not doing anything more than that And it is returning a string output If there is a problem then it is returning none Lets just test this once I will write here the take command I will save it with control + s *JARVIS RESPONDS* "HELLO MY.." "HELLO" *JARVIS RESPONDS* "HELLO I AM HARRY" It is showing I am having that is not bad I will run this again once *JARVIS RESPONDS* "WHO ARE YOU?" So it has recognised who are you perfectly What happened is what mic are you using The quality, distance The noise, it depends on all of that factors In most of the cases, google engine works perfectly Trust me This is the same engine that you use in mobiles So please don't think it won't work So the voice-to-text or speech-to-text you all know how smoothly that works. Now here we have done the take command Now what I will do here I will write query is equal to Whatever the query is, query is equal to And I will convert it into lowercase string So I will say convert this into lowercase string And after that I will write logic for executing tasks Based on query Now I will write here the logic That I will use to execute tasks So what I will do, I will write a while loop And this wishme don't write it in while loop Or else Jarvis will start wishing you like a mad man We don't want like this So lets write the logic And lest see what tasks we can execute I want you to type in terminal pip install wikipedia And this will install the wikipedia module and write import wikipedia on the top here wikipedia you all have written. Now suppose You all have to search wikipedia So what I will do? I will write here If "wikipedia" in query Suppose wikipedia is present in your query Then what has to be done Then Speak Searching... Wikipedia. So I am searching wikipedia And I will write this much. I won't write please wait I will write searching wikipedia And along with that I will write query is equal to And I will write here Query... So I will Wirte here query.replace And the wikipedia that is in query I will replace it with replace with Blank. That means I will remove wikipedia And I will write here I will search wikipedia with the query So I will write here results is equal to And whatever results I will get from wikipedia I will write here wikipedia.summary And I will write here query, sentences is equal to 2 query sentences is equal to 2 And sentences = 2 will return two sentences From wikipedia And here I will make it speak According to wikipedia According to wikipedia... So it will speak like "According to wikipedia" "Something, something, something...." like this And after that I will program it to speak results Whatever results are there just speak it Lets try to run it *Jarvis responds* "SHAHRUKH KHAN ACCPRDING TO WIKIPEDIA" *SEARCHING WIKIPEDIA* "JARVIS SPEAKS ABOUT SHAHRUKH KHAN " Can you all see? "JARVIS SPEAKS ABOUT SHAHRUKH KHAN " So it is giving details about Shahrukh Khan What I will do here.. I will print the results too And I will click f3 *JARVIS RESPONDS* "SHAHRUKH KHAN WIKIPEDIA" *JARVIS TALKS ABOUT SRK* So did you all see that? I am cancelling this Because it is reading this So it took 2 sentences from wikipedia and reading it If you think 2 sentences are more than enough So you can make It less So I will leave that upto you This will be on you whether you want 1,2 or 3 sentences Or you can program it to read full wikipedia Now what we will do here We have made some progress here What we did, we made wikipedia work for us We have made some progress here At least our wikipedia is working now Now what we want to do We have to make more things work like Like open YouTube, open google, or another site like wikipedia Now lets see how will it work Now suppose you said I will write elif "Open YouTube" in query Now the query includes open YouTube Now suppose you said Jarvis please open YouTube for me so open YouTube will be in that query open YouTube for that query will be true And what it will do It will open YouTube But how top open YouTube So for that we will install web browser module which is an inbuilt module So I will write at the top import web browser I wrote import web browser Now what I will do here, I will simply write webbrowser.open and here I will write YouTube.com And the moment I say open YouTube then it will be opened Now lets test whether it works or not I have executed it *JARVIS RESPONDS* I will speak now *JARVIS RESPONDS* "JARVIS OPEN YOUTUBE" Just see it has opened YouTube for me Now what I will do I will quit it And it has opened YouTube for me perfectly. Like this we can program it to open more websites Its not mandatory to open YouTube only, it can open more sites So will just copy it here I will paste it and write open google And for google, I will write here google.com And what is there? Stack overflow is there for programmers We should now forget it Okay? okay? You all can open like this So if I say open stack overflow So it opened stack overflow *JARVIS RESPONDS* "OPEN GOOGLE FOR ME JARVIS" So it has opened google for me and now if I haven't converted it into small case Then the G would've been capital and my query would've failed That's why in the query I have converted the take command into lowercase By lowercase, it will be converted into lowercase And you can match the query perfectly These were our browser actions And now I am going to show you that how you can play music So I will write here Elif and after that play music So you all have written play music And in query What you want? You want to play music Just import the os module from the top I have written import os at the top Now just se how I will play music If you are on windows then what happens is There will be a directory for songs Then what you will do music_ ..... If there is now directory then create one for songs Like my directory with name D:\\ after that Non Critical after that \\songs and after that \\Favourite songs I have created a directory by this name Now why am I using double slash here? I am using it because I want to escape the character All these things we have seen in out python course And you might get to know it That how we have to use these things If you haven't seen the python course I am telling you again You al will say I am telling you again and again But its important that's why I have to tell you again and again Lets go back to our visual studio code So here we have escaped and wrote our music directory Now by using the voice module here I will write here songs = os.listdir What does list for do It will all the files in musicdir So if I write here print songs So it will print all my songs You all ensure one thing here We are not detecting that we have to play mp3 You can add that additional feature For now it will just listen I haven't closed it is still listening See it has listened to something I don't know what, anyways So I write here print songs I have written print songs so what will happen So I would be able to see all the songs What I will do here?l I will do os.startfile What will os.startfile do? It will open that file And I will use os.part.joina I will merge musicdir with Will merge music_dir with songsdir That means I will play first song Now its not important to play only first song With the help of random module from 0 to length of song minus 1 you can generate a number to play random song But for now I will just keep it like this only Whatever the first song is will be played But you will enjoy more When you use random module When you will generate a number through random module And a random song Jarvis will generate a random song So it will be more fun. Please try it at your end. I just want to simply show you Video will be long if I do small enhancements So you can play music like this So lets see if it works or no I will run Jarvis and say "Play music" So I will play this and run my program I will run program and then say it *JARVIS RESPONDS* "JARVIS PLAY MUSIC" So just see it has played music for me So it is plying song now And it takes some time to open So the song is now started So I will not waste my time listening to song I will show you So like this you can play song So our play music task has been completed. Now we will add more task I will write here elif "the time in query" That means if you have asked for time You have asked Jarvis what's the time Then what you will do, I will write here timestr is equal to You want the time in string datetime.datetime.now that is the current time .strf(time) And after that what you will do %h specifier you will write here %m and along with that %s So with these specifiers, you can get the time in string If I have written it correctly, then I will speak time And here I will I will make Jarvis speak "TIME IS" I will apply fstring here And here I will say that "TIME IS" And by using control + X, I will paste it. I will make him speak "SIR THE TIME IS" "SIR THE TIME IS", like this it will say. Lets see if it works or not And here I will do like this. My program has started running It has not started yet. I am waiting. And my Jarvis is starting *JARVIS RESPONDS* "WHATS THE TIME JARVIS?" *JARVIS TELLS TIME* So Jarvis told me the current time that is 13:53 I will just close this program Let me do one thing I should change while True: Because I don't want it to run again and again Because I am taking to you And I am running it while talking to you So what will happen due to this? That if I do like this than It will be running continuously and recognising everything There is no damage due to if but still So what did we do here We simply opened google, opened YouTube opened stack overflow, played music We learned about time Now sometimes you want to open a program So what you will do then Suppose I want to open VS code I personally want to open it So what happens is I will click on Start Right-click on VS code And then I will go in more I will simply just go into open file location After going into open file location I can see the VS code I will right-click and select property and I will copy the target I will copy this whole target After copying target what I will do I will write here Elif open code In query. If there is open code in my query Then what I will do... I will write here What my path is.. I will write here path is equal to this... will change it to code code path is equal to this. And the slashes that are here I will escape them I will convert the single slash into double slash Simply.. And I will save it with control + s And I will write here Like I used os module before I will write here os.startfile(codepath) Simply you have to write this and nothing more And along with this, like I have used codepath here You can use more things like this Suppose you want to open some other program Then you can use that program's path And create a program corresponding to it You can make any string here and And you can open the corresponding path So if i run this program *JARVIS RESPONDS* "JARVIS OPEN CODE" So it has opened one more instance of VS code Now I will close this instance of VS code. If you are lazy and don't want to click on start like me So you can use you assistant for this work. Playing music, time, date, setting reminder These all things you can do. You can keep all your reminders in a file Or else you can store them is csv And use pandas to read csv So here i will simply show you That you limits here is the sky You can make your Jarvis do anything. Now after that one more fascinating use i will show you That is sending E-mails. Yes yes you can send e-mails But for sending E-mails What we will do I will show you a simple usage I will write here E-mail to harry Ans what I will do here. Now here I will say "Send e-mail to Harry. Then my command will be triggered But what you all can do. You can simply do this You can send e-mail and after that by using name You can detect the e-mail So what you all will do... You will create dictionary You can create a dictionary at the start And in that dictionary the names will be keys And the values will be e-mail id's. You can fill this with you Gmail Account. Fill it with all your contacts. You can import your contacts. And after importing the contacts And can save it by creating a dictionary But what I will show you here is E-mail to Harry In which message will go to only 1 E-Mail Now what i will do here. I will write here try You should always use try Because we don't want our Jarvis to fail We don't want it like that So I will write here speak "What should I say" What I should say, okay? And in this content I will use take command What does take command function do? What take command function does is Whatever you said in microphone It returns that in the form of string. So I hope you all can understand these things to is equal to your e-mail @ of gmail.com. Whose e-mail? Harry's email. Because I am e-mailing to Harry. So I will change it to harryyourEmail@gmail.com Whatever Harry's email is will come here And what I will do afterwards I will write a send email function here. It will include 2 this i.e to, and content I will send to and content to this function. I will explain this function You all don't be stressed "Email has been sent" I will make my AI speak that And after that what I will do I will write Except exception as e And I will write here After writing Except exception as e. I will print it to see what is the problem Because ideally this problem should not happen If you have configured it properly then it shouldn't happen But now we will see here and write. Sorry My friend Harry bhai. I am not able to send this E-Mail. Now the thing is, if you have done this Sorry My friend Harry bhai, I am not able to send this E-Mail. At the moment. You can write anything you want. So what will happen is it will speak And you will get to know your e-mail hasn't been sent. But ideally your e-mail will be sent. Now lets complete this send e-mail function. So I will come up here And I will complete this send email function I will write def sendEmail() And what things it takes in inputs? It takes to(to whom you want to mail) and content. To whom you want to send mail. And what you want to send. Now how will we send mail with the help of google? Now I will show you what will be our strategy To send these emails So what I will do here, I will use Google. I will use our Gmail here. And I will write here smtplib. smtplib is a python package Which is already installed. And with the help of this what you can do Simply you can use this to send emails with Gmail. You can send it with with ease. Less secured apps in Gmail. You have to search for this And whichever account you are using for sending mails You have to allow less secure apps in that mail. You will ask why would I allow less secure apps? But it wont work If you don't allow less secure apps. So in your. Gmail account Whichever account you are using for sending mail Atleast what you should do Just enable less secure apps. And enabling this is important. There is no alternative for this. So you have to enable less secure apps. Just refer here for how to enable it Go into your console And after that go in security You have to enable less secure apps. Once you have enabled it Now with Gmail You'll be able to send e-mails. So I am writing here send email And here I will write First I will import this module. I will write here. import smtplib. smtplib. Now i will come to my send e-mail function And I will write here server is equal to smtplib.smtp And after that I will write smtp.gmail.com And the port will be 587. So I will write here port 587. Along with that I will write server.ehlo() And after that I will type, server.startttls(). And after that I will write server.login() to be logged in And what I will write here. yourEmail@gmail.com. Whoever you're sending to you have to mention here. And after that So here your password will come. Do not write literal "password" here. So here your password will come. Here security concerns matters If you write your password here So it will be a issue So I want you store password in a text file And read password from that text file So no one can know your password in the. program And store text file in a location where It wont be easy to open Usually someone can open in VS code using control But still you have to think of some mechanism When you keep password in a plain text. Then there is security concern Thats why I want you all to be secured If only you use your PC like me No one uses it So I am safe here So I wrote here the email that I want to use That an after that to and after that content So it will send mail through your gmail account Then I will do server.close() That means I will close the server And then my email will be sent. Now we will do one thing here You will put your email here And here you will put your password I will put your password here I am telling you this again and again because People comment later on that That I write youEmail@gmail.com here And wrote your password here But my program did not work But my friend i just want to tell you That here you have to put your gmail account And here you have to put your password And after that you will put you gmail here Then your sendEmail function will work. So before running Jarvis This sendEmail function that we have written Just watch out whether it is working or not Because if you sendEmail function is not working. Then it will raise an issue for you. Now what we have done here in Jarvis We have put our email ID and password We have created a program for sending Email We have created a program for working with wikipedia We have put a command for opening youtube, Opening google and opening stackoverflow, playing music To see the time To open Visual Studio Code To Email someone You can program it do more work I just want to tell you all that Sky is the limit. So i will do one thing here. I will test this email part here. And to test this what I will do I will put email in this try block. And I will put my email and password here. And I will show I have received the email. So as you can see what I have done here I have collapsed my Try block here You also can collapse using the minus(-) symbol This try contains my email and password. And I have collapsed the sendEmail function. Because this contains my password And now I will run this. So what I will do here I will click F3 here That I have created shortcut for running the program You all can run from here also *JARVIS RESPONDS* "SEND EMAIL TO HARRY" So it has spelled it as Hari. Sometime it happens I will command it again. *JARVIS RESPONDS* "SEND EMAIL TO HARRY" *JARVIS RESPONDS* "I AM A GOOD BOT AND THIS TUTORIAL IS BEST TUTORIAL FOR JARVIS" *JARVIS RESPONDS* So it has failed; Me sending email has failed. So there was some issue thats why the email wasn't sent. So my mistake was i wrote smntp instead of smtp here I will change it to smtp. And I will collapse this. And the moment I collapse this Now what I will do here I will send Email now. Now I will run this program again. And I will say *JARVIS RESPONDS* "SEND EMAIL TO HARRY" *JARVIS RESPONDS* "SAY THIS THIS TUTORIAL WAS UPLOADED ON CODE WITH HARRY AS A PART OF PYTHON PROGRAMMING COURSE". So it has written codes instead of course. No worries, It happens sometimes. Now it is sending my Email. It said my email has been sent. So now lets verify it ourselves Whether the email has been sent or not. Or it is just making a fool of us. So here I have received the Email And as you can see It is saying "SAY THIS THIS TUTORIAL WAS UPLOADED ON CODE WITH HARRY AS A PART OF PYTHON PROGRAMMING COURSE". It has written codes but I said codes I said it maybe in a funny way thats why. But guys whether you enjoyed it or not Let me know in the comment section And let me know whether you have accessed my course. So if you haven't accessed this course So you are missing out on some good stuff Whatever things I have showed you here. By any change you all didn't understood that Then I want to say you that If you watch my python programming course Then you will understand it perfectly And along with that you can get this code And I will give you this whole code In sendEmail function You have to put your email and password. And who you want to send email to That has to be entered below That I have entered below So I will send you this code I hope you all understood this. I will give you a recap quickly. I will show you again what we have done In this mega project. So first our function starts here The main function starts here I will activate my while loop here First this program wishes you. We wrote a function named wishme. That will wish you according to the time It will say good morning, evening and afternoon And after that it will say I am Jarvis sir please tell me how may I help you. To make your program cooler You can write Hi this is Jarvis, speed.... Like that movie of Rajnikanth He said speed terabyte, zetabyte something like that You can program it to say like that And after that we have written a speak function Speak takes a string and after taking that string, it speaks that string So what we have done here We wrote wishme, in which we used speak function. And then we came in while true. We have written a function named takecommand here that takes a command And converts that to string It converts input into string and returns it. So after takecommand what we did? After that we converted it into lowercase And after converting it into lowercase Whether it contains wikipedia? If yes then remove wikipedia from string. Ans whatever remains Search that on wikipedia And make Jarvis speak that. If it contains open Youtube Then open Youtube. If it contains "open google" then open google If it contains "open stackoverflow" then open stackoverflow. If it contains "play music" the play then first music. But we can use random module to play random music. You can ask Jarvis time We have used datetime module You can open VS code And you all can If you say email to Harry It will send email to Harry. And we can add more functionalities That is I want to allot you as a challenge or an exercise. So you all just write challenge accepted in the comments If you accept this challenge. Challenge is you have to add atleast one more functionality. Now what is that functionality? That you all will let me know. And i will analyse how How many viewers are watching this tutorial seriously How many viewers listened to me Half of the people will just run the code And they will be satisfied. But the real python programmer He/she will try to understand how things work And will try to improve the system. That is the sign of real python programmer. So guys what we will do here now is Simply we will note what modules we will install. So this is pip install wikipedia So I will do one thing here I will click slash like this This will be our pip install speechRecognition So if someone hasn't installed the module So he/she can atleast install the module. And after that here.. pyttsx So I will write here pip install pyttsx3. So this will be installed with pip install pyttsx3. And our program is completed now. I hope you all understood this. And you all can appreciate this That what a fascinating program we have created. I was very excited for creating this And I will use this. And it will work well in my computer. And this will be working for me everyday. It will say things like good afternoon. And It will impress people. "OPEN GOOGLE" See it has opened google. And now i can search here anything. Now I will say my next query that is play music. So it has already played music for me And my music is started. Very good. *Playing Music* So I have only one mp3 here. I will close this. So I have only one mp3 so only that is played. You all avoid print statements in your program. Program becomes messy due to that. So now only like this video If you enjoyed it. And Let me know in comments I keep interacting in pinned comment. Let me know the review of this code. And how will you all enhance this. So Guys I hope you all understood this video And you all were able to write this code with me. I want to tell you something. That in Jarvis, the quit functionality That you all say quit and Jarvis Quits. I haven't done that I want you all to implement that on your own. Simply you have to write if "quit" in query After that you can write exit. Exit is a function in python if you all can remember. I have included that in my python programming for absolute beginners. If you all haven't accessed this course playlist Then you can find the link in description and access it. Playlist is like index of a book In which all the course details Its all in front of you and complete your course. Thats why this course playlist is very important. One more thing I want to show you is that many people will argue that This is not AI or artificial intelligence This is a bunch of if else statements But if we go in basic definition of artificial intelligence Then that goes like Whatever work a person do That work a computer can do So it is called as artificial intelligence. So if this isn't a good example of artificial intelligence But this is artificial intelligence We haven't used machine learning algorithms here But by using this architecture Machine learning package like scikit, tensorflow can be implemented. We can create chatbots We can create out computer emotionally fit We can make it understand things emotionally. So this all things we can implement in this This all things we can do sometime else Thats why I tell you subscribe below So whenever that video come you'll get it. I have many plans for this channel. And we will develop good projects We developed todays project, like this we will create more projects. Just like this video now only If you all want to see more projects like this And I want to This course of mine Python tutorial for absolute beginner Share it with your friends Because i have put a lot of work in this And I want more people to access this course And more people should benefit from this So I hope you all have liked this And I want to say you thankyou in advance That was all for this video. What do you feel about Jarvis and whatever additional functionality you will add Let me know in the comments I want to see people who add additional functionality I will give those people a heart. And honestly I will appreciate this If you all write something in the comments You all enhanced Jarvis I am using Jarvis personally to be honest. I am personally using this. I don't want to type youtube.com I will just say open youtube. And Youtube will be opened. Along with this you want to create Jarvis in Hindi So you all can create it in hindi If out engine understands Hindi convieniently So you all can make it speak and understand hindi. I want you all to do that also. Mention all the enhancements in the comments. And I will be be very happy if you all do something like this. So that was all for this video. Please like this video. Thankyou so much guys for watching this video. And I will see you next time. *Outro Music*
Info
Channel: CodeWithHarry
Views: 3,353,842
Rating: undefined out of 5
Keywords: python jarvis, python project ideas, personal assistant python, python ai tutorial, python ai assistant, virtual assistant python, Iron Man Jarvis AI, iron man jarvis, fun python project, python, python tutorial, python tutorial for beginners, python iron man ai, python programming, python project, python project for beginners, python application examples, python text to speech, python ai, python projects to work on, python jarvis tutorial, python jarvis ai, iron man ai
Id: Lp9Ftuq2sVI
Channel Id: undefined
Length: 58min 47sec (3527 seconds)
Published: Wed May 01 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.