introduce audio resamplers

This commit is contained in:
Aleix Conchillo Flaqué
2025-01-31 11:04:18 -08:00
parent 6c7474e1a2
commit fc89aad469
14 changed files with 173 additions and 31 deletions

View File

@@ -11,7 +11,7 @@ from typing import Any, Awaitable, Callable, List, Optional
from loguru import logger
from pydantic import BaseModel
from pipecat.audio.utils import resample_audio
from pipecat.audio.utils import create_default_resampler
from pipecat.audio.vad.vad_analyzer import VADAnalyzer
from pipecat.frames.frames import (
AudioRawFrame,
@@ -349,6 +349,7 @@ class LiveKitInputTransport(BaseInputTransport):
self._client = client
self._audio_in_task = None
self._vad_analyzer: VADAnalyzer | None = params.vad_analyzer
self._resampler = create_default_resampler()
async def start(self, frame: StartFrame):
await super().start(frame)
@@ -397,7 +398,7 @@ class LiveKitInputTransport(BaseInputTransport):
) -> AudioRawFrame:
audio_frame = audio_frame_event.frame
audio_data = resample_audio(
audio_data = self._resampler.resample(
audio_frame.data.tobytes(), audio_frame.sample_rate, self._params.audio_in_sample_rate
)