QUICK TIP - Python – Building a Virtual Assistant Robot With 50 Code Lines

0 12,415
zero_to_hero_python_3_full_stack_masterclass_45_ai_projects.jpg | A&H Business Technology
Related posts

As society grows, technology is also growing rapidly, we can see that more and more technology projects are coming out with smart, close and understand with humans, support a lot for people in everyday tasks, they call it AI, so what is AI?

What is AI?

 

  • AI – Artificial Intelligence, also known as Artificial Intelligence, is a science and technology for manufacturing intelligent machines, especially intelligent computer programs.
  • AI is done by studying the way people think, the way people learn, decide and work while solving a problem, and using these research results as a basis for develop intelligent software and systems, which can be applied to different purposes in life. In simple terms, AI is the use and analysis of input data to make predictions and then make a final decision.

In recent years AI has been booming and popular, it’s really hot, and I myself really like and understand this field so today we will go together to build for ourselves one. Virtual assistant like Siri or Google Assistant in python is very simple with just over 50 lines of code:

Let’s go to build it now.

Setup environments

First we need to set up the environments and install python on our machine, if you already have python on your computer, you can skip this step:

Ok next we need to visualise and divide the whole article into small parts, try to visualise with a virtual assistant, what functions does it need to have?

1: It must be audible

2: It must understand

3: It must be readable

 

Coding – Building a Virtual Assistant Robot With 50 Code Lines

Ok, now we are going to write the listening program of this robot:

I created a file named:

  • First we need to install the library named speech_recognition

pip install speechrecognition pip install pyaudio

hearing.py


  • In order for the robot to speak, or convert words into words, we need to download a library to do this:

Run:

pip install pyttsx3

Then before running the command below, you must make sure that it is installed pipalready!

You can see how to install it piphere.

https://pypi.org/project/pip/

(If you use windows and install pyttsx3, there is an error, please refer to the fix here.)

https://stackoverflow.com/questions/52283840/i-cant-install-pyaudio-on-windows-how-to-solve-error-microsoft-visual-c-14

speaking.py

  • At this point, when you run the command python3 noi.py, your computer will speak the sentence"I can't hear you, try again"

understand.py


ok and now I will put the other 3 files together into 1 file okay:

robot.rb

 

And then run the file python3 robot.pyand try chatting with it!

That’s like you saw above we have just completed a virtual assistant with python, with just over 50 lines of code is not too difficult, right now it is not very smart. You can continue to develop and customise to improve it.

TinyURL for this post: https://tinyurl.com/y52dgf98

Sorry, The Comment Form Is Temporarily Closed At This Time
You may also like

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More

Language:English