We are here for you MON-FRI 9AM-5PM info@systeum.cz +420 777 607 467

We are here for you MON-FRI 9AM-5PM obchod@systeum.cz +420 777 607 467

“Bob, write…” 2: practical instructions on how to program a virtual assistant

A virtual assistant can make our lives easier and using our computers and other devices more enjoyable. We described why it’s a good idea not to rely on Google or Siri but to create your own partner in the first article. It also included tips on what you can teach your Bob.

Together with Standa Keppert, we have prepared a practical guide on how to program a basic version of your future assistant. Let’s call it the “He’s not Einstein, but he’s nice” version. The following paragraphs will give you a basic starting point from which you can build on and develop the assistant according to your needs. 

In the first article, we mentioned that Standa communicated with his Bob in Czech. But since he hasn’t perfected it yet and it's his own know-how that he has honestly earned, this time we will share how it will look like with communication in English. However, we believe it’s not a problem. :)

 

Are you interested in the IT field and looking for job positions and opportunities in the IT industry? Whether you are a programmer, developer, tester, analyst, or software architect, contact us and we will find an IT project tailored to your needs from our IT job offers. Take a look at the current available job positions in the IT field. We will help you find new job challenges and opportunities. We look forward to collaborating with you!

 

Let’s begin

To start with, you need to decide which development environment you are going to use to program Bob. You can choose, like Standa, IntelliJ IDEA Community Edition, which is free. You will also need to download and install Python for Windows v3.6 or higher. A few more things will need to be installed in Python:

pip install SpeechRecognition

pip install gtts

pip install playsound

Everything we need is ready, so let’s create a new project.

Then create a file, e.g. MyAssistant.py, to work in and import the following packages.

One of the most important things for our Bob to understand us is to convert voice to text. The listen() function will help us with this.

Hurray. Bob can hear now! And since we want him to respond to us, we use the respond() function.

He’ll hear us and be able to answer us, so let’s create this Bob. We do this in the following class bob_assitent(). We will teach him basic things like checking with IF and a few sets of instructions inside IF.

Here you can define many things that your assistant should be able to do. Let your imagination run wild. :)

In order to call the created functions, we can use the code below.

At the beginning, we promised practical tips for creating a basic version of Bob, working title: “He’s not Einstein, but he’s nice”. So that’s HIM! Our champion!

Well, not exactly. Let’s give him a little more intelligence and teach him something else. :)

Smarter Bob

Create a new python.file and import a few new packages.

Let’s stop for a moment and look at the WolframAlpha package. It allows us to search by voice only. It is only available in English for now, but we definitely recommend using it before the Czech version is available.

To use WolframAlpha, you need to register and insert the key as shown below.

Check out what Bob, who can already communicate in a basic way, can recognise what greetings to say thanks to time functions and also announce he’s talking, looks like.

Next, we’ll look at the commander() class, the main class that listens and converts voice to text.

The commands you want to give to Bob should always be defined in advance. You can use the following examples to help you do this:

  • work with Google
  • work with e-mail
  • and other things you can teach him


    You can also program the assistant to log you into your e-mail. Just be careful. If you have some super strong password, check four times that you have entered it correctly, otherwise you will get “login failed” (Standa learned this the hard way :)). We also recommend setting up a few standard messages that the assistant will respond to in some way. 

    The assistant can also control things like the programs you use every day: starting music playback, etc. In our case, the player is set by default, so there is no need to define it.

    The image below also shows an example of how to use the WolframAlpha and Wikipedia special APIs. Ask Bob anything and he’ll answer it (assuming he can find the answer, that is).

    Bob (or Jessica, you can name your assistant whatever you like) offers an incredible number of possibilities and options for working with him. Don’t be afraid to build on this base and continue to improve him according to your ideas and fantasies. Maybe also in the form of a hologram with Jessica Alba’s face, as Standa has planned for the future. :)

     

🟡 Are you looking for an interesting project? Check out how we do things here and see which colleagues we're currently looking for.

🟡 Do you have a colleague or friend who is looking for a new project? Join our Referral program and get a financial reward for your recommendation.

🟡 Would you like to start working in IT? Download our ebook START WORKING IN IT: From First Steps to Dream Job, in which we guide you step by step with information, courses, and practical experience that are so essential not only for those who want to switch fields, but also for those who want to advance their careers and further their education.

Or share this article, which may also be useful to your acquaintances.


Would you like to receive our articles regularly in your inbox? 
Give us your e-mail address and we will be happy to serve as carrier owls.

You may also be interested in

How to program your first project i...

Reading time 10 min + 1.12.2021

“Bob, write…” or who wouldn’t want ...

Reading time 4 minuty 9.2.2022

How to develop your own mobile game...

Reading time 5 minut 29.6.2021

What they say about us?
 Ask our clients…

Systeum
Systeum

„Systeum is one of the biggest providers of our testing capacities. Years of cooperation have proved the outstanding quality of candidates. I also appreciate the willingness of the whole team.“

Head of test execution

„I really appreciate individual approach. Systeum provides us with teams of testers, C/C++ and Java developers. Specialists meet our requirements on knowledge of network protocols and cloud solutions“

Chief Technology Officer

„Systeum is our stable, long-term partner. Thanks to Systeum we have functional high quality senior teams of C++ embedded developers and auto testers sice 2015.“

Head of Payment Application

„Systeum, thank you for your help to find the right fit to my team! I can recommend cooperation with you to everybody. Very professional, smooth and friendly.“

IT CIM Inventory Management Development

Examples of long-term cooperation

Komerční banka Monster Generali Porsche Raiffeisen BANK Moneta