Skip to content

srinivaspedapati/Voice-Assistant-using-Speech-Recognition

Repository files navigation

Desktop Based Voice Assistant Pi Using Speech Recognition

Pi is a Desktop based Personal Voice-Assistant and devloped using python 3.5+ version.

It works on the principle of Speech-Reccognition i.e., it takes human speech as input and converts the speech-to-text using the Google API and can further communicate with the user, based on the command (speech) recieved. Upon recieving the command the Pi executes the python block associated with the keyword in command.

To speak or communicate back with the user it has to convert text-to-speech which is done with the help of Microsoft Speech API (SAPI).

Some of the Tasks that the Pi can perform are:

  • Greeting the user upon start-up
  • Bithday notifier
  • Reminder notifier
  • Water reminder notification
  • Tells current day's date and day
  • Gives weather updates
  • Tells any random joke
  • Open's any desired website/URL
  • Gives latest news feed
  • tells about anything from wikipedia
  • carry outs a search request using googlesearch
  • Tells the possible meanings of the word or phrase
  • Gives the latest updates on coronavirus in India/World (or any other specific country )
  • Suggests some of the most read books in the current week (source: Goodreads)
  • Launches any application
  • Calculates any simple mathematical expression
  • Answers basic general questions
  • Suggests some of the top movies to watch (source: IMDB)

Requirements:

  1. Desktop (Windows OS)
  2. Python version supported: 3.5+
  3. Microsoft Speech API [SAPI]

Working:

Python Libraries:

  1. SpeechRecognition - Library for performing speech recognition, with support for several engines and APIs, online and offline. The SpeechRecognition module requires PyAudio Module for Microphone input.

  2. win32com - This module allows us to easily access Window’s Component Object Model (COM) and control Microsoft applications via python. In this script, we use this module to invoke SAPI.

  3. win10toast - An easy-to-use Python library for displaying Windows 10 Toast Notifications which is useful for Windows GUI development.

  4. pyowm - PyOWM is a client Python wrapper library for OpenWeatherMap web APIs. It allows quickly retrieve weather updates and also other data. However, This requires API key to Retrieve data availible at the website

  5. newsapi - For News Updates from News API, The API_key can be obtained from the website.

  6. wikipedia - Wikipedia is a Python library that makes it easy to access and parse data from Wikipedia. Search Wikipedia, get article summaries, get data like links and images from a page, and more.

  7. wolframalpha - This module is a computational knowledge engine or answer engine that answers our basic mathematical computational querys or general questions. The app_idan obtained from [WolframAlpha](https://www.wolframalpha.com/.

  8. oxforddictionaries - This is a python wrapper for the Oxford Dictionary API. The Oxford API offers a free plan with up to 3,000 requests per month with ull access to Oxford Dictionaries data, although we will need to register for an API key availible at the website.

Installing Wheel Package Guide

Some of the modules comes pre-installed with python.

Scheduling Python Script on Start-Up:

To Automate the Voice-Assistant Pi on start-up, we need to schedule the python script to run when the system starts, using following steps:

  1. Create a Batch File

    Open a Text Document and Add python.exe and python script path to it in the below syntax:

    "python.exe path" "python_script path"
    

    SS1

    Save the Text Document as batch file using the .bat extension & Double-click the batch file to run it.

  2. Open Task Scheduler

    Create a Basic Task & Enter the Name and Description of the Task, Click Next.

    Click Next. Select the Task Trigger Time, as When computer turns on, Click Next.

    Now Select the Action to Perform, as start a program, Click Next.

    Browse the Batch File path and add it and Click Finish.

Some of the pre-defined commands that the Pi can understand are:

  • What date is today?
  • How is the weather today?
  • Tell me a joke
  • Open Chrome // command must be preceeded with keyword 'Open'
  • Open Word // command must be preceeded with keyword 'Open'
  • Give me some news Updates
  • search encyclopedia // command must be preceeded with keyword 'search'
  • Tell me the meaning of '___'
  • Give me updates on corona virus
  • suggest me a book to read
  • pi what is 2 plus 3? // command must be preceeded with pi
  • pi what is cos 0? // command must be preceeded with pi
  • pi what is the capital of india? // command must be preceeded with pi
  • suggest me movie to watch
  • pi shutdown

Screenshots:

Troubleshoot:

[1]. SpeechRecognition