Technology, Support & Services

Build Your Own Desktop Voice Assistant in Python

How cool is it to make your own personal assistants like Alexa or Siri?It’s not terribly difficult and may be simply achieved in Python.Personal digital assistants ar capturing plenty of attention late.With growing advancements in AI, coaching the machines to tackle every day tasks is that the norm.Voice based mostly personal assistants have gained plenty of recognition during this era of sensible homes and sensible devices.These personal assistants may be simply organized to perform several of your regular tasks by merely giving voice commands.Google has popularized voice-based search that’s a boon for several like senior voters UN agency aren’t comfy mistreatment the keypad/keyboard.This article can walk you thru the steps to quickly develop a voice based mostly desktop assistant, Minchu (meaning Flash) that you just will deploy on any device.The necessity for developing this application is information of Python.For building any voice based mostly assistant you wish 2 main functions.One for being attentive to your commands and another to retort to your commands.together with these 2 core functions, you wish the tailored directions that you just can feed your assistant.The first step is to put in and import all the required libraries.Use pip install to put in the libraries before mercantilism them.Following ar a number of the key libraries utilized in this program:
  • The SpeechRecognition library permits Python to access audio from your system’s mike, transcribe the audio, and reserve it.
  • Google’s text-to-speech package, gTTS converts your audio inquiries to text.The response from the look-up perform that you simply write for attractive answer to the question is regenerate to an audio phrase by gTTS. This package interfaces with Google Translate’s API.
  • Playsound package is employed to grant voice to the solution. Playsound permits Python to play MP3 files. Web browser package provides a high-level interface that permits displaying Web-based pages to users.
  • Se is an alternative choice for displaying sites. However, for mistreatment this you would like to put in and supply the browser-specific net driver.

Implementation of the Personal Assistant

The entire code for this application is written in Python using libraries supported by Python.

Import required libraries:

Write a function to capture your requests/questions:

Next, write a function to respond to your questions:

Now write the module to add all the required customized responses to your questions:

Once all the modules of your program ar prepared, execute it.you may be excited to listen to your own personal assistant converse with you.you’ll be able to add additional customizations supported your necessities, and develop a really intuitive voice based mostly assistant.Once your desktop assistant is prepared it’s time to deploy it.you’ll be able to convert it into associate feasible file and run it on any device.

Generate an executable for your voice assistant

To create associate degree workable from the Python script you’ll be able to use Pyinstaller.First, you’ve got to convert the .ipynb Python file to a .py extension.Next, use Pyinstaller to make a .exe file for your .py file.All the subsequent steps got to be performed within the electronic communication from the situation wherever Python is installed:
 
The .py file created ought to be settled within the same folder wherever the .ipynb file is found.Once the build is complete, Pyinstaller creates 2 folders, build and dist.Navigate to the dist folder and execute the .exe file to run your personal desktop assistant.This application is transportable and may be dead on any device.

Conclusion

This is however easy it’s to create your own voice assistant.you’ll add more options like play your favorite songs, offer weather details, open email application, compose emails, restart your system, etc.you’ll integrate this application into your phone or pill yet.

Leave a Reply

Your email address will not be published. Required fields are marked *