Get startedGet started for free

Using the SpeechRecognition library

To save typing speech_recognition every time, we'll import it as sr.

We'll also setup an instance of the Recognizer class to use later.

The energy_threshold is a number between 0 and 4000 for how much the Recognizer class should listen to an audio file.

energy_threshold will dynamically adjust whilst the recognizer class listens to audio.

This exercise is part of the course

Spoken Language Processing in Python

View Course

Exercise instructions

  • Import the speech_recognition library as sr.
  • Setup an instance of the Recognizer class and save it to recognizer.
  • Set the recognizer.energy_threshold to 300.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Importing the speech_recognition library
import ____ as ____

# Create an instance of the Recognizer class
____ = sr.____()

# Set the energy threshold
recognizer.____ = ____
Edit and Run Code