The Wayback Machine - https://web.archive.org/web/20240906224044/https://www.geeksforgeeks.org/hotword-detection-with-python/
Open In App

Hotword detection with Python

Last Updated : 07 Mar, 2024
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

Most of us have heard about Alexa, Ok google or hey Siri and may have thought of creating your own Virtual Personal Assistant with your favorite name like, Hey Thanos!. So here’s the easiest way to do it without getting your hands dirty.
Requirements: 
 

  1. Linux pc with working microphones (I have tested on Arch Linux).
  2. Install python3, pyaudio, sox(and also swig for Arch Linux) with your package manager.: 
     
sudo apt-get update
sudo apt-get install python3 python3-pip
sudo apt-get install python-pyaudio python3-pyaudio sox
  1. This file works with all Linux based OS. 
    Snowboy also supports all versions of Raspberry Pi (1, 2, 3 and Zero). Supported OS is Raspbian 8.0.
  2. Now when you extracted with a folder named usr.Now navigate to usr/lib/python3.7/site-packages.
  3. Copy both folder(snowboy and snowboy-1.2.0b1-py3.7.egg-info) to /usr/lib/python3.7/site-packages either by using file manager or cp -r command. 
     
cd Downloads
tar -xf python-snowboy-1.3.0-1-x86_64.pkg.tar.xz
cd usr/lib/python3.7/site-packages
sudo cp -r snowboy /usr/lib/python3.7/site-packages
sudo cp -r snowboy-1.2.0b1-py3.7.egg-info

Now you can check if snowboy works or not. Fire up your terminal and type Python to get the python shell. 
 

Python3




from snowboy import snowboydecode


If this does not throw import error then you are ready to go further.
Now go to snowboy website and do login. Once you login in, you will find create Hotword option and do further things as per instructions.once whole process is completed download the yourhotword.pmdl file which is generated.
Copy the hotword.pmdl file to directory where you are going to create program. 
 

Python3




from snowboy import snowboydecoder
def detected_callback():
    print ("hotword detected")
  
    # do your task here or call other program.
detector = snowboydecoder.HotwordDetector("hotword.pmdl",
                       sensitivity = 0.5, audio_gain = 1)
  
detector.start(detected_callback)


Output: 
 

Voice Input :  hey thanos
Output:
INFO:snowboy:Keyword 1 detected at time: 2019-05-09 21:55:16
hotword detected

This code will keep on running until you interrupt it with Ctrl+C or close terminal. As this code works offline (and does not connect to internet) so it does not stream your voice, so there is no risk of privacy. The hotword.pmdl file contains the model of your voice only. So, the above program will work with your voice only.
You can implement this program to another program to and carry out tasks controlled by voice.
 


Previous Article
Next Article

Similar Reads

