Creating Your Own Voice Assistant in Python

Let’s be honest with ourselves, at some point in our lives we wanted our own Jarvis. There’s something incredibly awesome about having a personal voice assistant to be able to give us information, manage our schedules, and just help us out with our day to day lives. In this article, we’ll build a foundation with python that you can use to build your own personal voice assistant. -------------------------------------------------------------------------------- How the Voice Assistant Works Th

July 4, 2022 1 Min Read
Creating Your Own Voice Assistant in Python
Creating Your Own Voice Assistant in Python

Codesphere

From everyone in the Codesphere Team:)

Table of Contents

Let’s be honest with ourselves, at some point in our lives we wanted our own Jarvis. There’s something incredibly awesome about having a personal voice assistant to be able to give us information, manage our schedules, and just help us out with our day to day lives.

In this article, we’ll build a foundation with python that you can use to build your own personal voice assistant.


How the Voice Assistant Works

The foundation of our program will be a speech recognition library and a Text to speech library(TTS) which will allow us to communicate with our script purely through audio.

The script will run on a loop of:

  • Waiting for a command from the user
  • Understanding and fulfilling a command

We’ll add some basic examples to do some small talk, tell the time, open apps and a few other things. This foundation can very easily be augmented to add whatever functionality you might want from your assistant. If you can do it in python, you can make the bot do it.


Setup

In a new python project, first install the speech recognition library with:

pip install SpeechRecognition

And install the TTS library with:

pip install pyttsx3


The Code

In a python file, we’re then going to:

  • Load in our imports
  • Configure the text to speech
  • Define our speech function

The bot above can fulfill the following commands:

  • Tell the time
  • Give a random number
  • Open and Close Slack

Building More

Whatever tasks you want your assistant to complete, you can now simply add another conditional to the list!

Of course, you can add a lot more complexity:

  • Power the assistant w/ Conversational AI via Rasa
  • Play music with the Spotify API
  • Pull information from wikipedia via Web Scraping

That’s all for today!

About the Author

Creating Your Own Voice Assistant in Python

Codesphere

From everyone in the Codesphere Team:)

We are building the next generation of Cloud, combining Infrastructure and IDE in one place, enabling a seamless DevEx and eliminating the need for DevOps specialists.

More Posts

How to Deploy Gleam on Codesphere?

How to Deploy Gleam on Codesphere?

Gleam is a newly released functional programming language. Follow this tutorial to build a simple web app with Gleam and deploy it on Codesphere.

Good Coding Practices: Codesphere Version

Good Coding Practices: Codesphere Version

Adhering to good coding practices and maintaining a consistent codebase is the differentiating factor when it comes to developer experience and efficiency.