AI Assistant From Basic to Advance - Part - 1

If you're thinking that this is just an ordinary tutorial, you're in for a surprise. This is not just a simple assistant it's much more than that.

We're going to go beyond just programming and show you how to integrate your assistant with electronics and automation. This project is perfect for exploring the development and learning about different concepts, such as automation and artificial intelligence.

If you take a look around, you'll see that all technologies are based on both programming and electronics. In this project, we're going to show you how you can create and integrate these different domains of concepts to make something truly amazing.

Not only will you learn how to code and work with electronics, but you'll also get hands-on experience integrating them into a single project. This is a great opportunity to explore the intersection of programming and electronics and see how they can work together to create something awe-inspiring.

So join us on this journey as we show you how to make and learn about advanced AI assistants that can do just about anything. This is a chance to push the limits of your knowledge and skills, and we can't wait to see what you'll create.

This series is not just a tutorial it's an opportunity to experiment and push the limits of what's possible. So if you're ready to take your skills to the next level and create an assistant that can do just about anything, then this series is for you.

Are you ready to join us on this journey! Let's get started!


To make a basic assistant using Python, you will need the following:
  • A computer with Python installed. You can download Python from the official website and install it on your computer.
  • A text editor or integrated development environment (IDE) to write your Python code. Some popular IDEs for Python include PyCharm, Visual Studio Code, and IDLE (which comes bundled with Python).
  • The necessary libraries and modules to build your assistant. Depending on the functionality you want to implement, you may need to install additional libraries and modules. For example, if you want to build a voice-based assistant, you may need to install the SpeechRecognition library.
  • Knowledge of Python programming. You will need to be familiar with the basic syntax and concepts of Python in order to write the code for your assistant. If you are new to Python, it is recommended to start with some basic tutorials and work your way up to more advanced topics.
  • A clear idea of the functionality you want to implement in your assistant. Defining the goals and capabilities of your assistant will help guide the development process and ensure that you have a functional and useful end product.



  • import datetime
  • import pyttsx3 # pip install pyttsx3
  • import speech_recognition as sr # pip install SpeechRecognition
This imports the necessary libraries. datetime is a built-in Python library for working with dates and times. pyttsx3 is a library for converting text to speech. speech_recognition is a library for performing speech recognition, converting spoken audio to text.
  • engine = pyttsx3.init() # initialise pyttsx3
  • voices = engine.getProperty('voices')
  • engine.setProperty('voice', voices[1].id) # 0-2 range for different voices
  • voicespeed = 140 # setting speed
  • engine.setProperty('rate', voicespeed)
This initializes the pyttsx3 engine and sets the voice to use and the speed at which the voice will speak.

#Speak function

  • def speak(audio):
  • engine.say(audio)
  • engine.runAndWait()
This defines the speak function, which takes an audio string as input and speaks it using the pyttsx3 engine.

#takeCommand function

  • def takeCommand():
  • """Listen for a command from the user and return it as text."""
  • r = sr.Recognizer()
  • with sr.Microphone() as source:
  • print("Listening...")
  • r.pause_threshold = 1
  • audio = r.listen(source)

  • try:
  • print("Recognising...")
  • query = r.recognize_google(audio, language='en-us')
  • except Exception as e:

  • print()
  • return "---"
  • return query
This defines the takeCommand function, which uses the speech_recognition library to listen to audio from the user's microphone and convert it to text. If it is unable to recognize the audio, it returns the string "---".

# Time function

  • def time():
  • """Speak the current time."""
  • time ="%H:%M:%S")
  • speak(time)
  • print(time)
This defines the time function, which uses the datetime library to get the current time and speaks it using the speak function. It also prints the current time to the console.

# Wish me function

  • def wishme():
  • speak("welcome back sir")

  • hour =
  • if hour>=6 and hour<=12:
  • speak('Good morning')
  • elif hour>=12 and hour<=18:
  • speak('Good afternoon')
  • elif hour>=18 and hour<=24:
  • speak('Good evening')
  • else:
  • speak('good night')

  • speak('How can i help you today')
The function first uses the datetime module to get the current hour and then uses a series of if statements to check the hour against a set of predefined ranges. If the hour falls within one of the ranges, it prints out a greeting message. If the hour doesn't fall within any of the ranges, it prints out a "good night" message.

Finally, the function prints out a question asking how it can help the user.
Overall, this function seems to be designed to provide a personalized greeting to the user and initiate a conversation.

    # Main loop of the script

    • if __name__ == "__main__":
    • while True:
    • query = takeCommand().lower()
    • print(query)

    • if "good morning" in query:
    • speak("good morning sir")

    • elif "time" in query:
    • time()
    This is the main loop of the script. It repeatedly calls the takeCommand function to get a command from the user and converts it to lowercase. If the command includes the phrase "good morning", the script will respond with "good morning sir". If the command includes the word "time", the script will call the time() function to speak the current time.

    # Error You may Face!

    #1 Solution!

    >> Run this code in terminal
    • pip install pipwin
    • pipwin install pyaudio

    #2 Solution!

    #Click here to install the .whl  file of pyaudio
    NOTE: This is the Python version, so download the appropriate .whl file, Different .whl files for different versions
    #Download and install the whl file as 'pip install pyaudio..whl' file

    # Read!

    Just wanted to let you know that an update to the code will be available soon. This update will include more information and enhancements to the current version. Please make sure to check it out and let me know if you have any questions or feedback.

    # If you face any problem!

    Please raise a query about the error you are facing, and our debugging community will try to assist you. You can also contribute to the community by helping others.


    If you have any doubts, please let me know

    Previous Post Next Post