Real-Time Edge Detection using OpenCV in Python | Canny edge detection method
Edge detection is one of the fundamental image-processing tasks used in various Computer Vision tasks to identify the boundary or sharp changes in the pixel intensity. It plays a crucial role in object detection, image segmentation and feature extraction from the image. In Real-time edge detection, the image frame coming from a live webcam or video
5 min read
Python | Corner detection with Harris Corner Detection method using OpenCV
Harris Corner detection algorithm was developed to identify the internal corners of an image. The corners of an image are basically identified as the regions in which there are variations in large intensity of the gradient in all possible dimensions and directions. Corners extracted can be a part of the image features, which can be matched with fea
2 min read
Python | Corner Detection with Shi-Tomasi Corner Detection Method using OpenCV
What is a Corner? A corner can be interpreted as the junction of two edges (where an edge is a sudden change in image brightness). Shi-Tomasi Corner Detection - Shi-Tomasi Corner Detection was published by J.Shi and C.Tomasi in their paper 'Good Features to Track'. Here the basic intuition is that corners can be detected by looking for significant
3 min read
Opencv Python program for Face Detection
The objective of the program given is to detect object of interest(face) in real time and to keep tracking of the same object.This is a simple example of how to detect face in Python. You can try to use training samples of any other object of your choice to be detected by training the classifier on required objects. Here is the steps to download th
2 min read
Python - Tuple key detection from value list
Sometimes, while working with record data, we can have a problem in which we need to extract the key which has matching value of K from its value list. This kind of problem can occur in domains that are linked to data. Lets discuss certain ways in which this task can be performed. Method #1 : Using List comprehension This task can be performed usin
6 min read
Face Detection using Python and OpenCV with webcam
OpenCV is a Library which is used to carry out image processing using programming languages like python. This project utilizes OpenCV Library to make a Real-Time Face Detection using your webcam as a primary camera.Following are the requirements for it:- Python 2.7OpenCVNumpyHaar Cascade Frontal face classifiers Approach/Algorithms used: This proje
4 min read
Python | Real time weather detection using Tkinter
Prerequisites : Introduction to tkinter | Find current weather of any cityPython offers multiple options for developing GUI (Graphical User Interface). Out of all the GUI methods, tkinter is the most commonly used method. It is a standard Python interface to the Tk GUI toolkit shipped with Python. Python with tkinter outputs the fastest and easiest
5 min read
Car driving using hand detection in Python
In this project, we are going to demonstrate how one can drive a car by just detecting hand gestures on the steering wheel. Let's say the requirement is something like this - If driver wants to start the car then put both of your hands on the steering wheel. If someone having no hands on a steering wheel that means brakes of car will be applied slo
3 min read
Python | Document field detection using Template Matching
Template matching is an image processing technique which is used to find the location of small-parts/template of a large image. This technique is widely used for object detection projects, like product quality, vehicle tracking, robotics etc. In this article, we will learn how to use template matching for detecting the related fields in a document
2 min read
Circle Detection using OpenCV | Python
Circle detection finds a variety of uses in biomedical applications, ranging from iris detection to white blood cell segmentation. The technique followed is similar to the one used to detect lines, as discussed in this article. Basics of Circle Detection A circle can be described by the following equation: To detect circles, we may fix a point (x,
3 min read
White and black dot detection using OpenCV | Python
Image processing using Python is one of the hottest topics in today's world. But image processing is a bit complex and beginners get bored in their first approach. So in this article, we have a very basic image processing python program to count black dots in white surface and white dots in the black surface using OpenCV functions (cv2.imread, cv2.
4 min read
Text detection using Python
Python language is widely used for modern machine learning and data analysis. One can detect an image, speech, can even detect an object through Python. For now, we will detect whether the text from the user gives a positive feeling or negative feeling by classifying the text as positive, negative, or neutral. In the code, Vader sentiment analysis
4 min read
Pedestrian Detection using OpenCV-Python
OpenCV is an open-source library, which is aimed at real-time computer vision. This library is developed by Intel and is cross-platform - it can support Python, C++, Java, etc. Computer Vision is a cutting edge field of Computer Science that aims to enable computers to understand what is being seen in an image. OpenCV is one of the most widely used
3 min read
Python - Edge Detection using Pillow
Edge Detection, is an Image Processing discipline that incorporates mathematics methods to find edges in a Digital Image. Edge Detection internally works by running a filter/Kernel over a Digital Image, which detects discontinuities in Image regions like stark changes in brightness/Intensity value of pixels. There are two forms of edge detection: S
5 min read
Multiple Color Detection in Real-Time using Python-OpenCV
For a robot to visualize the environment, along with the object detection, detection of its color in real-time is also very important. Why this is important? : Some Real-world Applications In self-driving car, to detect the traffic signals. Multiple color detection is used in some industrial robots, to performing pick-and-place task in separating d
4 min read
Contour Detection with Custom Seeds using Python - OpenCV
This article discusses how we can dynamically detect contours by clicking on the Image and assign different colors to different parts of the image. Contours are a very useful tool for shape analysis and object detection and recognition. This program uses OpenCV, Numpy, and Matplotlib libraries. It also uses a built-in OpenCV Watershed algorithm to
3 min read
Automating Scrolling using Python-Opencv by Color Detection
Prerequisites: OpencvPyAutoGUI It is possible to perform actions without actually giving any input through touchpad or mouse. This article discusses how this can be done using opencv module. Here we will use color detection to scroll screen. When a certain color is detected by the program during execution the screen starts to scroll on its own. App
2 min read
Language Detection in Python using Tkinter
Prerequisite: Tkinter In this article, we will learn about language detection Using Python in Tkinter. In Simple Words, language identification is the problem of determining which natural language given content is in. Modules UsedTkinter module is used in Python to create GUI based interfaces.For Language detection, we will use the langdetect Modul
2 min read
Facial expression detection using Deepface module in Python
In this article, we are going to detect the facial expression of an already existing image using OpenCV, Deepface, and matplotlib modules in python. Module NeededOpenCV: OpenCV is an open-source library in python which is used for computer vision, machine learning, and image processing.Matplotlib: Matplotlib is a comprehensive library for creating
2 min read
Python Arcade - Collision Detection
In this article, we will learn How we can add collisions in arcade games in Python. Installation You can install the Arcade module using the below command: pip install arcadeExample 1: In this example, we are going to use the check_for_collision() function to add collision between 2 sprites. Syntax: arcade.check_for_collision( sprite1, sprite2) Par
4 min read
Face detection using Cascade Classifier using OpenCV-Python
In this article, we are going to see how to detect faces using a cascade classifier in OpenCV Python. Face detection has much significance in different fields of today's world. It is a significant step in several applications, face recognition (also used as biometrics), photography (for auto-focus on the face), face analysis (age, gender, emotion r
4 min read
Feature detection and matching with OpenCV-Python
In this article, we are going to see about feature detection in computer vision with OpenCV in Python. Feature detection is the process of checking the important features of the image in this case features of the image can be edges, corners, ridges, and blobs in the images. In OpenCV, there are a number of methods to detect the features of the imag
5 min read
Python OpenCV - Roberts Edge Detection
Edge detection refers to a set of mathematical techniques for recognizing points in a digital image where the image brightness abruptly changes or, more formally, where there are discontinuities. The sharp fluctuations in image brightness are usually grouped into a collection of curved line segments called edges. Roberts Edge DetectionThe Roberts o
3 min read
Eye blink detection with OpenCV, Python, and dlib
In this article, we are going to see how to detect eye blink using OpenCV, Python, and dlib. This is a fairly simple task and it requires you to have a basic understanding of OpenCV and how to implement face landmark detection programs using OpenCV and dlib, since we'll be using that as the base for today's project. Stepwise ImplementationStep 1: I
6 min read
Brightness Control With Hand Detection using OpenCV in Python
In this article, we are going to make a Python project that uses OpenCV and Mediapipe to see hand gesture and accordingly set the brightness of the system from a range of 0-100. We have used a HandTracking module that tracks all points on the hand and detects hand landmarks, calculate the distance between thumb tip and index fingertip and maps the
6 min read
Python OpenCV - Drowsiness Detection
The number of fatalities on the road due to drowsiness is very high. Thus python allows the model of deep learning algorithm via including the use of OpenCV. Drowsiness Detection is the detection of a person to check whether the person is feeling sleepy while performing a significant task. This detection has many applications in medical and safety
9 min read
Detection of a specific color(blue here) using OpenCV with Python
The following code in python uses OpenCV library which is employed for image processing techniques. The program allows the detection of a specific color in a live stream video content. A video is composed of infinite frames at different time instants. We will detect the colour of every frame one by one. The code will only compile in linux environme
4 min read
Right and Left Hand Detection Using Python
In this article, we are going to see how to Detect Hands using Python. We will use mediapipe and OpenCV libraries in python to detect the Right Hand and Left Hand. We will be using the Hands model from mediapipe solutions to detect hands, it is a palm detection model that operates on the full image and returns an oriented hand bounding box. Require
5 min read
Character Encoding Detection With Chardet in Python
We are given some characters in the form of text files, unknown encoded text, and website content and our task is to detect the character encoding with Chardet in Python. In this article, we will see how we can perform character encoding detection with Chardet in Python. Example: Input: data = b'\xff\xfe\x41\x00\x42\x00\x43\x00'Output: UTF-16Explan
2 min read
Line detection in python with OpenCV | Houghline method
The Hough Transform is a method that is used in image processing to detect any shape, if that shape can be represented in mathematical form. It can detect the shape even if it is broken or distorted a little bit.We will see how Hough transform works for line detection using the HoughLine transform method. To apply the Houghline method, first an edg
6 min read
Practice Tags :