sarvamai 0.1.7__py3-none-any.whl → 0.1.8a0__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 +58 -1
- sarvamai/client.py +3 -0
- sarvamai/core/client_wrapper.py +2 -2
- sarvamai/requests/__init__.py +20 -0
- sarvamai/requests/audio_output.py +11 -0
- sarvamai/requests/audio_output_data.py +15 -0
- sarvamai/requests/close_connection.py +9 -0
- sarvamai/requests/error_response.py +11 -0
- sarvamai/requests/error_response_data.py +18 -0
- sarvamai/requests/initialize_connection.py +11 -0
- sarvamai/requests/initialize_connection_data.py +24 -0
- sarvamai/requests/ping_signal.py +9 -0
- sarvamai/requests/send_text.py +11 -0
- sarvamai/requests/send_text_data.py +7 -0
- sarvamai/text_to_speech_streaming/__init__.py +4 -0
- sarvamai/text_to_speech_streaming/client.py +136 -0
- sarvamai/text_to_speech_streaming/raw_client.py +113 -0
- sarvamai/text_to_speech_streaming/socket_client.py +175 -0
- sarvamai/types/__init__.py +28 -0
- sarvamai/types/audio_output.py +21 -0
- sarvamai/types/audio_output_data.py +27 -0
- sarvamai/types/close_connection.py +19 -0
- sarvamai/types/error_response.py +21 -0
- sarvamai/types/error_response_data.py +28 -0
- sarvamai/types/initialize_connection.py +21 -0
- sarvamai/types/initialize_connection_data.py +34 -0
- sarvamai/types/initialize_connection_data_model.py +5 -0
- sarvamai/types/initialize_connection_data_output_audio_bitrate.py +7 -0
- sarvamai/types/initialize_connection_data_speaker.py +28 -0
- sarvamai/types/initialize_connection_data_target_language_code.py +8 -0
- sarvamai/types/ping_signal.py +19 -0
- sarvamai/types/send_text.py +21 -0
- sarvamai/types/send_text_data.py +19 -0
- {sarvamai-0.1.7.dist-info → sarvamai-0.1.8a0.dist-info}/METADATA +2 -2
- {sarvamai-0.1.7.dist-info → sarvamai-0.1.8a0.dist-info}/RECORD +36 -8
- {sarvamai-0.1.7.dist-info → sarvamai-0.1.8a0.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,175 @@
|
|
|
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_output import AudioOutput
|
|
11
|
+
from ..types.close_connection import CloseConnection
|
|
12
|
+
from ..types.error_response import ErrorResponse
|
|
13
|
+
from ..types.initialize_connection import InitializeConnection
|
|
14
|
+
from ..types.ping_signal import PingSignal
|
|
15
|
+
from ..types.send_text import SendText
|
|
16
|
+
|
|
17
|
+
TextToSpeechStreamingSocketClientResponse = typing.Union[AudioOutput, ErrorResponse]
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class AsyncTextToSpeechStreamingSocketClient(EventEmitterMixin):
|
|
21
|
+
def __init__(self, *, websocket: websockets.WebSocketClientProtocol):
|
|
22
|
+
super().__init__()
|
|
23
|
+
self._websocket = websocket
|
|
24
|
+
|
|
25
|
+
async def __aiter__(self):
|
|
26
|
+
async for message in self._websocket:
|
|
27
|
+
yield parse_obj_as(TextToSpeechStreamingSocketClientResponse, message) # type: ignore
|
|
28
|
+
|
|
29
|
+
async def start_listening(self):
|
|
30
|
+
"""
|
|
31
|
+
Start listening for messages on the websocket connection.
|
|
32
|
+
|
|
33
|
+
Emits events in the following order:
|
|
34
|
+
- EventType.OPEN when connection is established
|
|
35
|
+
- EventType.MESSAGE for each message received
|
|
36
|
+
- EventType.ERROR if an error occurs
|
|
37
|
+
- EventType.CLOSE when connection is closed
|
|
38
|
+
"""
|
|
39
|
+
self._emit(EventType.OPEN, None)
|
|
40
|
+
try:
|
|
41
|
+
async for raw_message in self._websocket:
|
|
42
|
+
parsed = parse_obj_as(TextToSpeechStreamingSocketClientResponse, raw_message) # type: ignore
|
|
43
|
+
self._emit(EventType.MESSAGE, parsed)
|
|
44
|
+
except websockets.WebSocketException as exc:
|
|
45
|
+
self._emit(EventType.ERROR, exc)
|
|
46
|
+
finally:
|
|
47
|
+
self._emit(EventType.CLOSE, None)
|
|
48
|
+
|
|
49
|
+
async def send_initialize_connection(self, message: InitializeConnection) -> None:
|
|
50
|
+
"""
|
|
51
|
+
Send a message to the websocket connection.
|
|
52
|
+
The message will be sent as a InitializeConnection.
|
|
53
|
+
"""
|
|
54
|
+
await self._send_model(message)
|
|
55
|
+
|
|
56
|
+
async def send_send_text(self, message: SendText) -> None:
|
|
57
|
+
"""
|
|
58
|
+
Send a message to the websocket connection.
|
|
59
|
+
The message will be sent as a SendText.
|
|
60
|
+
"""
|
|
61
|
+
await self._send_model(message)
|
|
62
|
+
|
|
63
|
+
async def send_close_connection(self, message: CloseConnection) -> None:
|
|
64
|
+
"""
|
|
65
|
+
Send a message to the websocket connection.
|
|
66
|
+
The message will be sent as a CloseConnection.
|
|
67
|
+
"""
|
|
68
|
+
await self._send_model(message)
|
|
69
|
+
|
|
70
|
+
async def send_ping_signal(self, message: PingSignal) -> None:
|
|
71
|
+
"""
|
|
72
|
+
Send a message to the websocket connection.
|
|
73
|
+
The message will be sent as a PingSignal.
|
|
74
|
+
"""
|
|
75
|
+
await self._send_model(message)
|
|
76
|
+
|
|
77
|
+
async def recv(self) -> TextToSpeechStreamingSocketClientResponse:
|
|
78
|
+
"""
|
|
79
|
+
Receive a message from the websocket connection.
|
|
80
|
+
"""
|
|
81
|
+
data = await self._websocket.recv()
|
|
82
|
+
return parse_obj_as(TextToSpeechStreamingSocketClientResponse, data) # type: ignore
|
|
83
|
+
|
|
84
|
+
async def _send(self, data: typing.Any) -> None:
|
|
85
|
+
"""
|
|
86
|
+
Send a message to the websocket connection.
|
|
87
|
+
"""
|
|
88
|
+
if isinstance(data, dict):
|
|
89
|
+
data = json.dumps(data)
|
|
90
|
+
await self._websocket.send(data)
|
|
91
|
+
|
|
92
|
+
async def _send_model(self, data: typing.Any) -> None:
|
|
93
|
+
"""
|
|
94
|
+
Send a Pydantic model to the websocket connection.
|
|
95
|
+
"""
|
|
96
|
+
await self._send(data.dict())
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
class TextToSpeechStreamingSocketClient(EventEmitterMixin):
|
|
100
|
+
def __init__(self, *, websocket: websockets_sync_connection.Connection):
|
|
101
|
+
super().__init__()
|
|
102
|
+
self._websocket = websocket
|
|
103
|
+
|
|
104
|
+
def __iter__(self):
|
|
105
|
+
for message in self._websocket:
|
|
106
|
+
yield parse_obj_as(TextToSpeechStreamingSocketClientResponse, message) # type: ignore
|
|
107
|
+
|
|
108
|
+
def start_listening(self):
|
|
109
|
+
"""
|
|
110
|
+
Start listening for messages on the websocket connection.
|
|
111
|
+
|
|
112
|
+
Emits events in the following order:
|
|
113
|
+
- EventType.OPEN when connection is established
|
|
114
|
+
- EventType.MESSAGE for each message received
|
|
115
|
+
- EventType.ERROR if an error occurs
|
|
116
|
+
- EventType.CLOSE when connection is closed
|
|
117
|
+
"""
|
|
118
|
+
self._emit(EventType.OPEN, None)
|
|
119
|
+
try:
|
|
120
|
+
for raw_message in self._websocket:
|
|
121
|
+
parsed = parse_obj_as(TextToSpeechStreamingSocketClientResponse, raw_message) # type: ignore
|
|
122
|
+
self._emit(EventType.MESSAGE, parsed)
|
|
123
|
+
except websockets.WebSocketException as exc:
|
|
124
|
+
self._emit(EventType.ERROR, exc)
|
|
125
|
+
finally:
|
|
126
|
+
self._emit(EventType.CLOSE, None)
|
|
127
|
+
|
|
128
|
+
def send_initialize_connection(self, message: InitializeConnection) -> None:
|
|
129
|
+
"""
|
|
130
|
+
Send a message to the websocket connection.
|
|
131
|
+
The message will be sent as a InitializeConnection.
|
|
132
|
+
"""
|
|
133
|
+
self._send_model(message)
|
|
134
|
+
|
|
135
|
+
def send_send_text(self, message: SendText) -> None:
|
|
136
|
+
"""
|
|
137
|
+
Send a message to the websocket connection.
|
|
138
|
+
The message will be sent as a SendText.
|
|
139
|
+
"""
|
|
140
|
+
self._send_model(message)
|
|
141
|
+
|
|
142
|
+
def send_close_connection(self, message: CloseConnection) -> None:
|
|
143
|
+
"""
|
|
144
|
+
Send a message to the websocket connection.
|
|
145
|
+
The message will be sent as a CloseConnection.
|
|
146
|
+
"""
|
|
147
|
+
self._send_model(message)
|
|
148
|
+
|
|
149
|
+
def send_ping_signal(self, message: PingSignal) -> None:
|
|
150
|
+
"""
|
|
151
|
+
Send a message to the websocket connection.
|
|
152
|
+
The message will be sent as a PingSignal.
|
|
153
|
+
"""
|
|
154
|
+
self._send_model(message)
|
|
155
|
+
|
|
156
|
+
def recv(self) -> TextToSpeechStreamingSocketClientResponse:
|
|
157
|
+
"""
|
|
158
|
+
Receive a message from the websocket connection.
|
|
159
|
+
"""
|
|
160
|
+
data = self._websocket.recv()
|
|
161
|
+
return parse_obj_as(TextToSpeechStreamingSocketClientResponse, data) # type: ignore
|
|
162
|
+
|
|
163
|
+
def _send(self, data: typing.Any) -> None:
|
|
164
|
+
"""
|
|
165
|
+
Send a message to the websocket connection.
|
|
166
|
+
"""
|
|
167
|
+
if isinstance(data, dict):
|
|
168
|
+
data = json.dumps(data)
|
|
169
|
+
self._websocket.send(data)
|
|
170
|
+
|
|
171
|
+
def _send_model(self, data: typing.Any) -> None:
|
|
172
|
+
"""
|
|
173
|
+
Send a Pydantic model to the websocket connection.
|
|
174
|
+
"""
|
|
175
|
+
self._send(data.dict())
|
sarvamai/types/__init__.py
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
from .audio_data import AudioData
|
|
6
6
|
from .audio_message import AudioMessage
|
|
7
|
+
from .audio_output import AudioOutput
|
|
8
|
+
from .audio_output_data import AudioOutputData
|
|
7
9
|
from .chat_completion_request_assistant_message import ChatCompletionRequestAssistantMessage
|
|
8
10
|
from .chat_completion_request_message import (
|
|
9
11
|
ChatCompletionRequestMessage,
|
|
@@ -15,6 +17,7 @@ from .chat_completion_request_system_message import ChatCompletionRequestSystemM
|
|
|
15
17
|
from .chat_completion_request_user_message import ChatCompletionRequestUserMessage
|
|
16
18
|
from .chat_completion_response_message import ChatCompletionResponseMessage
|
|
17
19
|
from .choice import Choice
|
|
20
|
+
from .close_connection import CloseConnection
|
|
18
21
|
from .completion_usage import CompletionUsage
|
|
19
22
|
from .config_message import ConfigMessage
|
|
20
23
|
from .create_chat_completion_response import CreateChatCompletionResponse
|
|
@@ -24,15 +27,26 @@ from .error_code import ErrorCode
|
|
|
24
27
|
from .error_data import ErrorData
|
|
25
28
|
from .error_details import ErrorDetails
|
|
26
29
|
from .error_message import ErrorMessage
|
|
30
|
+
from .error_response import ErrorResponse
|
|
31
|
+
from .error_response_data import ErrorResponseData
|
|
27
32
|
from .events_data import EventsData
|
|
28
33
|
from .finish_reason import FinishReason
|
|
29
34
|
from .format import Format
|
|
35
|
+
from .initialize_connection import InitializeConnection
|
|
36
|
+
from .initialize_connection_data import InitializeConnectionData
|
|
37
|
+
from .initialize_connection_data_model import InitializeConnectionDataModel
|
|
38
|
+
from .initialize_connection_data_output_audio_bitrate import InitializeConnectionDataOutputAudioBitrate
|
|
39
|
+
from .initialize_connection_data_speaker import InitializeConnectionDataSpeaker
|
|
40
|
+
from .initialize_connection_data_target_language_code import InitializeConnectionDataTargetLanguageCode
|
|
30
41
|
from .language_identification_response import LanguageIdentificationResponse
|
|
31
42
|
from .numerals_format import NumeralsFormat
|
|
43
|
+
from .ping_signal import PingSignal
|
|
32
44
|
from .reasoning_effort import ReasoningEffort
|
|
33
45
|
from .response_type import ResponseType
|
|
34
46
|
from .role import Role
|
|
35
47
|
from .sarvam_model_ids import SarvamModelIds
|
|
48
|
+
from .send_text import SendText
|
|
49
|
+
from .send_text_data import SendTextData
|
|
36
50
|
from .speech_sample_rate import SpeechSampleRate
|
|
37
51
|
from .speech_to_text_language import SpeechToTextLanguage
|
|
38
52
|
from .speech_to_text_model import SpeechToTextModel
|
|
@@ -68,6 +82,8 @@ from .transliteration_response import TransliterationResponse
|
|
|
68
82
|
__all__ = [
|
|
69
83
|
"AudioData",
|
|
70
84
|
"AudioMessage",
|
|
85
|
+
"AudioOutput",
|
|
86
|
+
"AudioOutputData",
|
|
71
87
|
"ChatCompletionRequestAssistantMessage",
|
|
72
88
|
"ChatCompletionRequestMessage",
|
|
73
89
|
"ChatCompletionRequestMessage_Assistant",
|
|
@@ -77,6 +93,7 @@ __all__ = [
|
|
|
77
93
|
"ChatCompletionRequestUserMessage",
|
|
78
94
|
"ChatCompletionResponseMessage",
|
|
79
95
|
"Choice",
|
|
96
|
+
"CloseConnection",
|
|
80
97
|
"CompletionUsage",
|
|
81
98
|
"ConfigMessage",
|
|
82
99
|
"CreateChatCompletionResponse",
|
|
@@ -86,15 +103,26 @@ __all__ = [
|
|
|
86
103
|
"ErrorData",
|
|
87
104
|
"ErrorDetails",
|
|
88
105
|
"ErrorMessage",
|
|
106
|
+
"ErrorResponse",
|
|
107
|
+
"ErrorResponseData",
|
|
89
108
|
"EventsData",
|
|
90
109
|
"FinishReason",
|
|
91
110
|
"Format",
|
|
111
|
+
"InitializeConnection",
|
|
112
|
+
"InitializeConnectionData",
|
|
113
|
+
"InitializeConnectionDataModel",
|
|
114
|
+
"InitializeConnectionDataOutputAudioBitrate",
|
|
115
|
+
"InitializeConnectionDataSpeaker",
|
|
116
|
+
"InitializeConnectionDataTargetLanguageCode",
|
|
92
117
|
"LanguageIdentificationResponse",
|
|
93
118
|
"NumeralsFormat",
|
|
119
|
+
"PingSignal",
|
|
94
120
|
"ReasoningEffort",
|
|
95
121
|
"ResponseType",
|
|
96
122
|
"Role",
|
|
97
123
|
"SarvamModelIds",
|
|
124
|
+
"SendText",
|
|
125
|
+
"SendTextData",
|
|
98
126
|
"SpeechSampleRate",
|
|
99
127
|
"SpeechToTextLanguage",
|
|
100
128
|
"SpeechToTextModel",
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
import pydantic
|
|
6
|
+
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
|
|
7
|
+
from .audio_output_data import AudioOutputData
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class AudioOutput(UniversalBaseModel):
|
|
11
|
+
type: typing.Literal["audio"] = "audio"
|
|
12
|
+
data: AudioOutputData
|
|
13
|
+
|
|
14
|
+
if IS_PYDANTIC_V2:
|
|
15
|
+
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
|
|
16
|
+
else:
|
|
17
|
+
|
|
18
|
+
class Config:
|
|
19
|
+
frozen = True
|
|
20
|
+
smart_union = True
|
|
21
|
+
extra = pydantic.Extra.allow
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
import pydantic
|
|
6
|
+
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class AudioOutputData(UniversalBaseModel):
|
|
10
|
+
content_type: str = pydantic.Field()
|
|
11
|
+
"""
|
|
12
|
+
MIME type of the audio content (e.g., 'audio/mp3', 'audio/wav')
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
audio: str = pydantic.Field()
|
|
16
|
+
"""
|
|
17
|
+
Base64-encoded audio data ready for playback or download
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
if IS_PYDANTIC_V2:
|
|
21
|
+
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
|
|
22
|
+
else:
|
|
23
|
+
|
|
24
|
+
class Config:
|
|
25
|
+
frozen = True
|
|
26
|
+
smart_union = True
|
|
27
|
+
extra = pydantic.Extra.allow
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
import pydantic
|
|
6
|
+
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class CloseConnection(UniversalBaseModel):
|
|
10
|
+
type: typing.Literal["flush"] = "flush"
|
|
11
|
+
|
|
12
|
+
if IS_PYDANTIC_V2:
|
|
13
|
+
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
|
|
14
|
+
else:
|
|
15
|
+
|
|
16
|
+
class Config:
|
|
17
|
+
frozen = True
|
|
18
|
+
smart_union = True
|
|
19
|
+
extra = pydantic.Extra.allow
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
import pydantic
|
|
6
|
+
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
|
|
7
|
+
from .error_response_data import ErrorResponseData
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class ErrorResponse(UniversalBaseModel):
|
|
11
|
+
type: typing.Literal["error"] = "error"
|
|
12
|
+
data: ErrorResponseData
|
|
13
|
+
|
|
14
|
+
if IS_PYDANTIC_V2:
|
|
15
|
+
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
|
|
16
|
+
else:
|
|
17
|
+
|
|
18
|
+
class Config:
|
|
19
|
+
frozen = True
|
|
20
|
+
smart_union = True
|
|
21
|
+
extra = pydantic.Extra.allow
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
import pydantic
|
|
6
|
+
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class ErrorResponseData(UniversalBaseModel):
|
|
10
|
+
message: str
|
|
11
|
+
code: typing.Optional[int] = pydantic.Field(default=None)
|
|
12
|
+
"""
|
|
13
|
+
Optional error code for programmatic error handling
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
details: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None)
|
|
17
|
+
"""
|
|
18
|
+
Additional error details and context information
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
if IS_PYDANTIC_V2:
|
|
22
|
+
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
|
|
23
|
+
else:
|
|
24
|
+
|
|
25
|
+
class Config:
|
|
26
|
+
frozen = True
|
|
27
|
+
smart_union = True
|
|
28
|
+
extra = pydantic.Extra.allow
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
import pydantic
|
|
6
|
+
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
|
|
7
|
+
from .initialize_connection_data import InitializeConnectionData
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class InitializeConnection(UniversalBaseModel):
|
|
11
|
+
type: typing.Literal["config"] = "config"
|
|
12
|
+
data: InitializeConnectionData
|
|
13
|
+
|
|
14
|
+
if IS_PYDANTIC_V2:
|
|
15
|
+
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
|
|
16
|
+
else:
|
|
17
|
+
|
|
18
|
+
class Config:
|
|
19
|
+
frozen = True
|
|
20
|
+
smart_union = True
|
|
21
|
+
extra = pydantic.Extra.allow
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
import pydantic
|
|
6
|
+
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
|
|
7
|
+
from .initialize_connection_data_model import InitializeConnectionDataModel
|
|
8
|
+
from .initialize_connection_data_output_audio_bitrate import InitializeConnectionDataOutputAudioBitrate
|
|
9
|
+
from .initialize_connection_data_speaker import InitializeConnectionDataSpeaker
|
|
10
|
+
from .initialize_connection_data_target_language_code import InitializeConnectionDataTargetLanguageCode
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class InitializeConnectionData(UniversalBaseModel):
|
|
14
|
+
target_language_code: InitializeConnectionDataTargetLanguageCode
|
|
15
|
+
speaker: InitializeConnectionDataSpeaker
|
|
16
|
+
pitch: typing.Optional[float] = None
|
|
17
|
+
pace: typing.Optional[float] = None
|
|
18
|
+
loudness: typing.Optional[float] = None
|
|
19
|
+
speech_sample_rate: typing.Optional[int] = None
|
|
20
|
+
enable_preprocessing: typing.Optional[bool] = None
|
|
21
|
+
model: InitializeConnectionDataModel
|
|
22
|
+
output_audio_codec: typing.Optional[typing.Literal["mp3"]] = None
|
|
23
|
+
output_audio_bitrate: typing.Optional[InitializeConnectionDataOutputAudioBitrate] = None
|
|
24
|
+
min_buffer_size: typing.Optional[int] = None
|
|
25
|
+
max_chunk_length: typing.Optional[int] = None
|
|
26
|
+
|
|
27
|
+
if IS_PYDANTIC_V2:
|
|
28
|
+
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
|
|
29
|
+
else:
|
|
30
|
+
|
|
31
|
+
class Config:
|
|
32
|
+
frozen = True
|
|
33
|
+
smart_union = True
|
|
34
|
+
extra = pydantic.Extra.allow
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
InitializeConnectionDataSpeaker = typing.Union[
|
|
6
|
+
typing.Literal[
|
|
7
|
+
"meera",
|
|
8
|
+
"pavithra",
|
|
9
|
+
"maitreyi",
|
|
10
|
+
"arvind",
|
|
11
|
+
"amol",
|
|
12
|
+
"amartya",
|
|
13
|
+
"diya",
|
|
14
|
+
"neel",
|
|
15
|
+
"misha",
|
|
16
|
+
"vian",
|
|
17
|
+
"arjun",
|
|
18
|
+
"maya",
|
|
19
|
+
"anushka",
|
|
20
|
+
"abhilash",
|
|
21
|
+
"manisha",
|
|
22
|
+
"vidya",
|
|
23
|
+
"arya",
|
|
24
|
+
"karun",
|
|
25
|
+
"hitesh",
|
|
26
|
+
],
|
|
27
|
+
typing.Any,
|
|
28
|
+
]
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
InitializeConnectionDataTargetLanguageCode = typing.Union[
|
|
6
|
+
typing.Literal["bn-IN", "en-IN", "gu-IN", "hi-IN", "kn-IN", "ml-IN", "mr-IN", "od-IN", "pa-IN", "ta-IN", "te-IN"],
|
|
7
|
+
typing.Any,
|
|
8
|
+
]
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
import pydantic
|
|
6
|
+
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class PingSignal(UniversalBaseModel):
|
|
10
|
+
type: typing.Literal["ping"] = "ping"
|
|
11
|
+
|
|
12
|
+
if IS_PYDANTIC_V2:
|
|
13
|
+
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
|
|
14
|
+
else:
|
|
15
|
+
|
|
16
|
+
class Config:
|
|
17
|
+
frozen = True
|
|
18
|
+
smart_union = True
|
|
19
|
+
extra = pydantic.Extra.allow
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
import pydantic
|
|
6
|
+
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
|
|
7
|
+
from .send_text_data import SendTextData
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class SendText(UniversalBaseModel):
|
|
11
|
+
type: typing.Literal["text"] = "text"
|
|
12
|
+
data: SendTextData
|
|
13
|
+
|
|
14
|
+
if IS_PYDANTIC_V2:
|
|
15
|
+
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
|
|
16
|
+
else:
|
|
17
|
+
|
|
18
|
+
class Config:
|
|
19
|
+
frozen = True
|
|
20
|
+
smart_union = True
|
|
21
|
+
extra = pydantic.Extra.allow
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
import pydantic
|
|
6
|
+
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class SendTextData(UniversalBaseModel):
|
|
10
|
+
text: str
|
|
11
|
+
|
|
12
|
+
if IS_PYDANTIC_V2:
|
|
13
|
+
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
|
|
14
|
+
else:
|
|
15
|
+
|
|
16
|
+
class Config:
|
|
17
|
+
frozen = True
|
|
18
|
+
smart_union = True
|
|
19
|
+
extra = pydantic.Extra.allow
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: sarvamai
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.8a0
|
|
4
4
|
Summary:
|
|
5
5
|
Requires-Python: >=3.8,<4.0
|
|
6
6
|
Classifier: Intended Audience :: Developers
|
|
@@ -34,7 +34,7 @@ The Sarvam Python library provides convenient access to the Sarvam API from Pyth
|
|
|
34
34
|
|
|
35
35
|
## Documentation
|
|
36
36
|
|
|
37
|
-
API reference documentation is available [here](https://
|
|
37
|
+
API reference documentation is available [here](https://docs.sarvam.ai/api-reference-docs/speech-to-text/).
|
|
38
38
|
|
|
39
39
|
## Installation
|
|
40
40
|
|