To build voice enabled objects/applications with Python and ReSpeaker
Clone or download
Latest commit ea9ccdc Oct 29, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples add Apr 16, 2018
respeaker enumerate usb when needed Mar 12, 2018
.gitignore v0.3.0 Sep 25, 2016
.travis.yml Fixed broken imports and added Python 3.5 support Jan 18, 2017
LICENSE Adds apache license file Jul 3, 2017 Update Oct 29, 2018
README.rst v0.3.0 Sep 25, 2016
requirements.txt remove hidapi from requirements Apr 13, 2017
setup.cfg to build universal whell Oct 20, 2016 0.6.1 Mar 12, 2018

ReSpeaker Python Library

Build Status

ReSpeaker is an open project to create voice enabled objects. ReSpeaker python library is an open source python library to provide basic functions of voice interaction.

It uses PocketSphinx for keyword spotting and uses webrtcvad for voice activity detecting.

Installation (Not for ReSpeaker Core)

Note: This library is already installed on ReSpeaker Core by default. Please skip the installation step and don't re-install it

python and pip are required.

  1. Install pocketsphinx, webrtcvad

On windows, we can use pre-compiled python wheel packages of pocketsphinx and pyaudio from speech_recognition. For python 2.7, run:

pip install
pip install

On Linux

pip install pocketsphinx webrtcvad
  1. pip install pyaudio respeaker --upgrade

  2. Install hidapi (optional)

MacOSX install ReSpeaker Python Library

0.(brew install python2)

1.pip2 install pocketsphinx webrtcvad

2.(Since pyAudio has portAudio as a dependency, you first have to install portaudio: brew install portaudio) pip install pyaudio respeaker --upgrade 3.Install hidapi (optional)

stdio.h file not found error on macOS Mojave

For anyone discovering this later on who may not be familiar with the command line, here's how to install the macOS_SDK_headers_for_macOS_10.14.pkg package as explained in @yicongli's response above:

In or any shell app like iTerm:

cd /Library/Developer/CommandLineTools/Packages/ open macOS_SDK_headers_for_macOS_10.14.pkg

Make sure you go through the whole thing and try to install the gem that failed to install again or run bundle install again if this was something you encountered while trying to install from a Gemfile.

Getting started

import logging
import time
from threading import Thread, Event

from respeaker import Microphone

def task(quit_event):
    mic = Microphone(quit_event=quit_event)

    while not quit_event.is_set():
        if mic.wakeup('respeaker'):
            print('Wake up')
            data = mic.listen()
            text = mic.recognize(data)
            if text:
                print('Recognized %s' % text)

def main():

    quit_event = Event()
    thread = Thread(target=task, args=(quit_event,))
    thread.daemon = True
    while True:
        except KeyboardInterrupt:

if __name__ == '__main__':