sarvamai 0.1.8rc3__py3-none-any.whl → 0.1.8rc4__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.
- sarvamai/core/client_wrapper.py +2 -2
- sarvamai/text_to_speech_streaming/socket_client.py +70 -24
- {sarvamai-0.1.8rc3.dist-info → sarvamai-0.1.8rc4.dist-info}/METADATA +1 -1
- {sarvamai-0.1.8rc3.dist-info → sarvamai-0.1.8rc4.dist-info}/RECORD +5 -5
- {sarvamai-0.1.8rc3.dist-info → sarvamai-0.1.8rc4.dist-info}/WHEEL +0 -0
sarvamai/core/client_wrapper.py
CHANGED
|
@@ -17,10 +17,10 @@ class BaseClientWrapper:
|
|
|
17
17
|
|
|
18
18
|
def get_headers(self) -> typing.Dict[str, str]:
|
|
19
19
|
headers: typing.Dict[str, str] = {
|
|
20
|
-
"User-Agent": "sarvamai/0.1.
|
|
20
|
+
"User-Agent": "sarvamai/0.1.8rc4",
|
|
21
21
|
"X-Fern-Language": "Python",
|
|
22
22
|
"X-Fern-SDK-Name": "sarvamai",
|
|
23
|
-
"X-Fern-SDK-Version": "0.1.
|
|
23
|
+
"X-Fern-SDK-Version": "0.1.8rc4",
|
|
24
24
|
}
|
|
25
25
|
headers["api-subscription-key"] = self.api_subscription_key
|
|
26
26
|
return headers
|
|
@@ -11,8 +11,10 @@ from ..types.audio_output import AudioOutput
|
|
|
11
11
|
from ..types.close_connection import CloseConnection
|
|
12
12
|
from ..types.error_response import ErrorResponse
|
|
13
13
|
from ..types.initialize_connection import InitializeConnection
|
|
14
|
+
from ..types.initialize_connection_data import InitializeConnectionData
|
|
14
15
|
from ..types.ping_signal import PingSignal
|
|
15
16
|
from ..types.send_text import SendText
|
|
17
|
+
from ..types.send_text_data import SendTextData
|
|
16
18
|
|
|
17
19
|
TextToSpeechStreamingSocketClientResponse = typing.Union[AudioOutput, ErrorResponse]
|
|
18
20
|
|
|
@@ -24,6 +26,7 @@ class AsyncTextToSpeechStreamingSocketClient(EventEmitterMixin):
|
|
|
24
26
|
|
|
25
27
|
async def __aiter__(self):
|
|
26
28
|
async for message in self._websocket:
|
|
29
|
+
message = json.loads(message) if isinstance(message, str) else message
|
|
27
30
|
yield parse_obj_as(TextToSpeechStreamingSocketClientResponse, message) # type: ignore
|
|
28
31
|
|
|
29
32
|
async def start_listening(self):
|
|
@@ -39,6 +42,11 @@ class AsyncTextToSpeechStreamingSocketClient(EventEmitterMixin):
|
|
|
39
42
|
self._emit(EventType.OPEN, None)
|
|
40
43
|
try:
|
|
41
44
|
async for raw_message in self._websocket:
|
|
45
|
+
raw_message = (
|
|
46
|
+
json.loads(raw_message)
|
|
47
|
+
if isinstance(raw_message, str)
|
|
48
|
+
else raw_message
|
|
49
|
+
)
|
|
42
50
|
parsed = parse_obj_as(TextToSpeechStreamingSocketClientResponse, raw_message) # type: ignore
|
|
43
51
|
self._emit(EventType.MESSAGE, parsed)
|
|
44
52
|
except websockets.WebSocketException as exc:
|
|
@@ -46,32 +54,47 @@ class AsyncTextToSpeechStreamingSocketClient(EventEmitterMixin):
|
|
|
46
54
|
finally:
|
|
47
55
|
self._emit(EventType.CLOSE, None)
|
|
48
56
|
|
|
49
|
-
async def
|
|
57
|
+
async def initialize_connection(
|
|
58
|
+
self,
|
|
59
|
+
target_language_code: str,
|
|
60
|
+
speaker: str,
|
|
61
|
+
) -> None:
|
|
50
62
|
"""
|
|
51
|
-
|
|
52
|
-
|
|
63
|
+
Initialize the TTS connection with configuration parameters.
|
|
64
|
+
|
|
65
|
+
:param target_language_code: Target language code (e.g., 'hi-IN')
|
|
66
|
+
:param speaker: Voice speaker name (e.g., 'meera', 'arvind')
|
|
53
67
|
"""
|
|
68
|
+
data = InitializeConnectionData(
|
|
69
|
+
target_language_code=target_language_code,
|
|
70
|
+
speaker=speaker,
|
|
71
|
+
)
|
|
72
|
+
message = InitializeConnection(data=data)
|
|
54
73
|
await self._send_model(message)
|
|
55
74
|
|
|
56
|
-
async def
|
|
75
|
+
async def convert(self, text: str) -> None:
|
|
57
76
|
"""
|
|
58
|
-
Send
|
|
59
|
-
|
|
77
|
+
Send text to be converted to speech.
|
|
78
|
+
|
|
79
|
+
:param text: Text to be synthesized (1-2500 characters)
|
|
60
80
|
"""
|
|
81
|
+
data = SendTextData(text=text)
|
|
82
|
+
message = SendText(data=data)
|
|
61
83
|
await self._send_model(message)
|
|
62
84
|
|
|
63
|
-
async def
|
|
85
|
+
async def flush(self) -> None:
|
|
64
86
|
"""
|
|
65
|
-
|
|
66
|
-
|
|
87
|
+
Signal to flush the buffer and finalize audio output.
|
|
88
|
+
This indicates the end of text input.
|
|
67
89
|
"""
|
|
90
|
+
message = CloseConnection()
|
|
68
91
|
await self._send_model(message)
|
|
69
92
|
|
|
70
|
-
async def
|
|
93
|
+
async def ping(self) -> None:
|
|
71
94
|
"""
|
|
72
|
-
Send
|
|
73
|
-
The message will be sent as a PingSignal.
|
|
95
|
+
Send ping signal to keep the WebSocket connection alive.
|
|
74
96
|
"""
|
|
97
|
+
message = PingSignal()
|
|
75
98
|
await self._send_model(message)
|
|
76
99
|
|
|
77
100
|
async def recv(self) -> TextToSpeechStreamingSocketClientResponse:
|
|
@@ -79,6 +102,7 @@ class AsyncTextToSpeechStreamingSocketClient(EventEmitterMixin):
|
|
|
79
102
|
Receive a message from the websocket connection.
|
|
80
103
|
"""
|
|
81
104
|
data = await self._websocket.recv()
|
|
105
|
+
data = json.loads(data) if isinstance(data, str) else data
|
|
82
106
|
return parse_obj_as(TextToSpeechStreamingSocketClientResponse, data) # type: ignore
|
|
83
107
|
|
|
84
108
|
async def _send(self, data: typing.Any) -> None:
|
|
@@ -103,6 +127,7 @@ class TextToSpeechStreamingSocketClient(EventEmitterMixin):
|
|
|
103
127
|
|
|
104
128
|
def __iter__(self):
|
|
105
129
|
for message in self._websocket:
|
|
130
|
+
message = json.loads(message) if isinstance(message, str) else message
|
|
106
131
|
yield parse_obj_as(TextToSpeechStreamingSocketClientResponse, message) # type: ignore
|
|
107
132
|
|
|
108
133
|
def start_listening(self):
|
|
@@ -118,6 +143,11 @@ class TextToSpeechStreamingSocketClient(EventEmitterMixin):
|
|
|
118
143
|
self._emit(EventType.OPEN, None)
|
|
119
144
|
try:
|
|
120
145
|
for raw_message in self._websocket:
|
|
146
|
+
raw_message = (
|
|
147
|
+
json.loads(raw_message)
|
|
148
|
+
if isinstance(raw_message, str)
|
|
149
|
+
else raw_message
|
|
150
|
+
)
|
|
121
151
|
parsed = parse_obj_as(TextToSpeechStreamingSocketClientResponse, raw_message) # type: ignore
|
|
122
152
|
self._emit(EventType.MESSAGE, parsed)
|
|
123
153
|
except websockets.WebSocketException as exc:
|
|
@@ -125,32 +155,47 @@ class TextToSpeechStreamingSocketClient(EventEmitterMixin):
|
|
|
125
155
|
finally:
|
|
126
156
|
self._emit(EventType.CLOSE, None)
|
|
127
157
|
|
|
128
|
-
def
|
|
158
|
+
def initialize_connection(
|
|
159
|
+
self,
|
|
160
|
+
target_language_code: str,
|
|
161
|
+
speaker: str,
|
|
162
|
+
) -> None:
|
|
129
163
|
"""
|
|
130
|
-
|
|
131
|
-
|
|
164
|
+
Initialize the TTS connection with configuration parameters.
|
|
165
|
+
|
|
166
|
+
:param target_language_code: Target language code (e.g., 'hi-IN')
|
|
167
|
+
:param speaker: Voice speaker name (e.g., 'meera', 'arvind')
|
|
132
168
|
"""
|
|
169
|
+
data = InitializeConnectionData(
|
|
170
|
+
target_language_code=target_language_code,
|
|
171
|
+
speaker=speaker,
|
|
172
|
+
)
|
|
173
|
+
message = InitializeConnection(data=data)
|
|
133
174
|
self._send_model(message)
|
|
134
175
|
|
|
135
|
-
def
|
|
176
|
+
def convert(self, text: str) -> None:
|
|
136
177
|
"""
|
|
137
|
-
Send
|
|
138
|
-
|
|
178
|
+
Send text to be converted to speech.
|
|
179
|
+
|
|
180
|
+
:param text: Text to be synthesized (1-2500 characters)
|
|
139
181
|
"""
|
|
182
|
+
data = SendTextData(text=text)
|
|
183
|
+
message = SendText(data=data)
|
|
140
184
|
self._send_model(message)
|
|
141
185
|
|
|
142
|
-
def
|
|
186
|
+
def flush(self) -> None:
|
|
143
187
|
"""
|
|
144
|
-
|
|
145
|
-
|
|
188
|
+
Signal to flush the buffer and finalize audio output.
|
|
189
|
+
This indicates the end of text input.
|
|
146
190
|
"""
|
|
191
|
+
message = CloseConnection()
|
|
147
192
|
self._send_model(message)
|
|
148
193
|
|
|
149
|
-
def
|
|
194
|
+
def ping(self) -> None:
|
|
150
195
|
"""
|
|
151
|
-
Send
|
|
152
|
-
The message will be sent as a PingSignal.
|
|
196
|
+
Send ping signal to keep the WebSocket connection alive.
|
|
153
197
|
"""
|
|
198
|
+
message = PingSignal()
|
|
154
199
|
self._send_model(message)
|
|
155
200
|
|
|
156
201
|
def recv(self) -> TextToSpeechStreamingSocketClientResponse:
|
|
@@ -158,6 +203,7 @@ class TextToSpeechStreamingSocketClient(EventEmitterMixin):
|
|
|
158
203
|
Receive a message from the websocket connection.
|
|
159
204
|
"""
|
|
160
205
|
data = self._websocket.recv()
|
|
206
|
+
data = json.loads(data) if isinstance(data, str) else data
|
|
161
207
|
return parse_obj_as(TextToSpeechStreamingSocketClientResponse, data) # type: ignore
|
|
162
208
|
|
|
163
209
|
def _send(self, data: typing.Any) -> None:
|
|
@@ -5,7 +5,7 @@ sarvamai/chat/raw_client.py,sha256=A2kRuZcVWlJhyYCD7YKgqNkZEp3cYa1731KhRkhirU0,1
|
|
|
5
5
|
sarvamai/client.py,sha256=aI1sw5LVGMjgukgZLDlUmA17ecK1yGsQxH-W_JiCrco,7177
|
|
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=
|
|
8
|
+
sarvamai/core/client_wrapper.py,sha256=n37XVBNUAT0tusKUk_VaNpSUmSysyGgwv6sSK9hXikI,2080
|
|
9
9
|
sarvamai/core/datetime_utils.py,sha256=nBys2IsYrhPdszxGKCNRPSOCwa-5DWOHG95FB8G9PKo,1047
|
|
10
10
|
sarvamai/core/events.py,sha256=j7VWXgMpOsjCXdzY22wIhI7Q-v5InZ4WchRzA88x_Sk,856
|
|
11
11
|
sarvamai/core/file.py,sha256=d4NNbX8XvXP32z8KpK2Xovv33nFfruIrpz0QWxlgpZk,2663
|
|
@@ -100,7 +100,7 @@ sarvamai/text_to_speech/raw_client.py,sha256=3Zu6HN_FOY683Vm-EN-OL7YAbLsftjJlFm5
|
|
|
100
100
|
sarvamai/text_to_speech_streaming/__init__.py,sha256=AyHwl9te1mTfiz6IkMU20quN-0RP5njbchknXCz-oK8,173
|
|
101
101
|
sarvamai/text_to_speech_streaming/client.py,sha256=sEC5mVNALldkZri3gHVxHcJCI9TmVwF1vPTL8vfatbY,6161
|
|
102
102
|
sarvamai/text_to_speech_streaming/raw_client.py,sha256=DXsU8Rq27yZGINkRmyeyqPWLlSAGsR1RTJWJH81FlTI,5342
|
|
103
|
-
sarvamai/text_to_speech_streaming/socket_client.py,sha256=
|
|
103
|
+
sarvamai/text_to_speech_streaming/socket_client.py,sha256=rvlRi2wmyUzWdh2jBqrveD6Ck9dXA-IiCAf0ehZIREE,7799
|
|
104
104
|
sarvamai/text_to_speech_streaming/types/__init__.py,sha256=DUsvIGTtST5N1v3Hnodq5aNKfPcTBlod28DSypc8NzA,198
|
|
105
105
|
sarvamai/text_to_speech_streaming/types/text_to_speech_streaming_model.py,sha256=1uOMrJIaAxi_XzwCYmnG5XA-il66cq9uC4ZuiI7HCHo,176
|
|
106
106
|
sarvamai/types/__init__.py,sha256=oCDY6p7Hfd26vLAvluWMrP-qpUd-BJdlVE-KipWXqR8,6332
|
|
@@ -175,6 +175,6 @@ sarvamai/types/transliterate_mode.py,sha256=1jSEMlGcoLkWuk12TgoOpSgwifa4rThGKZ1h
|
|
|
175
175
|
sarvamai/types/transliterate_source_language.py,sha256=bSY9wJszF0sg-Cgg6F-YcWC8ly1mIlj9rqa15-jBtx8,283
|
|
176
176
|
sarvamai/types/transliteration_response.py,sha256=yt-lzTbDeJ_ZL4I8kQa6oESxA9ebeJJY7LfFHpdEsmM,815
|
|
177
177
|
sarvamai/version.py,sha256=Qkp3Ee9YH-O9RTix90e0i7iNrFAGN-QDt2AFwGA4n8k,75
|
|
178
|
-
sarvamai-0.1.
|
|
179
|
-
sarvamai-0.1.
|
|
180
|
-
sarvamai-0.1.
|
|
178
|
+
sarvamai-0.1.8rc4.dist-info/METADATA,sha256=oq7Tpq7QybN8DkNwZe1pYJfxt1cuHCetcQxvCb1CO48,26760
|
|
179
|
+
sarvamai-0.1.8rc4.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
|
|
180
|
+
sarvamai-0.1.8rc4.dist-info/RECORD,,
|
|
File without changes
|