sarvamai 0.1.11a6__py3-none-any.whl → 0.1.12__py3-none-any.whl

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.
@@ -23,10 +23,10 @@ class BaseClientWrapper:
23
23
 
24
24
  def get_headers(self) -> typing.Dict[str, str]:
25
25
  headers: typing.Dict[str, str] = {
26
- "User-Agent": "sarvamai/0.1.11a6",
26
+ "User-Agent": "sarvamai/0.1.12",
27
27
  "X-Fern-Language": "Python",
28
28
  "X-Fern-SDK-Name": "sarvamai",
29
- "X-Fern-SDK-Version": "0.1.11a6",
29
+ "X-Fern-SDK-Version": "0.1.12",
30
30
  **(self.get_custom_headers() or {}),
31
31
  }
32
32
  headers["api-subscription-key"] = self.api_subscription_key
sarvamai/core/events.py CHANGED
@@ -1,5 +1,6 @@
1
1
  # This file was auto-generated by Fern from our API Definition.
2
2
 
3
+ import inspect
3
4
  import typing
4
5
  from enum import Enum
5
6
 
@@ -19,7 +20,7 @@ class EventEmitterMixin:
19
20
  def __init__(self) -> None:
20
21
  self._callbacks: typing.Dict[EventType, typing.List[typing.Callable]] = {}
21
22
 
22
- def on(self, event_name: EventType, callback: typing.Callable[[typing.Any], None]) -> None:
23
+ def on(self, event_name: EventType, callback: typing.Callable[[typing.Any], typing.Any]) -> None:
23
24
  if event_name not in self._callbacks:
24
25
  self._callbacks[event_name] = []
25
26
  self._callbacks[event_name].append(callback)
@@ -28,3 +29,10 @@ class EventEmitterMixin:
28
29
  if event_name in self._callbacks:
29
30
  for cb in self._callbacks[event_name]:
30
31
  cb(data)
32
+
33
+ async def _emit_async(self, event_name: EventType, data: typing.Any) -> None:
34
+ if event_name in self._callbacks:
35
+ for cb in self._callbacks[event_name]:
36
+ res = cb(data)
37
+ if inspect.isawaitable(res):
38
+ await res
@@ -4,7 +4,7 @@ import typing
4
4
  from contextlib import asynccontextmanager, contextmanager
5
5
 
6
6
  import httpx
7
- import websockets
7
+ import websockets.exceptions
8
8
  import websockets.sync.client as websockets_sync_client
9
9
  from ..core.api_error import ApiError
10
10
  from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
@@ -16,6 +16,11 @@ from .types.speech_to_text_streaming_language_code import SpeechToTextStreamingL
16
16
  from .types.speech_to_text_streaming_model import SpeechToTextStreamingModel
17
17
  from .types.speech_to_text_streaming_vad_signals import SpeechToTextStreamingVadSignals
18
18
 
19
+ try:
20
+ from websockets.legacy.client import connect as websockets_client_connect # type: ignore
21
+ except ImportError:
22
+ from websockets import connect as websockets_client_connect # type: ignore
23
+
19
24
 
20
25
  class SpeechToTextStreamingClient:
21
26
  def __init__(self, *, client_wrapper: SyncClientWrapper):
@@ -174,7 +179,7 @@ class AsyncSpeechToTextStreamingClient:
174
179
  if request_options and "additional_headers" in request_options:
175
180
  headers.update(request_options["additional_headers"])
176
181
  try:
177
- async with websockets.connect(ws_url, extra_headers=headers) as protocol:
182
+ async with websockets_client_connect(ws_url, extra_headers=headers) as protocol:
178
183
  yield AsyncSpeechToTextStreamingSocketClient(websocket=protocol)
179
184
  except websockets.exceptions.InvalidStatusCode as exc:
180
185
  status_code: int = exc.status_code
@@ -4,7 +4,7 @@ import typing
4
4
  from contextlib import asynccontextmanager, contextmanager
5
5
 
6
6
  import httpx
7
- import websockets
7
+ import websockets.exceptions
8
8
  import websockets.sync.client as websockets_sync_client
9
9
  from ..core.api_error import ApiError
10
10
  from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
@@ -15,6 +15,11 @@ from .types.speech_to_text_streaming_language_code import SpeechToTextStreamingL
15
15
  from .types.speech_to_text_streaming_model import SpeechToTextStreamingModel
