Skip to content

Commit f860eb7

Browse files
author
LittleMouse
committed
[perf] Increase chunk_size and add sending interval
1 parent fe73b13 commit f860eb7

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

backend/asr_client_backend.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ async def create_transcription(self, audio_data: bytes, language: str = "zh", pr
9595
self._active_tasks.add(task)
9696
try:
9797
audio_b64 = base64.b64encode(audio_data).decode('utf-8')
98-
chunk_size = 1024
98+
chunk_size = 4096
9999
audio_chunks = [
100100
audio_b64[i:i + chunk_size] for i in range(0, len(audio_b64), chunk_size)
101101
]
@@ -111,6 +111,7 @@ async def create_transcription(self, audio_data: bytes, language: str = "zh", pr
111111
object_type="asr.base64.stream"
112112
))
113113
transcription += "".join(responses)
114+
await asyncio.sleep(0.002)
114115

115116
return transcription
116117
except asyncio.CancelledError:

0 commit comments

Comments
 (0)