@@ -46,7 +46,7 @@ def __init__(
4646 self ._run_length : int = 0
4747
4848 def __call__ (self , context : SpeechContext , frame : np .ndarray ) -> None :
49- """Processes a single frame of audio to detemine if voice is present
49+ """ Processes a single frame of audio to determine if voice is present
5050
5151 Args:
5252 context (SpeechContext): State based information that needs to be shared
@@ -78,3 +78,30 @@ def reset(self) -> None:
7878 def close (self ) -> None :
7979 """ Close interface for use in pipeline """
8080 self .reset ()
81+
82+
83+ class VoiceActivityTrigger :
84+ """ Voice Activity Detector trigger pipeline component """
85+
86+ def __init__ (self ) -> None :
87+ self ._is_speech = False
88+
89+ def __call__ (self , context : SpeechContext , frame : np .ndarray ) -> None :
90+ """ Activates speech context whenever speech is detected
91+
92+ Args:
93+ context (SpeechContext): State based information that needs to be shared
94+ between pieces of the pipeline
95+ frame (np.ndarray): Single frame of PCM-16 audio from an input source
96+
97+ """
98+ if context .is_speech != self ._is_speech :
99+ if context .is_speech :
100+ context .is_active = True
101+ self ._is_speech = context .is_speech
102+
103+ def close (self ) -> None :
104+ self .reset ()
105+
106+ def reset (self ) -> None :
107+ self ._is_speech = False
0 commit comments