Skip to content

Commit

Permalink
Using single method to process the frames and making the variables pr…
Browse files Browse the repository at this point in the history
…ivate.
  • Loading branch information
filipi87 committed Nov 5, 2024
1 parent af86750 commit 43e4847
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/pipecat/audio/filters/krisp_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@ def __init__(
self._channels = channels
self._sample_rate = 0
self._filtering = True
self.krisp_processor = None
self._krisp_processor = None

async def start(self, sample_rate: int):
self._sample_rate = sample_rate
self.krisp_processor = KrispAudioProcessor(
self._krisp_processor = KrispAudioProcessor(
self._sample_rate, self._sample_type, self._channels, self._model_path
)

async def stop(self):
self.krisp_processor = None
self._krisp_processor = None
pass

async def process_frame(self, frame: FilterControlFrame):
Expand All @@ -75,8 +75,7 @@ async def filter(self, audio: bytes) -> bytes:
data = data.astype(np.float32) + epsilon

# Process the audio chunk to reduce noise
self.krisp_processor.store_audio_chunk(data)
reduced_noise = self.krisp_processor.get_processed_frames()
reduced_noise = self._krisp_processor.process(data)

# Clip and set processed audio back to frame
audio = np.clip(reduced_noise, -32768, 32767).astype(np.int16).tobytes()
Expand Down

0 comments on commit 43e4847

Please sign in to comment.