The SpeechRecognition Package

The SpeechRecognition package provides a high-level interface to record and process audio inputs in Python.

Reference:

Prerequisites

This package depends on another Python package called "pyaudio", which itself depends on a lower-level library caled "portaudio" (not a Python package). To install "portaudio":

  • On a Mac, use homebrew (brew install portaudio).

  • On Windows, use pipwin within an active virtual environment (see installation steps below).

Installation

Do these installation steps after activating a virtual environment.

Windows:

pip install pipwin
pipwin install pyaudio # will install along with lower level binaries
pip install SpeechRecognition # depends on the "pyaudio" Python package

Mac:

Usage

Recording Audio

Record audio using your computer's built-in microphone, and save that to a file:

Recognizing Speech

Record audio using your computer's built-in microphone, and recognize the spoken words:

Last updated

Was this helpful?