Results = wikipedia.summary(query, sentences=2) If 'wikipedia' in query: #if wikipedia found in the query then this block will be executed # Logic for executing tasks based on query Query = takeCommand().lower() #Converting user query into lower case Type the below command to install the Wikipedia module : pip install wikipediaĪfter successfully installing the Wikipedia module, import it into the program by writing an import statement. To do Wikipedia searches, we need to install and import the Wikipedia module into our program. 28:04 – Defining Task 1: To search something on Wikipedia Now, we will develop logic for different commands such as Wikipedia searches, playing music, etc. Return "None" #None string will be returned Print("Say that again please.") #Say that again will be printed in case of improper voice Print(f"User said: \n") #User query will be printed. Query = r.recognize_google(audio, language='en-in') #Using google for voice recognition. Now we are going to add a try and except block to our program to handle errors effectively. We have successfully created our takeCommand() function. #It takes microphone input from the user and returns string output Let's start coding the takeCommand() function : def takeCommand(): assistant will return a string output by taking microphone input from the user.īefore defining the takeCommand() function, we need to install a module called speechRecognition. Install this module by: pip install speechRecognitionĪfter successfully installing this module, import this module into the program by writing an import statement. With the help of the takeCommand() function, our A.I. So, now we will make a takeCommand() function. assistant is that it should take command with the help of the microphone of the user's system. The next most important thing for our A.I. Now, we will use this hour value inside an if-else loop. Here, we have stored the current hour or time integer value into a variable named hour. Now, let's start defining the wishme() function: def wishme(): Import this module to your program by: import datetime To provide current or live time to A.I., we need to import a module called datetime. wish or greet the user according to the time of computer or pc. Now, we will make a wishme()function that will make our J.A.R.V.I.S. Then, install pypiwin32 by typing the below command in the terminal : pip install pypiwin32.Īfter successfully installing pyttsx3, import this module into your program.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |