sarvamai 0.1.5a6__py3-none-any.whl → 0.1.5a7__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/__init__.py +45 -1
- sarvamai/chat/__init__.py +2 -0
- sarvamai/chat/client.py +9 -10
- sarvamai/chat/raw_client.py +48 -37
- sarvamai/client.py +13 -31
- sarvamai/core/__init__.py +5 -0
- sarvamai/core/api_error.py +13 -5
- sarvamai/core/client_wrapper.py +17 -20
- sarvamai/core/events.py +30 -0
- sarvamai/core/force_multipart.py +16 -0
- sarvamai/core/http_client.py +70 -24
- sarvamai/core/http_response.py +19 -11
- sarvamai/core/pydantic_utilities.py +69 -108
- sarvamai/environment.py +10 -3
- sarvamai/errors/__init__.py +2 -0
- sarvamai/errors/bad_request_error.py +4 -3
- sarvamai/errors/forbidden_error.py +4 -3
- sarvamai/errors/internal_server_error.py +4 -3
- sarvamai/errors/service_unavailable_error.py +4 -2
- sarvamai/errors/too_many_requests_error.py +4 -3
- sarvamai/errors/unprocessable_entity_error.py +4 -3
- sarvamai/requests/__init__.py +18 -0
- sarvamai/requests/audio_data.py +21 -0
- sarvamai/requests/audio_message.py +8 -0
- sarvamai/requests/chat_completion_request_message.py +3 -1
- sarvamai/requests/create_chat_completion_response.py +2 -2
- sarvamai/requests/diarized_transcript.py +2 -1
- sarvamai/requests/error_data.py +15 -0
- sarvamai/requests/error_details.py +0 -1
- sarvamai/requests/events_data.py +17 -0
- sarvamai/requests/language_identification_response.py +0 -1
- sarvamai/requests/speech_to_text_response.py +1 -2
- sarvamai/requests/speech_to_text_streaming_response.py +10 -0
- sarvamai/requests/speech_to_text_streaming_response_data.py +9 -0
- sarvamai/requests/speech_to_text_translate_response.py +0 -1
- sarvamai/requests/text_to_speech_response.py +2 -2
- sarvamai/requests/timestamps_model.py +2 -1
- sarvamai/requests/transcription_data.py +35 -0
- sarvamai/requests/transcription_metrics.py +15 -0
- sarvamai/requests/translation_response.py +0 -1
- sarvamai/requests/transliteration_response.py +0 -1
- sarvamai/speech_to_text/__init__.py +2 -0
- sarvamai/speech_to_text/client.py +13 -14
- sarvamai/speech_to_text/raw_client.py +99 -68
- sarvamai/speech_to_text_streaming/__init__.py +7 -0
- sarvamai/speech_to_text_streaming/client.py +189 -0
- sarvamai/speech_to_text_streaming/raw_client.py +166 -0
- sarvamai/speech_to_text_streaming/socket_client.py +129 -0
- sarvamai/speech_to_text_streaming/types/__init__.py +8 -0
- sarvamai/speech_to_text_streaming/types/speech_to_text_streaming_language_code.py +8 -0
- sarvamai/speech_to_text_streaming/types/speech_to_text_streaming_model.py +5 -0
- sarvamai/text/__init__.py +2 -0
- sarvamai/text/client.py +24 -25
- sarvamai/text/raw_client.py +126 -91
- sarvamai/text_to_speech/__init__.py +2 -0
- sarvamai/text_to_speech/client.py +10 -11
- sarvamai/text_to_speech/raw_client.py +49 -38
- sarvamai/types/__init__.py +24 -0
- sarvamai/types/audio_data.py +33 -0
- sarvamai/types/audio_data_encoding.py +5 -0
- sarvamai/types/audio_message.py +20 -0
- sarvamai/types/chat_completion_request_assistant_message.py +3 -3
- sarvamai/types/chat_completion_request_message.py +3 -2
- sarvamai/types/chat_completion_request_system_message.py +3 -3
- sarvamai/types/chat_completion_request_user_message.py +3 -3
- sarvamai/types/chat_completion_response_message.py +3 -3
- sarvamai/types/choice.py +4 -4
- sarvamai/types/completion_usage.py +3 -3
- sarvamai/types/create_chat_completion_response.py +3 -3
- sarvamai/types/diarized_entry.py +3 -3
- sarvamai/types/diarized_transcript.py +3 -3
- sarvamai/types/error_data.py +27 -0
- sarvamai/types/error_details.py +3 -3
- sarvamai/types/error_message.py +4 -4
- sarvamai/types/events_data.py +28 -0
- sarvamai/types/format.py +5 -0
- sarvamai/types/language_identification_response.py +2 -2
- sarvamai/types/speech_to_text_response.py +3 -3
- sarvamai/types/speech_to_text_streaming_response.py +22 -0
- sarvamai/types/speech_to_text_streaming_response_data.py +9 -0
- sarvamai/types/speech_to_text_streaming_response_type.py +5 -0
- sarvamai/types/speech_to_text_translate_response.py +3 -3
- sarvamai/types/text_to_speech_response.py +2 -2
- sarvamai/types/timestamps_model.py +2 -2
- sarvamai/types/transcription_data.py +45 -0
- sarvamai/types/transcription_metrics.py +27 -0
- sarvamai/types/translation_response.py +2 -2
- sarvamai/types/transliteration_response.py +2 -2
- sarvamai-0.1.5a7.dist-info/METADATA +28 -0
- sarvamai-0.1.5a7.dist-info/RECORD +134 -0
- sarvamai-0.1.5a6.dist-info/METADATA +0 -174
- sarvamai-0.1.5a6.dist-info/RECORD +0 -106
- {sarvamai-0.1.5a6.dist-info → sarvamai-0.1.5a7.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
from contextlib import asynccontextmanager, contextmanager
|
|
5
|
+
|
|
6
|
+
import httpx
|
|
7
|
+
import websockets
|
|
8
|
+
import websockets.sync.client as websockets_sync_client
|
|
9
|
+
from ..core.api_error import ApiError
|
|
10
|
+
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
11
|
+
from ..core.request_options import RequestOptions
|
|
12
|
+
from .socket_client import AsyncSpeechToTextStreamingSocketClient, SpeechToTextStreamingSocketClient
|
|
13
|
+
from .types.speech_to_text_streaming_language_code import SpeechToTextStreamingLanguageCode
|
|
14
|
+
from .types.speech_to_text_streaming_model import SpeechToTextStreamingModel
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class RawSpeechToTextStreamingClient:
|
|
18
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
19
|
+
self._client_wrapper = client_wrapper
|
|
20
|
+
|
|
21
|
+
@contextmanager
|
|
22
|
+
def connect(
|
|
23
|
+
self,
|
|
24
|
+
*,
|
|
25
|
+
language_code: SpeechToTextStreamingLanguageCode,
|
|
26
|
+
model: SpeechToTextStreamingModel,
|
|
27
|
+
high_vad_sensitivity: typing.Optional[str] = None,
|
|
28
|
+
vad_signals: typing.Optional[str] = None,
|
|
29
|
+
api_subscription_key: typing.Optional[str] = None,
|
|
30
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
31
|
+
) -> typing.Iterator[SpeechToTextStreamingSocketClient]:
|
|
32
|
+
"""
|
|
33
|
+
WebSocket channel for real-time speech to text streaming
|
|
34
|
+
|
|
35
|
+
Parameters
|
|
36
|
+
----------
|
|
37
|
+
language_code : SpeechToTextStreamingLanguageCode
|
|
38
|
+
Language code for speech recognition
|
|
39
|
+
|
|
40
|
+
model : SpeechToTextStreamingModel
|
|
41
|
+
Speech to text model to use
|
|
42
|
+
|
|
43
|
+
high_vad_sensitivity : typing.Optional[str]
|
|
44
|
+
Enable high VAD (Voice Activity Detection) sensitivity
|
|
45
|
+
|
|
46
|
+
vad_signals : typing.Optional[str]
|
|
47
|
+
Enable VAD signals in response
|
|
48
|
+
|
|
49
|
+
api_subscription_key : typing.Optional[str]
|
|
50
|
+
API subscription key for authentication
|
|
51
|
+
|
|
52
|
+
request_options : typing.Optional[RequestOptions]
|
|
53
|
+
Request-specific configuration.
|
|
54
|
+
|
|
55
|
+
Returns
|
|
56
|
+
-------
|
|
57
|
+
SpeechToTextStreamingSocketClient
|
|
58
|
+
"""
|
|
59
|
+
ws_url = self._client_wrapper.get_environment().production + "/speech-to-text/ws"
|
|
60
|
+
query_params = httpx.QueryParams()
|
|
61
|
+
if language_code is not None:
|
|
62
|
+
query_params = query_params.add("language-code", language_code)
|
|
63
|
+
if model is not None:
|
|
64
|
+
query_params = query_params.add("model", model)
|
|
65
|
+
if high_vad_sensitivity is not None:
|
|
66
|
+
query_params = query_params.add("high_vad_sensitivity", high_vad_sensitivity)
|
|
67
|
+
if vad_signals is not None:
|
|
68
|
+
query_params = query_params.add("vad_signals", vad_signals)
|
|
69
|
+
ws_url = ws_url + f"?{query_params}"
|
|
70
|
+
headers = self._client_wrapper.get_headers()
|
|
71
|
+
if api_subscription_key is not None:
|
|
72
|
+
headers["Api-Subscription-Key"] = str(api_subscription_key)
|
|
73
|
+
if request_options and "additional_headers" in request_options:
|
|
74
|
+
headers.update(request_options["additional_headers"])
|
|
75
|
+
try:
|
|
76
|
+
with websockets_sync_client.connect(ws_url, additional_headers=headers) as protocol:
|
|
77
|
+
yield SpeechToTextStreamingSocketClient(websocket=protocol)
|
|
78
|
+
except websockets.exceptions.InvalidStatusCode as exc:
|
|
79
|
+
status_code: int = exc.status_code
|
|
80
|
+
if status_code == 401:
|
|
81
|
+
raise ApiError(
|
|
82
|
+
status_code=status_code,
|
|
83
|
+
headers=dict(headers),
|
|
84
|
+
body="Websocket initialized with invalid credentials.",
|
|
85
|
+
)
|
|
86
|
+
raise ApiError(
|
|
87
|
+
status_code=status_code,
|
|
88
|
+
headers=dict(headers),
|
|
89
|
+
body="Unexpected error when initializing websocket connection.",
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
class AsyncRawSpeechToTextStreamingClient:
|
|
94
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
95
|
+
self._client_wrapper = client_wrapper
|
|
96
|
+
|
|
97
|
+
@asynccontextmanager
|
|
98
|
+
async def connect(
|
|
99
|
+
self,
|
|
100
|
+
*,
|
|
101
|
+
language_code: SpeechToTextStreamingLanguageCode,
|
|
102
|
+
model: SpeechToTextStreamingModel,
|
|
103
|
+
high_vad_sensitivity: typing.Optional[str] = None,
|
|
104
|
+
vad_signals: typing.Optional[str] = None,
|
|
105
|
+
api_subscription_key: typing.Optional[str] = None,
|
|
106
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
107
|
+
) -> typing.AsyncIterator[AsyncSpeechToTextStreamingSocketClient]:
|
|
108
|
+
"""
|
|
109
|
+
WebSocket channel for real-time speech to text streaming
|
|
110
|
+
|
|
111
|
+
Parameters
|
|
112
|
+
----------
|
|
113
|
+
language_code : SpeechToTextStreamingLanguageCode
|
|
114
|
+
Language code for speech recognition
|
|
115
|
+
|
|
116
|
+
model : SpeechToTextStreamingModel
|
|
117
|
+
Speech to text model to use
|
|
118
|
+
|
|
119
|
+
high_vad_sensitivity : typing.Optional[str]
|
|
120
|
+
Enable high VAD (Voice Activity Detection) sensitivity
|
|
121
|
+
|
|
122
|
+
vad_signals : typing.Optional[str]
|
|
123
|
+
Enable VAD signals in response
|
|
124
|
+
|
|
125
|
+
api_subscription_key : typing.Optional[str]
|
|
126
|
+
API subscription key for authentication
|
|
127
|
+
|
|
128
|
+
request_options : typing.Optional[RequestOptions]
|
|
129
|
+
Request-specific configuration.
|
|
130
|
+
|
|
131
|
+
Returns
|
|
132
|
+
-------
|
|
133
|
+
AsyncSpeechToTextStreamingSocketClient
|
|
134
|
+
"""
|
|
135
|
+
ws_url = self._client_wrapper.get_environment().production + "/speech-to-text/ws"
|
|
136
|
+
query_params = httpx.QueryParams()
|
|
137
|
+
if language_code is not None:
|
|
138
|
+
query_params = query_params.add("language-code", language_code)
|
|
139
|
+
if model is not None:
|
|
140
|
+
query_params = query_params.add("model", model)
|
|
141
|
+
if high_vad_sensitivity is not None:
|
|
142
|
+
query_params = query_params.add("high_vad_sensitivity", high_vad_sensitivity)
|
|
143
|
+
if vad_signals is not None:
|
|
144
|
+
query_params = query_params.add("vad_signals", vad_signals)
|
|
145
|
+
ws_url = ws_url + f"?{query_params}"
|
|
146
|
+
headers = self._client_wrapper.get_headers()
|
|
147
|
+
if api_subscription_key is not None:
|
|
148
|
+
headers["Api-Subscription-Key"] = str(api_subscription_key)
|
|
149
|
+
if request_options and "additional_headers" in request_options:
|
|
150
|
+
headers.update(request_options["additional_headers"])
|
|
151
|
+
try:
|
|
152
|
+
async with websockets.connect(ws_url, extra_headers=headers) as protocol:
|
|
153
|
+
yield AsyncSpeechToTextStreamingSocketClient(websocket=protocol)
|
|
154
|
+
except websockets.exceptions.InvalidStatusCode as exc:
|
|
155
|
+
status_code: int = exc.status_code
|
|
156
|
+
if status_code == 401:
|
|
157
|
+
raise ApiError(
|
|
158
|
+
status_code=status_code,
|
|
159
|
+
headers=dict(headers),
|
|
160
|
+
body="Websocket initialized with invalid credentials.",
|
|
161
|
+
)
|
|
162
|
+
raise ApiError(
|
|
163
|
+
status_code=status_code,
|
|
164
|
+
headers=dict(headers),
|
|
165
|
+
body="Unexpected error when initializing websocket connection.",
|
|
166
|
+
)
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import typing
|
|
5
|
+
|
|
6
|
+
import websockets
|
|
7
|
+
import websockets.sync.connection as websockets_sync_connection
|
|
8
|
+
from ..core.events import EventEmitterMixin, EventType
|
|
9
|
+
from ..core.pydantic_utilities import parse_obj_as
|
|
10
|
+
from ..types.audio_message import AudioMessage
|
|
11
|
+
from ..types.speech_to_text_streaming_response import SpeechToTextStreamingResponse
|
|
12
|
+
|
|
13
|
+
SpeechToTextStreamingSocketClientResponse = typing.Union[SpeechToTextStreamingResponse]
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class AsyncSpeechToTextStreamingSocketClient(EventEmitterMixin):
|
|
17
|
+
def __init__(self, *, websocket: websockets.WebSocketClientProtocol):
|
|
18
|
+
super().__init__()
|
|
19
|
+
self._websocket = websocket
|
|
20
|
+
|
|
21
|
+
async def __aiter__(self):
|
|
22
|
+
async for message in self._websocket:
|
|
23
|
+
yield parse_obj_as(SpeechToTextStreamingSocketClientResponse, message) # type: ignore
|
|
24
|
+
|
|
25
|
+
async def start_listening(self):
|
|
26
|
+
"""
|
|
27
|
+
Start listening for messages on the websocket connection.
|
|
28
|
+
|
|
29
|
+
Emits events in the following order:
|
|
30
|
+
- EventType.OPEN when connection is established
|
|
31
|
+
- EventType.MESSAGE for each message received
|
|
32
|
+
- EventType.ERROR if an error occurs
|
|
33
|
+
- EventType.CLOSE when connection is closed
|
|
34
|
+
"""
|
|
35
|
+
self._emit(EventType.OPEN, None)
|
|
36
|
+
try:
|
|
37
|
+
async for raw_message in self._websocket:
|
|
38
|
+
parsed = parse_obj_as(SpeechToTextStreamingSocketClientResponse, raw_message) # type: ignore
|
|
39
|
+
self._emit(EventType.MESSAGE, parsed)
|
|
40
|
+
except websockets.WebSocketException as exc:
|
|
41
|
+
self._emit(EventType.ERROR, exc)
|
|
42
|
+
finally:
|
|
43
|
+
self._emit(EventType.CLOSE, None)
|
|
44
|
+
|
|
45
|
+
async def send_audio_message(self, message: AudioMessage) -> None:
|
|
46
|
+
"""
|
|
47
|
+
Send a message to the websocket connection.
|
|
48
|
+
The message will be sent as a AudioMessage.
|
|
49
|
+
"""
|
|
50
|
+
await self._send_model(message)
|
|
51
|
+
|
|
52
|
+
async def recv(self) -> SpeechToTextStreamingSocketClientResponse:
|
|
53
|
+
"""
|
|
54
|
+
Receive a message from the websocket connection.
|
|
55
|
+
"""
|
|
56
|
+
data = await self._websocket.recv()
|
|
57
|
+
return parse_obj_as(SpeechToTextStreamingSocketClientResponse, data) # type: ignore
|
|
58
|
+
|
|
59
|
+
async def _send(self, data: typing.Any) -> None:
|
|
60
|
+
"""
|
|
61
|
+
Send a message to the websocket connection.
|
|
62
|
+
"""
|
|
63
|
+
if isinstance(data, dict):
|
|
64
|
+
data = json.dumps(data)
|
|
65
|
+
await self._websocket.send(data)
|
|
66
|
+
|
|
67
|
+
async def _send_model(self, data: typing.Any) -> None:
|
|
68
|
+
"""
|
|
69
|
+
Send a Pydantic model to the websocket connection.
|
|
70
|
+
"""
|
|
71
|
+
await self._send(data.dict())
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
class SpeechToTextStreamingSocketClient(EventEmitterMixin):
|
|
75
|
+
def __init__(self, *, websocket: websockets_sync_connection.Connection):
|
|
76
|
+
super().__init__()
|
|
77
|
+
self._websocket = websocket
|
|
78
|
+
|
|
79
|
+
def __iter__(self):
|
|
80
|
+
for message in self._websocket:
|
|
81
|
+
yield parse_obj_as(SpeechToTextStreamingSocketClientResponse, message) # type: ignore
|
|
82
|
+
|
|
83
|
+
def start_listening(self):
|
|
84
|
+
"""
|
|
85
|
+
Start listening for messages on the websocket connection.
|
|
86
|
+
|
|
87
|
+
Emits events in the following order:
|
|
88
|
+
- EventType.OPEN when connection is established
|
|
89
|
+
- EventType.MESSAGE for each message received
|
|
90
|
+
- EventType.ERROR if an error occurs
|
|
91
|
+
- EventType.CLOSE when connection is closed
|
|
92
|
+
"""
|
|
93
|
+
self._emit(EventType.OPEN, None)
|
|
94
|
+
try:
|
|
95
|
+
for raw_message in self._websocket:
|
|
96
|
+
parsed = parse_obj_as(SpeechToTextStreamingSocketClientResponse, raw_message) # type: ignore
|
|
97
|
+
self._emit(EventType.MESSAGE, parsed)
|
|
98
|
+
except websockets.WebSocketException as exc:
|
|
99
|
+
self._emit(EventType.ERROR, exc)
|
|
100
|
+
finally:
|
|
101
|
+
self._emit(EventType.CLOSE, None)
|
|
102
|
+
|
|
103
|
+
def send_audio_message(self, message: AudioMessage) -> None:
|
|
104
|
+
"""
|
|
105
|
+
Send a message to the websocket connection.
|
|
106
|
+
The message will be sent as a AudioMessage.
|
|
107
|
+
"""
|
|
108
|
+
self._send_model(message)
|
|
109
|
+
|
|
110
|
+
def recv(self) -> SpeechToTextStreamingSocketClientResponse:
|
|
111
|
+
"""
|
|
112
|
+
Receive a message from the websocket connection.
|
|
113
|
+
"""
|
|
114
|
+
data = self._websocket.recv()
|
|
115
|
+
return parse_obj_as(SpeechToTextStreamingSocketClientResponse, data) # type: ignore
|
|
116
|
+
|
|
117
|
+
def _send(self, data: typing.Any) -> None:
|
|
118
|
+
"""
|
|
119
|
+
Send a message to the websocket connection.
|
|
120
|
+
"""
|
|
121
|
+
if isinstance(data, dict):
|
|
122
|
+
data = json.dumps(data)
|
|
123
|
+
self._websocket.send(data)
|
|
124
|
+
|
|
125
|
+
def _send_model(self, data: typing.Any) -> None:
|
|
126
|
+
"""
|
|
127
|
+
Send a Pydantic model to the websocket connection.
|
|
128
|
+
"""
|
|
129
|
+
self._send(data.dict())
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
# isort: skip_file
|
|
4
|
+
|
|
5
|
+
from .speech_to_text_streaming_language_code import SpeechToTextStreamingLanguageCode
|
|
6
|
+
from .speech_to_text_streaming_model import SpeechToTextStreamingModel
|
|
7
|
+
|
|
8
|
+
__all__ = ["SpeechToTextStreamingLanguageCode", "SpeechToTextStreamingModel"]
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
SpeechToTextStreamingLanguageCode = typing.Union[
|
|
6
|
+
typing.Literal["en-IN", "hi-IN", "bn-IN", "gu-IN", "kn-IN", "ml-IN", "mr-IN", "od-IN", "pa-IN", "ta-IN", "te-IN"],
|
|
7
|
+
typing.Any,
|
|
8
|
+
]
|
sarvamai/text/__init__.py
CHANGED
sarvamai/text/client.py
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
|
2
2
|
|
|
3
3
|
import typing
|
|
4
|
-
|
|
5
|
-
from .
|
|
6
|
-
from ..
|
|
7
|
-
from ..types.
|
|
8
|
-
from ..types.
|
|
4
|
+
|
|
5
|
+
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
6
|
+
from ..core.request_options import RequestOptions
|
|
7
|
+
from ..types.language_identification_response import LanguageIdentificationResponse
|
|
8
|
+
from ..types.numerals_format import NumeralsFormat
|
|
9
|
+
from ..types.spoken_form_numerals_format import SpokenFormNumeralsFormat
|
|
9
10
|
from ..types.translate_mode import TranslateMode
|
|
10
11
|
from ..types.translate_model import TranslateModel
|
|
11
|
-
from ..types.
|
|
12
|
-
from ..types.
|
|
13
|
-
from ..
|
|
12
|
+
from ..types.translate_source_language import TranslateSourceLanguage
|
|
13
|
+
from ..types.translate_speaker_gender import TranslateSpeakerGender
|
|
14
|
+
from ..types.translate_target_language import TranslateTargetLanguage
|
|
14
15
|
from ..types.translation_response import TranslationResponse
|
|
15
|
-
from ..types.language_identification_response import LanguageIdentificationResponse
|
|
16
|
-
from ..types.transliterate_source_language import TransliterateSourceLanguage
|
|
17
16
|
from ..types.translatiterate_target_language import TranslatiterateTargetLanguage
|
|
18
|
-
from ..types.
|
|
17
|
+
from ..types.transliterate_mode import TransliterateMode
|
|
18
|
+
from ..types.transliterate_source_language import TransliterateSourceLanguage
|
|
19
19
|
from ..types.transliteration_response import TransliterationResponse
|
|
20
|
-
from
|
|
21
|
-
from .raw_client import AsyncRawTextClient
|
|
20
|
+
from .raw_client import AsyncRawTextClient, RawTextClient
|
|
22
21
|
|
|
23
22
|
# this is used as the default value for optional parameters
|
|
24
23
|
OMIT = typing.cast(typing.Any, ...)
|
|
@@ -180,7 +179,7 @@ class TextClient:
|
|
|
180
179
|
target_language_code="bn-IN",
|
|
181
180
|
)
|
|
182
181
|
"""
|
|
183
|
-
|
|
182
|
+
_response = self._raw_client.translate(
|
|
184
183
|
input=input,
|
|
185
184
|
source_language_code=source_language_code,
|
|
186
185
|
target_language_code=target_language_code,
|
|
@@ -192,7 +191,7 @@ class TextClient:
|
|
|
192
191
|
numerals_format=numerals_format,
|
|
193
192
|
request_options=request_options,
|
|
194
193
|
)
|
|
195
|
-
return
|
|
194
|
+
return _response.data
|
|
196
195
|
|
|
197
196
|
def identify_language(
|
|
198
197
|
self, *, input: str, request_options: typing.Optional[RequestOptions] = None
|
|
@@ -224,8 +223,8 @@ class TextClient:
|
|
|
224
223
|
input="input",
|
|
225
224
|
)
|
|
226
225
|
"""
|
|
227
|
-
|
|
228
|
-
return
|
|
226
|
+
_response = self._raw_client.identify_language(input=input, request_options=request_options)
|
|
227
|
+
return _response.data
|
|
229
228
|
|
|
230
229
|
def transliterate(
|
|
231
230
|
self,
|
|
@@ -336,7 +335,7 @@ class TextClient:
|
|
|
336
335
|
target_language_code="bn-IN",
|
|
337
336
|
)
|
|
338
337
|
"""
|
|
339
|
-
|
|
338
|
+
_response = self._raw_client.transliterate(
|
|
340
339
|
input=input,
|
|
341
340
|
source_language_code=source_language_code,
|
|
342
341
|
target_language_code=target_language_code,
|
|
@@ -345,7 +344,7 @@ class TextClient:
|
|
|
345
344
|
spoken_form=spoken_form,
|
|
346
345
|
request_options=request_options,
|
|
347
346
|
)
|
|
348
|
-
return
|
|
347
|
+
return _response.data
|
|
349
348
|
|
|
350
349
|
|
|
351
350
|
class AsyncTextClient:
|
|
@@ -512,7 +511,7 @@ class AsyncTextClient:
|
|
|
512
511
|
|
|
513
512
|
asyncio.run(main())
|
|
514
513
|
"""
|
|
515
|
-
|
|
514
|
+
_response = await self._raw_client.translate(
|
|
516
515
|
input=input,
|
|
517
516
|
source_language_code=source_language_code,
|
|
518
517
|
target_language_code=target_language_code,
|
|
@@ -524,7 +523,7 @@ class AsyncTextClient:
|
|
|
524
523
|
numerals_format=numerals_format,
|
|
525
524
|
request_options=request_options,
|
|
526
525
|
)
|
|
527
|
-
return
|
|
526
|
+
return _response.data
|
|
528
527
|
|
|
529
528
|
async def identify_language(
|
|
530
529
|
self, *, input: str, request_options: typing.Optional[RequestOptions] = None
|
|
@@ -564,8 +563,8 @@ class AsyncTextClient:
|
|
|
564
563
|
|
|
565
564
|
asyncio.run(main())
|
|
566
565
|
"""
|
|
567
|
-
|
|
568
|
-
return
|
|
566
|
+
_response = await self._raw_client.identify_language(input=input, request_options=request_options)
|
|
567
|
+
return _response.data
|
|
569
568
|
|
|
570
569
|
async def transliterate(
|
|
571
570
|
self,
|
|
@@ -684,7 +683,7 @@ class AsyncTextClient:
|
|
|
684
683
|
|
|
685
684
|
asyncio.run(main())
|
|
686
685
|
"""
|
|
687
|
-
|
|
686
|
+
_response = await self._raw_client.transliterate(
|
|
688
687
|
input=input,
|
|
689
688
|
source_language_code=source_language_code,
|
|
690
689
|
target_language_code=target_language_code,
|
|
@@ -693,4 +692,4 @@ class AsyncTextClient:
|
|
|
693
692
|
spoken_form=spoken_form,
|
|
694
693
|
request_options=request_options,
|
|
695
694
|
)
|
|
696
|
-
return
|
|
695
|
+
return _response.data
|