From 66611dac1ccbd205f727370ac26814c29692e5e6 Mon Sep 17 00:00:00 2001 From: Jag Date: Thu, 8 Aug 2024 13:02:52 -0700 Subject: [PATCH] Moved energy_threshold into an optional Recognizer() __init__ param. --- speech_recognition/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/speech_recognition/__init__.py b/speech_recognition/__init__.py index 022cd7d5..2ea5fc80 100644 --- a/speech_recognition/__init__.py +++ b/speech_recognition/__init__.py @@ -324,11 +324,11 @@ def read(self, size=-1): class Recognizer(AudioSource): - def __init__(self): + def __init__(self, energy_threshold=300): """ Creates a new ``Recognizer`` instance, which represents a collection of speech recognition functionality. """ - self.energy_threshold = 300 # minimum audio energy to consider for recording + self.energy_threshold = energy_threshold # minimum audio energy to consider for recording self.dynamic_energy_threshold = True self.dynamic_energy_adjustment_damping = 0.15 self.dynamic_energy_ratio = 1.5