ojin-client 0.1.7.dev5__tar.gz → 0.1.7.dev7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ojin_client-0.1.7.dev5 → ojin_client-0.1.7.dev7}/PKG-INFO +1 -1
- {ojin_client-0.1.7.dev5 → ojin_client-0.1.7.dev7}/ojin/ojin_persona_client.py +10 -17
- {ojin_client-0.1.7.dev5 → ojin_client-0.1.7.dev7}/ojin_client.egg-info/PKG-INFO +1 -1
- {ojin_client-0.1.7.dev5 → ojin_client-0.1.7.dev7}/pyproject.toml +1 -1
- {ojin_client-0.1.7.dev5 → ojin_client-0.1.7.dev7}/README.md +0 -0
- {ojin_client-0.1.7.dev5 → ojin_client-0.1.7.dev7}/ojin/__init__.py +0 -0
- {ojin_client-0.1.7.dev5 → ojin_client-0.1.7.dev7}/ojin/cacert.pem +0 -0
- {ojin_client-0.1.7.dev5 → ojin_client-0.1.7.dev7}/ojin/entities/interaction_messages.py +0 -0
- {ojin_client-0.1.7.dev5 → ojin_client-0.1.7.dev7}/ojin/entities/session_messages.py +0 -0
- {ojin_client-0.1.7.dev5 → ojin_client-0.1.7.dev7}/ojin/ojin_persona_messages.py +0 -0
- {ojin_client-0.1.7.dev5 → ojin_client-0.1.7.dev7}/ojin_client.egg-info/SOURCES.txt +0 -0
- {ojin_client-0.1.7.dev5 → ojin_client-0.1.7.dev7}/ojin_client.egg-info/dependency_links.txt +0 -0
- {ojin_client-0.1.7.dev5 → ojin_client-0.1.7.dev7}/ojin_client.egg-info/requires.txt +0 -0
- {ojin_client-0.1.7.dev5 → ojin_client-0.1.7.dev7}/ojin_client.egg-info/top_level.txt +0 -0
- {ojin_client-0.1.7.dev5 → ojin_client-0.1.7.dev7}/setup.cfg +0 -0
|
@@ -87,10 +87,9 @@ class OjinPersonaClient(IOjinPersonaClient):
|
|
|
87
87
|
self._receive_task: Optional[asyncio.Task] = None
|
|
88
88
|
self._inference_server_ready: bool = False
|
|
89
89
|
self._cancelled: bool = False
|
|
90
|
-
self._cancelled_interaction_id: str | None = None
|
|
91
90
|
self.active_interaction_id: str | None = None
|
|
92
91
|
self._split_audio_task: Optional[asyncio.Task] = None
|
|
93
|
-
self._audio_queue: asyncio.Queue[
|
|
92
|
+
self._audio_queue: asyncio.Queue[OjinPersonaInteractionInputMessage] = asyncio.Queue()
|
|
94
93
|
|
|
95
94
|
async def connect(self) -> None:
|
|
96
95
|
"""Establish WebSocket connection and authenticate with the service."""
|
|
@@ -300,9 +299,7 @@ class OjinPersonaClient(IOjinPersonaClient):
|
|
|
300
299
|
except asyncio.QueueEmpty:
|
|
301
300
|
break
|
|
302
301
|
|
|
303
|
-
|
|
304
302
|
self._cancelled = False
|
|
305
|
-
self._cancelled_interaction_id = message.interaction_id
|
|
306
303
|
|
|
307
304
|
return
|
|
308
305
|
|
|
@@ -326,9 +323,8 @@ class OjinPersonaClient(IOjinPersonaClient):
|
|
|
326
323
|
|
|
327
324
|
if not message.audio_int16_bytes:
|
|
328
325
|
raise ValueError("Audio cannot be empty")
|
|
329
|
-
|
|
330
326
|
|
|
331
|
-
await self._audio_queue.put(message
|
|
327
|
+
await self._audio_queue.put(message)
|
|
332
328
|
# Split audio bytes into chunks of max 3200 samples
|
|
333
329
|
# max_chunk_size = 3200 * 2
|
|
334
330
|
# audio_chunks = [
|
|
@@ -370,22 +366,19 @@ class OjinPersonaClient(IOjinPersonaClient):
|
|
|
370
366
|
|
|
371
367
|
async def _split_audio(self) -> None:
|
|
372
368
|
while True:
|
|
373
|
-
message_audio:
|
|
369
|
+
message_audio: OjinPersonaInteractionInputMessage| None = None
|
|
374
370
|
if self._cancelled:
|
|
375
|
-
|
|
371
|
+
continue
|
|
376
372
|
|
|
377
373
|
try:
|
|
378
374
|
message_audio = self._audio_queue.get_nowait()
|
|
379
375
|
except asyncio.QueueEmpty:
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
if message_audio is None:
|
|
383
|
-
pass
|
|
376
|
+
continue
|
|
384
377
|
|
|
385
378
|
max_chunk_size = 3200 * 2
|
|
386
379
|
audio_chunks = [
|
|
387
|
-
message_audio[i : i + max_chunk_size]
|
|
388
|
-
for i in range(0, len(message_audio), max_chunk_size)
|
|
380
|
+
message_audio.audio_int16_bytes[i : i + max_chunk_size]
|
|
381
|
+
for i in range(0, len(message_audio.audio_int16_bytes), max_chunk_size)
|
|
389
382
|
]
|
|
390
383
|
logger.info(
|
|
391
384
|
"Split audio into %d chunks of max %d bytes",
|
|
@@ -393,15 +386,15 @@ class OjinPersonaClient(IOjinPersonaClient):
|
|
|
393
386
|
)
|
|
394
387
|
|
|
395
388
|
for i, chunk in enumerate(audio_chunks):
|
|
396
|
-
is_last = i == len(audio_chunks) - 1 and
|
|
389
|
+
is_last = i == len(audio_chunks) - 1 and message_audio.is_last_input
|
|
397
390
|
|
|
398
391
|
interaction_input = InteractionInput(
|
|
399
|
-
interaction_id=
|
|
392
|
+
interaction_id=message_audio.interaction_id,
|
|
400
393
|
is_final_input=is_last,
|
|
401
394
|
payload_type="audio",
|
|
402
395
|
payload=chunk,
|
|
403
396
|
timestamp=int(time.monotonic() * 1000),
|
|
404
|
-
params=
|
|
397
|
+
params=message_audio.params if i == 0 else None,
|
|
405
398
|
)
|
|
406
399
|
proxy_message = InteractionInputMessage(payload=interaction_input)
|
|
407
400
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|