BaseOutputTransport: allow setting 10ms output audio chunks

This commit is contained in:
Aleix Conchillo Flaqué
2025-04-01 09:54:16 -07:00
parent 43008c8c5b
commit b40ca391f5
3 changed files with 8 additions and 2 deletions

View File

@@ -79,10 +79,11 @@ class BaseOutputTransport(FrameProcessor):
async def start(self, frame: StartFrame):
self._sample_rate = self._params.audio_out_sample_rate or frame.audio_out_sample_rate
# We will write 20ms audio at a time. If we receive long audio frames we
# We will write 10ms*CHUNKS of audio at a time (where CHUNKS is the
# `audio_out_10ms_chunks` parameter). If we receive long audio frames we
# will chunk them. This will help with interruption handling.
audio_bytes_10ms = int(self._sample_rate / 100) * self._params.audio_out_channels * 2
self._audio_chunk_size = audio_bytes_10ms * 2
self._audio_chunk_size = audio_bytes_10ms * self._params.audio_out_10ms_chunks
# Start audio mixer.
if self._params.audio_out_mixer:

View File

@@ -31,6 +31,7 @@ class TransportParams(BaseModel):
audio_out_sample_rate: Optional[int] = None
audio_out_channels: int = 1
audio_out_bitrate: int = 96000
audio_out_10ms_chunks: int = 2
audio_out_mixer: Optional[BaseAudioMixer] = None
audio_in_enabled: bool = False
audio_in_sample_rate: Optional[int] = None