Making a menu-driven OS program launcher in python: With speech assistance

Have you ever wondered how to just talk to your computer and tell it to open the browser or play music for you? If yes, then this is the software for you.

We see Siri and Alexa everywhere today, ready to assist us with anything. If you are anything like me, you must have wondered how it actually works. There must be some complicated coding with some technical mumbo-jumbo behind it… Absolutely NOT! What a surprise. Just a few lines of code with some amazing modules can do the trick. Read on to find out how to make your own speech assisted programs. For this example, I have decided to make a simple program launcher for Windows Operating System.

This simple and intuitive code in python allows us to talk to our computer and tell it to keep our tabs ready. What a great help especially on not-so-great days. Whether it’s because of your jam packed schedule or simply because you’re feeling lazy, what a great way to get assistance for your laptops or computers.

Imported Libraries

I have started off by importing 3 libraries:

  1. os
  2. pyttsx3 (to convert text to speech)
  3. speech_recognition (to accept user’s input by them talking to the device)

It is followed by instructing the user to tell the device what needs to be done. As seen in the image, it is printed on the screen as well as said out loud by the device in the form of audio instruction.

Voice Input taken by the device from the user

Following this we accept the input from the user as the user talks back to the device. Then using a loop, the input is taken and the required action is performed. The output confirms the action as shown below.

the browser, notepad and window media player opened and output confirmed by the output box

The simple command os.system() was able to automate the launching of OS programs. This was my take on creating a menu-driven OS program launcher using python. Hope you enjoyed the article!

Keep learning, keep exploring and be joyful!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Janhavi Jain

Hi there! I write about many technologies like Docker and Hadoop in an easy to understand language. My LinkedIn: https://www.linkedin.com/in/janhavi-jain