Desktop Assistant Using Python Programming

Lakshay Sharma
Impelsys
Published in
4 min readMar 21, 2023

by Lakshay Sharma

Have you ever wondered how cool it is to have our own assistant? Imagine doing different tasks like Sending E-mails, Playing Music, and doing Wikipedia searches without opening web browsers just with a single voice command.

What can this Desktop Assistant do for us?

  1. It can send E-mails on our behalf.
  2. It can play music for us using YouTube.
  3. Can do Wikipedia searches for us.
  4. It can open websites like Google, YouTube, etc.
  5. We can also make it to open any Desktop Application we want like code editor or Ide with a single voice command.

Technology Used: -

  1. Python Programming
  2. Visual Studio Code

Python Programming

> Python is a popular general-purpose programming language. It is used in machine learning, web development, desktop applications, and many other fields. Fortunately, Python features a simple and easy-to-use syntax for beginners. This makes Python a significant language to learn for beginners. Python Programming Language is very well suited for Beginners, also for experienced programmers with other programming languages like C++ and Java.

Visual Studio Code

> Visual Studio Code is a code editor used for development operations like debugging, task running, building products, and version control. It is one of the best tools that every developer needs for a quick code build-debug cycle. Some benefit of using the visual studio is that it has several built-in libraries which can help to write long and efficient programs like Pandas, Numpy, Matplotlib, Scipy, etc.

Some Functionalities and Libraries used

1. Explaining Speak() Function

> First thing for our Desktop Assistant is that it should be able to speak. To make our Assistant talk we need speak function. This function takes audio as an argument and then will pronounce it.

def speak():
pass # This is the way to create function() in Python.

2. pyttsx3 Library

> This is a Python library that helps us to convert text to speech. In other words, we can say it is a text-to-speech library.

> It also works offline, and it is compatible with both the version of Python that is Python2 & Python3.

> It is a Microsoft Developed Speech API that helps in the synthesis and recognition of voice.

> With the help of voice id we can select different voices like of Male and Female.

We can Install any library using the command pip install in Vs Code. Ex:-

pip install pyttsx3     # Installation of pyttsx3  

3. wishme() Function

def wishme():    # Function
pass

We can create as many functionalities as we want according to our requirements. This function I created this because I want that my computer will greet me according to time like Good Morning at the time of Good Morning similarly Good Afternoon and Good Night.

4. Explaining takeCommand() Function

The most important thing about our Desktop Assistant is that it should take command with the help of microphone input from the user.

Before defining this function we need to install the Speech Recognition module and Wikipedia module with the same method using pip install.

pip install speechRecognition  # Installing Module 
pip install wikipedia # Installing Module

After this take command function is completed, we need to create more functionalities such as Wikipedia Searches, Playing Music, and opening some particular desktop applications, etc.

5. smtplib Library

SMTP (Simple Mail Transfer Protocol) is a protocol that allows us to send emails and route emails between mail servers. An instance method called send email is present in the SMTP module. This method allows us to send an email instantly. The three parameters that it takes: -

  1. The Sender: E-mail address of the sender.
  2. The Receiver: E-mail of the receiver.
  3. The Message

We will create a sent E-mail() Function, which will help us send emails to multiple recipients.

Summary

  1. First of all, we have created a wishme() function that greets us depending on the time of our Pc.
  2. After the wishme() function, we have created a takeCommand() function, which helps our Desktop Assistant to take commands from the user. The user’s query will also be returned by this function in string format.
  3. We developed the code logic for opening websites like Google, YouTube, Stack overflow, and other desktop application.
  4. Developed code logic for opening VS Code.
  5. At last, we added functionality that can send emails from voice commands.

--

--