diff --git a/examples/recognition/basic_async.py b/examples/recognition/basic_async.py index da4d3bb..c83dace 100644 --- a/examples/recognition/basic_async.py +++ b/examples/recognition/basic_async.py @@ -67,7 +67,7 @@ async def expect(*event_classes): # Scenario - await send(client.open("mytest")) + await send(client.open("mytest", session_id="mysession")) await expect(Opened) # start streaming streamer = asyncio.create_task( @@ -78,7 +78,13 @@ async def expect(*event_classes): ) ) - await send(client.set_params(speech_language="fr", no_input_timeout=5000)) + await send( + client.set_params( + speech_language="fr", + no_input_timeout=5000, + logging_tag="basic_async_test", + ) + ) await expect(ParamsSet) # Recognize address diff --git a/setup.py b/setup.py index 593c250..ac5f327 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setup( name="uhlive", - version="1.3.1", + version="1.4.0", url="https://github.com/uhlive/python-sdk", author="Allo-Media", author_email="support@allo-media.fr", diff --git a/src/uhlive/stream/recognition/client.py b/src/uhlive/stream/recognition/client.py index 4ab1c80..fc7fb80 100644 --- a/src/uhlive/stream/recognition/client.py +++ b/src/uhlive/stream/recognition/client.py @@ -1,6 +1,7 @@ """ Object oriented abstraction over the H2B API protocol and workflow. """ + import json from enum import Enum from typing import Any, Dict, Union @@ -51,15 +52,22 @@ def __init__(self) -> None: # Workflow methods def open( - self, custom_id: str = "", channel_id: str = "", audio_codec: str = "linear" + self, + custom_id: str = "", + channel_id: str = "", + session_id: str = "", + audio_codec: str = "linear", ) -> str: """Open a new H2B session. Args: custom_id: is any reference of yours that you want to appear in the logs - and invoice reports. + and invoice reports; for example your client id. channel_id: when provided, it'll be used as a prefix for the actual channel ID generated by the server. + session_id: you can set an alternate channel identifier to appear along side the channel_id in + the logs and in the Dev Console, to make it easier to reconcile your client logs with + the server logs. audio_codec: the speech audio codec of the audio data: - `"linear"`: (default) linear 16 bit SLE raw PCM audio at 8khz; @@ -79,7 +87,11 @@ def open( "command": "OPEN", "request_id": self.request_id, "channel_id": channel_id, - "headers": {"custom_id": custom_id, "audio_codec": audio_codec}, + "headers": { + "custom_id": custom_id, + "audio_codec": audio_codec, + "session_id": session_id, + }, "body": "", } )