Creating the silence based on the chunk size.
This commit is contained in:
@@ -202,11 +202,12 @@ class TavusVideoService(AIService):
|
||||
# limit (even including base64 encoding). For a sample rate of 16000,
|
||||
# that would be 32000 / 20 = 1600.
|
||||
sample_rate = self._client.out_sample_rate
|
||||
# 50 ms of audio
|
||||
MAX_CHUNK_SIZE = int((sample_rate * 2) / 20)
|
||||
|
||||
audio_buffer = bytearray()
|
||||
current_idx_str = None
|
||||
silence = b"\x00\x00"
|
||||
silence = b"\x00" * MAX_CHUNK_SIZE
|
||||
samples_sent = 0
|
||||
start_time = None
|
||||
|
||||
|
||||
@@ -405,7 +405,8 @@ class TavusOutputTransport(BaseOutputTransport):
|
||||
self._start_time = time.time()
|
||||
self._samples_sent = 0
|
||||
elif isinstance(frame, BotStoppedSpeakingFrame):
|
||||
await self._client.encode_audio_and_send(b"\x00\x00", True, self._current_idx_str)
|
||||
silence = b"\x00" * self.audio_chunk_size
|
||||
await self._client.encode_audio_and_send(silence, True, self._current_idx_str)
|
||||
self._current_idx_str = None
|
||||
await super().push_frame(frame, direction)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user