16
16
  from .types.speech_to_text_streaming_vad_signals import SpeechToTextStreamingVadSignals
17
17
 
18
+ try:
19
+ from websockets.legacy.client import connect as websockets_client_connect # type: ignore
20
+ except ImportError:
21
+ from websockets import connect as websockets_client_connect # type: ignore
22
+
18
23
 
19
24
  class RawSpeechToTextStreamingClient:
20
25
  def __init__(self, *, client_wrapper: SyncClientWrapper):
@@ -151,7 +156,7 @@ class AsyncRawSpeechToTextStreamingClient:
151
156
  if request_options and "additional_headers" in request_options:
152
157
  headers.update(request_options["additional_headers"])
153
158
  try:
154
- async with websockets.connect(ws_url, extra_headers=headers) as protocol:
159
+ async with websockets_client_connect(ws_url, extra_headers=headers) as protocol:
155
160
  yield AsyncSpeechToTextStreamingSocketClient(websocket=protocol)
156
161
  except websockets.exceptions.InvalidStatusCode as exc:
157
162
  status_code: int = exc.status_code
@@ -4,7 +4,7 @@ import typing
4
4
  from contextlib import asynccontextmanager, contextmanager
5
5
 
6
6
  import httpx
7
- import websockets
7
+ import websockets.exceptions
8
8
  import websockets.sync.client as websockets_sync_client
9
9
  from ..core.api_error import ApiError
10
10
  from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
