Forráskód Böngészése

Added new callbacks

Kolja Beigel 1 éve
szülő
commit
fd74fa53f5
2 módosított fájl, 6 hozzáadás és 0 törlés
  1. 4 0
      README.md
  2. 2 0
      RealtimeSTT/audio_recorder.py

+ 4 - 0
README.md

@@ -185,6 +185,10 @@ When you initialize the `AudioToTextRecorder` class, you have various options to
 
 - **pre_recording_buffer_duration** (float, default=0.2): The time span, in seconds, during which audio is buffered prior to formal recording. This helps counterbalancing the latency inherent in speech activity detection, ensuring no initial audio is missed.
 
+- **on_vad_detect_start**: A callable function triggered when the system starts to listen for voice activity.
+
+- **on_vad_detect_stop**: A callable function triggered when the system stops to listen for voice activity.
+
 #### Wake Word Parameters
 
 - **wake_words** (str, default=""): Wake words for initiating the recording. Multiple wake words can be provided as a comma-separated string. Supported wake words are: alexa, americano, blueberry, bumblebee, computer, grapefruits, grasshopper, hey google, hey siri, jarvis, ok google, picovoice, porcupine, terminator

+ 2 - 0
RealtimeSTT/audio_recorder.py

@@ -96,6 +96,8 @@ class AudioToTextRecorder:
         - min_gap_between_recordings (float, default=1.0): Specifies the minimum time interval in seconds that should exist between the end of one recording session and the beginning of another to prevent rapid consecutive recordings.
         - min_length_of_recording (float, default=1.0): Specifies the minimum duration in seconds that a recording session should last to ensure meaningful audio capture, preventing excessively short or fragmented recordings.
         - pre_recording_buffer_duration (float, default=0.2): Duration in seconds for the audio buffer to maintain pre-roll audio (compensates speech activity detection latency)
+        - on_vad_detect_start (callable, default=None): Callback function to be called when the system listens for voice activity.
+        - on_vad_detect_stop (callable, default=None): Callback function to be called when the system stops listening for voice activity.
         - wake_words (str, default=""): Comma-separated string of wake words to initiate recording. Supported wake words include:
                 'alexa', 'americano', 'blueberry', 'bumblebee', 'computer', 'grapefruits', 'grasshopper', 'hey google', 'hey siri', 'jarvis', 'ok google', 'picovoice', 'porcupine', 'terminator'.
         - wake_words_sensitivity (float, default=0.5): Sensitivity for wake word detection, ranging from 0 (least sensitive) to 1 (most sensitive). Default is 0.5.