Skip to content

Commit

Permalink
Added support for channel level 'session_id'
Browse files Browse the repository at this point in the history
  • Loading branch information
rtxm committed Mar 14, 2024
1 parent 9bf977c commit cc07786
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
10 changes: 8 additions & 2 deletions examples/recognition/basic_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
18 changes: 15 additions & 3 deletions src/uhlive/stream/recognition/client.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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": "",
}
)
Expand Down

0 comments on commit cc07786

Please sign in to comment.