@@ -17,6 +17,11 @@ from .types.speech_to_text_translate_streaming_high_vad_sensitivity import (
17
17
  from .types.speech_to_text_translate_streaming_model import SpeechToTextTranslateStreamingModel
18
18
  from .types.speech_to_text_translate_streaming_vad_signals import SpeechToTextTranslateStreamingVadSignals
19
19
 
20
+ try:
21
+ from websockets.legacy.client import connect as websockets_client_connect # type: ignore
22
+ except ImportError:
23
+ from websockets import connect as websockets_client_connect # type: ignore
24
+
20
25
 
21
26
  class SpeechToTextTranslateStreamingClient:
22
27
  def __init__(self, *, client_wrapper: SyncClientWrapper):
@@ -163,7 +168,7 @@ class AsyncSpeechToTextTranslateStreamingClient:
163
168
  if request_options and "additional_headers" in request_options:
164
169
  headers.update(request_options["additional_headers"])
165
170
  try:
166
- async with websockets.connect(ws_url, extra_headers=headers) as protocol:
171
+ async with websockets_client_connect(ws_url, extra_headers=headers) as protocol:
167
172
  yield AsyncSpeechToTextTranslateStreamingSocketClient(websocket=protocol)
168
173
  except websockets.exceptions.InvalidStatusCode as exc:
169
174
  status_code: int = exc.status_code
@@ -4,7 +4,7 @@ import typing
4
4
  from contextlib import asynccontextmanager, contextmanager
5
5
 
6
6
  import httpx
7
- import websockets
7
+ import websockets.exceptions
8
8
  import websockets.sync.client as websockets_sync_client
9
9
  from ..core.api_error import ApiError
10
10
  from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
@@ -16,6 +16,11 @@ from .types.speech_to_text_translate_streaming_high_vad_sensitivity import (
16
16
  from .types.speech_to_text_translate_streaming_model import SpeechToTextTranslateStreamingModel
17
17
  from .types.speech_to_text_translate_streaming_vad_signals import SpeechToTextTranslateStreamingVadSignals
18
18
 
19
+ try:
20
+ from websockets.legacy.client import connect as websockets_client_connect # type: ignore
21
+ except ImportError:
22
+ from websockets import connect as websockets_client_connect # type: ignore
23
+
19
24
 
20
25
  class RawSpeechToTextTranslateStreamingClient:
21
26
  def __init__(self, *, client_wrapper: SyncClientWrapper):
@@ -140,7 +145,7 @@ class AsyncRawSpeechToTextTranslateStreamingClient:
140
145
  if request_options and "additional_headers" in request_options:
141
146
  headers.update(request_options["additional_headers"])
142
147
  try:
143
- async with websockets.connect(ws_url, extra_headers=headers) as protocol:
148
+ async with websockets_client_connect(ws_url, extra_headers=headers) as protocol:
144
149
  yield AsyncSpeechToTextTranslateStreamingSocketClient(websocket=protocol)
145
150
  except websockets.exceptions.InvalidStatusCode as exc:
146
151
  status_code: int = exc.status_code
@@ -4,7 +4,7 @@ import typing
4
4
  from contextlib import asynccontextmanager, contextmanager
5
5
 
6
6
  import httpx
7
- import websockets
7
+ import websockets.exceptions
8
8
  import websockets.sync.client as websockets_sync_client
9
9
  from ..core.api_error import ApiError
10
10
  from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
@@ -12,6 +12,11 @@ from ..core.request_options import RequestOptions
12
12
  from .raw_client import AsyncRawTextToSpeechStreamingClient, RawTextToSpeechStreamingClient
13
13
  from .socket_client import AsyncTextToSpeechStreamingSocketClient, TextToSpeechStreamingSocketClient
14
14
 
15
+ try:
16
+ from websockets.legacy.client import connect as websockets_client_connect # type: ignore
17
+ except ImportError:
18
+ from websockets import connect as websockets_client_connect # type: ignore
19
+
15
20
 
16
21
  class TextToSpeechStreamingClient:
17
22
  def __init__(self, *, client_wrapper: SyncClientWrapper):
@@ -136,7 +141,7 @@ class AsyncTextToSpeechStreamingClient:
136
141
  if request_options and "additional_headers" in request_options:
137
142
  headers.update(request_options["additional_headers"])
138
143
  try:
139
- async with websockets.connect(ws_url, extra_headers=headers) as protocol:
144
+ async with websockets_client_connect(ws_url, extra_headers=headers) as protocol:
140
145
  yield AsyncTextToSpeechStreamingSocketClient(websocket=protocol)
141
146
  except websockets.exceptions.InvalidStatusCode as exc:
142
147
  status_code: int = exc.status_code
@@ -4,13 +4,18 @@ import typing
4
4
  from contextlib import asynccontextmanager, contextmanager
5
5
 
6
6
  import httpx
7
- import websockets
7
+ import websockets.exceptions
8
8
  import websockets.sync.client as websockets_sync_client
9
9
  from ..core.api_error import ApiError
10
10
  from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
11
11
  from ..core.request_options import RequestOptions
12
12
  from .socket_client import AsyncTextToSpeechStreamingSocketClient, TextToSpeechStreamingSocketClient
13
13
 
14
+ try:
15
+ from websockets.legacy.client import connect as websockets_client_connect # type: ignore
16
+ except ImportError:
17
+ from websockets import connect as websockets_client_connect # type: ignore
18
+
14
19
 
15
20
  class RawTextToSpeechStreamingClient:
16
21
  def __init__(self, *, client_wrapper: SyncClientWrapper):
@@ -113,7 +118,7 @@ class AsyncRawTextToSpeechStreamingClient:
113
118
  if request_options and "additional_headers" in request_options:
114
119
  headers.update(request_options["additional_headers"])
115
120
  try:
116
- async with websockets.connect(ws_url, extra_headers=headers) as protocol:
121
+ async with websockets_client_connect(ws_url, extra_headers=headers) as protocol:
117
122
  yield AsyncTextToSpeechStreamingSocketClient(websocket=protocol)
118
123
  except websockets.exceptions.InvalidStatusCode as exc:
119
124
  status_code: int = exc.status_code
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sarvamai
3
- Version: 0.1.11a6
3
+ Version: 0.1.12
4
4
  Summary:
5
5
  Requires-Python: >=3.8,<4.0
6
6
  Classifier: Intended Audience :: Developers
@@ -5,9 +5,9 @@ sarvamai/chat/raw_client.py,sha256=A2kRuZcVWlJhyYCD7YKgqNkZEp3cYa1731KhRkhirU0,1
5
5
  sarvamai/client.py,sha256=J30X_os1lPf8Wml0KDFEf6p8VGHhgF_lf3nw1T2D3qo,8207
6
6
  sarvamai/core/__init__.py,sha256=YE2CtXeASe1RAbaI39twKWYKCuT4tW5is9HWHhJjR_g,1653
7
7
  sarvamai/core/api_error.py,sha256=44vPoTyWN59gonCIZMdzw7M1uspygiLnr3GNFOoVL2Q,614
8
- sarvamai/core/client_wrapper.py,sha256=9BO6RRCqqNgboZxlWPn6OwocQvhQ2evHMjNUHvTEHZ4,2570
8
+ sarvamai/core/client_wrapper.py,sha256=BchIfnj5QNZg85eRe4xIj3ebOrnptC01IM14XeZ7So4,2566
9
9
  sarvamai/core/datetime_utils.py,sha256=nBys2IsYrhPdszxGKCNRPSOCwa-5DWOHG95FB8G9PKo,1047
10
- sarvamai/core/events.py,sha256=j7VWXgMpOsjCXdzY22wIhI7Q-v5InZ4WchRzA88x_Sk,856
10
+ sarvamai/core/events.py,sha256=HvKBdSoYcFetk7cgNXb7FxuY-FtY8NtUhZIN7mGVx8U,1159
11
11
  sarvamai/core/file.py,sha256=d4NNbX8XvXP32z8KpK2Xovv33nFfruIrpz0QWxlgpZk,2663
12
12
  sarvamai/core/force_multipart.py,sha256=awxh5MtcRYe74ehY8U76jzv6fYM_w_D3Rur7KQQzSDk,429
13
13
  sarvamai/core/http_client.py,sha256=QurkBvCZZz2Z1d8znp4M2YbOXebBUPcPXRhPIS84Wvk,21214
@@ -91,8 +91,8 @@ sarvamai/speech_to_text_job/client.py,sha256=v_q-fKp7Gz5izywtyIsjYE0CfJGa51k8sRB
91
91
  sarvamai/speech_to_text_job/job.py,sha256=LD47DCehRg5vHF8mc9C-gcVPiXRE-vpVMT8gGlrzK04,13923
92
92
  sarvamai/speech_to_text_job/raw_client.py,sha256=v14drcQLAmpqozRUNKmw1F9j3omieMPC8R88Th1BID8,48055
93
93
  sarvamai/speech_to_text_streaming/__init__.py,sha256=q7QygMmZCHJ-4FMhhL_6XNV_dsqlIFRCO1iSxoyxaaY,437
94
- sarvamai/speech_to_text_streaming/client.py,sha256=WdkzZxKMdnQ2hHv9hzJlfSNggRJLKFljRiC7695Jcog,8224
95
- sarvamai/speech_to_text_streaming/raw_client.py,sha256=7zcgVw7CXA2TySkJKQkS-NdnJOMRudmV_m4NaigICN0,7405
94
+ sarvamai/speech_to_text_streaming/client.py,sha256=AzStfZDXhu2YAJEpnVbsy0WObub5ctlGBzqfeYOUlpA,8442
95
+ sarvamai/speech_to_text_streaming/raw_client.py,sha256=UrSRTR6NtB6SU0Ta8U2ER-PxBP1sDWL857l2LIaTxiU,7623
96
96
  sarvamai/speech_to_text_streaming/socket_client.py,sha256=QI0vEjDvNTG9-EH99NolIuARYwD-P8Fms8rqKOD9HJQ,6419
97
97
  sarvamai/speech_to_text_streaming/types/__init__.py,sha256=hzEDbcyy6K0Q9-Zx5k5lxAHxIgeHnAoPpvTLrL13YT0,599
98
98
  sarvamai/speech_to_text_streaming/types/speech_to_text_streaming_high_vad_sensitivity.py,sha256=OwPwffa8TkLPGMnOTn5S7d-HmV8QmN3B7fHz8I1-VT8,180
@@ -104,8 +104,8 @@ sarvamai/speech_to_text_translate_job/client.py,sha256=UmM9yACznkasSGodp1rNoi4An
104
104
  sarvamai/speech_to_text_translate_job/job.py,sha256=-DRzK4ZI3Jupf4H3GUX1ShIqDSTxGb59lIYGY9cQa7U,14109
105
105
  sarvamai/speech_to_text_translate_job/raw_client.py,sha256=g-xk7H8ZwjmPSuJSgblVSH7kqGh_5wAkYUy5PdwTm-U,49362
106
106
  sarvamai/speech_to_text_translate_streaming/__init__.py,sha256=_hmlce1Zs1grylysZhBUdtKfkaUROwVydtwz6l-1qqg,411
107
- sarvamai/speech_to_text_translate_streaming/client.py,sha256=TnHCcspbbYFaimcEk8km3QNrNkm8JlX7e2ydpeHL9EE,8068
108
- sarvamai/speech_to_text_translate_streaming/raw_client.py,sha256=_TlUro1NwWc1dAvC0SHcOoTnsnAqRRXxzxKHxw8BGTs,7177
107
+ sarvamai/speech_to_text_translate_streaming/client.py,sha256=xPPg5_JgpH8tYDUte6FGtpzXO2LGBUSRADN-ICqqA6U,8286
108
+ sarvamai/speech_to_text_translate_streaming/raw_client.py,sha256=WUj5dGWQT2HUYLFoi3SRJzXk1JMuLxhPQzbL45G5kO8,7395
109
109
  sarvamai/speech_to_text_translate_streaming/socket_client.py,sha256=Xy86G9Mv1kGLf8xwFo3OBf98vqGQ50iigUAoOaApLdI,7842
110
110
  sarvamai/speech_to_text_translate_streaming/types/__init__.py,sha256=zyKoGAbKW4d0-Zi56F0RfPUqtk_xUjWjF_RjTxbXXW4,556
111
111
  sarvamai/speech_to_text_translate_streaming/types/speech_to_text_translate_streaming_high_vad_sensitivity.py,sha256=r6MvTlkM0VEpb4dpnMHtINOZ-gYc22o0Fx_Xce2rjvo,189
@@ -118,8 +118,8 @@ sarvamai/text_to_speech/__init__.py,sha256=_VhToAyIt_5axN6CLJwtxg3-CO7THa_23pbUz
118
118
  sarvamai/text_to_speech/client.py,sha256=iwrQNfoMgCSOgvztTIXtLHQmSmn0RInwt5RSo9TwdtA,9617
119
119
  sarvamai/text_to_speech/raw_client.py,sha256=si_aSjMR7SocIpKZFoVYqBmaIDuRm_6vxTM0dJ73PEo,15569
120
120
  sarvamai/text_to_speech_streaming/__init__.py,sha256=_VhToAyIt_5axN6CLJwtxg3-CO7THa_23pbUzqhXJa4,85
121
- sarvamai/text_to_speech_streaming/client.py,sha256=geTF5xy-batzO12XVt0sPw_XJCi7-m2sDFK_B7SL7qc,6088
122
- sarvamai/text_to_speech_streaming/raw_client.py,sha256=asOcNw1WAViOiXDVWH4sxWSXGVoLwAOh9vUtq_xralA,5269
121
+ sarvamai/text_to_speech_streaming/client.py,sha256=tcYTUmWGseGQkLOsJdO4S3eZrFstjaLCPi5OcKflfus,6306
122
+ sarvamai/text_to_speech_streaming/raw_client.py,sha256=VdL5HYpUotIm5HaOqTwRkyZqoV0BuzwCtAfcB0g1y10,5487
123
123
  sarvamai/text_to_speech_streaming/socket_client.py,sha256=NEcijnvjuNcWfzqpBi-xWsXVkL0NPq6EGAkEjnaq9hw,13909
124
124
  sarvamai/types/__init__.py,sha256=_tcONO157t6xm41llByU9FzSYWCQO2gExsqKZOz0HpQ,7681
125
125
  sarvamai/types/audio_data.py,sha256=rgOukLkLNJ_HBBVE2g5dfEL2CWjRoGiMvCtpq0qTB1Y,829
@@ -209,6 +209,6 @@ sarvamai/types/transliterate_mode.py,sha256=1jSEMlGcoLkWuk12TgoOpSgwifa4rThGKZ1h
209
209
  sarvamai/types/transliterate_source_language.py,sha256=bSY9wJszF0sg-Cgg6F-YcWC8ly1mIlj9rqa15-jBtx8,283
210
210
  sarvamai/types/transliteration_response.py,sha256=yt-lzTbDeJ_ZL4I8kQa6oESxA9ebeJJY7LfFHpdEsmM,815
211
211
  sarvamai/version.py,sha256=Qkp3Ee9YH-O9RTix90e0i7iNrFAGN-QDt2AFwGA4n8k,75
212
- sarvamai-0.1.11a6.dist-info/METADATA,sha256=6TFC9iLDM-98sDrDfALNDyqwEbBVv0dnJQXNBbmZ-ro,26753
213
- sarvamai-0.1.11a6.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
214
- sarvamai-0.1.11a6.dist-info/RECORD,,
212
+ sarvamai-0.1.12.dist-info/METADATA,sha256=THBES5M2uAlXlYgWG9gOVgyQAqY0KGjIPlVkRJM_2zE,26751
213
+ sarvamai-0.1.12.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
214
+ sarvamai-0.1.12.dist-info/RECORD,,