From 967e00e89d0cc45f2bbfa8afd2001f30dc87b201 Mon Sep 17 00:00:00 2001 From: chyroc Date: Mon, 3 Mar 2025 15:00:01 +0800 Subject: [PATCH] update --- examples/benchmark_websockets_chat.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/benchmark_websockets_chat.py b/examples/benchmark_websockets_chat.py index 04caf07..6a4e128 100644 --- a/examples/benchmark_websockets_chat.py +++ b/examples/benchmark_websockets_chat.py @@ -3,7 +3,6 @@ import logging import os import time -from time import sleep from typing import List, Optional from cozepy import ( @@ -109,6 +108,7 @@ async def generate_audio(coze: AsyncCoze, text: str) -> List[bytes]: sample_rate=24000, **kwargs, ) + content.write_to_file("test.wav") return [data for data in content._raw_response.iter_bytes(chunk_size=1024)] @@ -141,8 +141,8 @@ async def test_latency(coze: AsyncCoze, bot_id: str, audios: List[bytes]) -> Asy } ) ) - # sleep(len(delta)*1.0/24000/2) # ms - sleep(1.5) + await asyncio.sleep(len(delta) * 1.0 / 24000 / 2) + await client.input_audio_buffer_complete() handler.input_audio_buffer_completed_at = int(time.time() * 1000) await client.wait( @@ -166,6 +166,8 @@ async def main(): # Initialize Audio audios = await generate_audio(coze, text) + exit(0) + times = 50 text_latency = [] audio_latency = []