Skip to content

Commit a0c52ca

Browse files
YiminWwangyoucao577
authored andcommitted
feat: add timestamp set in send_tts_audio for align words with audio
1 parent 117daf0 commit a0c52ca

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

interface/ten_ai_base/tts2.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ async def _process_input_queue(self, ten_env: AsyncTenEnv) -> None:
160160

161161

162162
async def send_tts_audio_data(
163-
self, audio_data: bytes
163+
self, audio_data: bytes, timestamp: int
164164
) -> None:
165165
"""End sending audio out."""
166166
try:
@@ -195,9 +195,11 @@ async def send_tts_audio_data(
195195
// (bytes_per_sample * number_of_channels)
196196
)
197197
f.alloc_buf(len(combined_data))
198+
f.set_timestamp(timestamp)
198199
buff = f.lock_buf()
199200
buff[:] = combined_data
200201
f.unlock_buf(buff)
202+
self.ten_env.log_debug(f"send audio frame, timestamp: {timestamp}, length: {len(combined_data)}")
201203
await self.ten_env.send_audio_frame(f)
202204
except Exception as e:
203205
self.ten_env.log_error(

0 commit comments

Comments
 (0)