sarvamai 0.1.22a4__py3-none-any.whl → 0.1.23a1__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.
Files changed (56) hide show
  1. sarvamai/__init__.py +405 -200
  2. sarvamai/chat/raw_client.py +20 -20
  3. sarvamai/client.py +186 -34
  4. sarvamai/core/__init__.py +76 -21
  5. sarvamai/core/client_wrapper.py +19 -3
  6. sarvamai/core/force_multipart.py +4 -2
  7. sarvamai/core/http_client.py +217 -97
  8. sarvamai/core/http_response.py +1 -1
  9. sarvamai/core/http_sse/__init__.py +42 -0
  10. sarvamai/core/http_sse/_api.py +112 -0
  11. sarvamai/core/http_sse/_decoders.py +61 -0
  12. sarvamai/core/http_sse/_exceptions.py +7 -0
  13. sarvamai/core/http_sse/_models.py +17 -0
  14. sarvamai/core/jsonable_encoder.py +8 -0
  15. sarvamai/core/pydantic_utilities.py +110 -4
  16. sarvamai/errors/__init__.py +40 -6
  17. sarvamai/errors/bad_request_error.py +1 -1
  18. sarvamai/errors/forbidden_error.py +1 -1
  19. sarvamai/errors/internal_server_error.py +1 -1
  20. sarvamai/errors/service_unavailable_error.py +1 -1
  21. sarvamai/errors/too_many_requests_error.py +1 -1
  22. sarvamai/errors/unprocessable_entity_error.py +1 -1
  23. sarvamai/requests/__init__.py +150 -62
  24. sarvamai/requests/audio_data.py +0 -6
  25. sarvamai/requests/error_response_data.py +1 -1
  26. sarvamai/requests/file_signed_url_details.py +1 -1
  27. sarvamai/requests/speech_to_text_transcription_data.py +2 -2
  28. sarvamai/speech_to_text/raw_client.py +54 -52
  29. sarvamai/speech_to_text_job/raw_client.py +120 -120
  30. sarvamai/speech_to_text_streaming/__init__.py +38 -8
  31. sarvamai/speech_to_text_streaming/client.py +0 -13
  32. sarvamai/speech_to_text_streaming/raw_client.py +0 -13
  33. sarvamai/speech_to_text_streaming/types/__init__.py +36 -6
  34. sarvamai/speech_to_text_translate_job/raw_client.py +120 -120
  35. sarvamai/speech_to_text_translate_streaming/__init__.py +36 -7
  36. sarvamai/speech_to_text_translate_streaming/client.py +0 -13
  37. sarvamai/speech_to_text_translate_streaming/raw_client.py +0 -13
  38. sarvamai/speech_to_text_translate_streaming/types/__init__.py +36 -5
  39. sarvamai/text/client.py +0 -12
  40. sarvamai/text/raw_client.py +60 -72
  41. sarvamai/text_to_speech/client.py +18 -0
  42. sarvamai/text_to_speech/raw_client.py +38 -20
  43. sarvamai/text_to_speech_streaming/__init__.py +28 -1
  44. sarvamai/text_to_speech_streaming/types/__init__.py +30 -1
  45. sarvamai/types/__init__.py +222 -100
  46. sarvamai/types/audio_data.py +0 -6
  47. sarvamai/types/chat_completion_request_message.py +6 -2
  48. sarvamai/types/error_response_data.py +1 -1
  49. sarvamai/types/file_signed_url_details.py +1 -1
  50. sarvamai/types/speech_to_text_transcription_data.py +2 -2
  51. {sarvamai-0.1.22a4.dist-info → sarvamai-0.1.23a1.dist-info}/METADATA +2 -1
  52. {sarvamai-0.1.22a4.dist-info → sarvamai-0.1.23a1.dist-info}/RECORD +53 -51
  53. sarvamai/speech_to_text_streaming/types/speech_to_text_streaming_input_audio_codec.py +0 -33
  54. sarvamai/speech_to_text_translate_streaming/types/speech_to_text_translate_streaming_input_audio_codec.py +0 -33
  55. sarvamai/types/audio_data_input_audio_codec.py +0 -33
  56. {sarvamai-0.1.22a4.dist-info → sarvamai-0.1.23a1.dist-info}/WHEEL +0 -0
@@ -2,18 +2,48 @@
2
2
 
3
3
  # isort: skip_file
4
4
 
5
- from .types import (
6
- SpeechToTextStreamingFlushSignal,
7
- SpeechToTextStreamingHighVadSensitivity,
8
- SpeechToTextStreamingInputAudioCodec,
9
- SpeechToTextStreamingLanguageCode,
10
- SpeechToTextStreamingVadSignals,
11
- )
5
+ import typing
6
+ from importlib import import_module
7
+
8
+ if typing.TYPE_CHECKING:
9
+ from .types import (
10
+ SpeechToTextStreamingFlushSignal,
11
+ SpeechToTextStreamingHighVadSensitivity,
12
+ SpeechToTextStreamingLanguageCode,
13
+ SpeechToTextStreamingVadSignals,
14
+ )
15
+ _dynamic_imports: typing.Dict[str, str] = {
16
+ "SpeechToTextStreamingFlushSignal": ".types",
17
+ "SpeechToTextStreamingHighVadSensitivity": ".types",
18
+ "SpeechToTextStreamingLanguageCode": ".types",
19
+ "SpeechToTextStreamingVadSignals": ".types",
20
+ }
21
+
22
+
23
+ def __getattr__(attr_name: str) -> typing.Any:
24
+ module_name = _dynamic_imports.get(attr_name)
25
+ if module_name is None:
26
+ raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}")
27
+ try:
28
+ module = import_module(module_name, __package__)
29
+ if module_name == f".{attr_name}":
30
+ return module
31
+ else:
32
+ return getattr(module, attr_name)
33
+ except ImportError as e:
34
+ raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e
35
+ except AttributeError as e:
36
+ raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e
37
+
38
+
39
+ def __dir__():
40
+ lazy_attrs = list(_dynamic_imports.keys())
41
+ return sorted(lazy_attrs)
42
+
12
43
 
13
44
  __all__ = [
14
45
  "SpeechToTextStreamingFlushSignal",
15
46
  "SpeechToTextStreamingHighVadSensitivity",
16
- "SpeechToTextStreamingInputAudioCodec",
17
47
  "SpeechToTextStreamingLanguageCode",
18
48
  "SpeechToTextStreamingVadSignals",
19
49
  ]
@@ -13,7 +13,6 @@ from .raw_client import AsyncRawSpeechToTextStreamingClient, RawSpeechToTextStre
13
13
  from .socket_client import AsyncSpeechToTextStreamingSocketClient, SpeechToTextStreamingSocketClient
14
14
  from .types.speech_to_text_streaming_flush_signal import SpeechToTextStreamingFlushSignal
15
15
  from .types.speech_to_text_streaming_high_vad_sensitivity import SpeechToTextStreamingHighVadSensitivity
16
- from .types.speech_to_text_streaming_input_audio_codec import SpeechToTextStreamingInputAudioCodec
17
16
  from .types.speech_to_text_streaming_language_code import SpeechToTextStreamingLanguageCode
18
17
  from .types.speech_to_text_streaming_vad_signals import SpeechToTextStreamingVadSignals
19
18
 
@@ -44,7 +43,6 @@ class SpeechToTextStreamingClient:
44
43
  *,
45
44
  language_code: SpeechToTextStreamingLanguageCode,
46
45
  model: typing.Optional[typing.Literal["saarika:v2.5"]] = None,
47
- input_audio_codec: typing.Optional[SpeechToTextStreamingInputAudioCodec] = None,
48
46
  sample_rate: typing.Optional[str] = None,
49
47
  high_vad_sensitivity: typing.Optional[SpeechToTextStreamingHighVadSensitivity] = None,
50
48
  vad_signals: typing.Optional[SpeechToTextStreamingVadSignals] = None,
@@ -67,9 +65,6 @@ class SpeechToTextStreamingClient:
67
65
  model : typing.Optional[typing.Literal["saarika:v2.5"]]
68
66
  Speech to text model to use
69
67
 
70
- input_audio_codec : typing.Optional[SpeechToTextStreamingInputAudioCodec]
71
- Audio codec/format of the input file. Our API automatically detects all codec formats, but for PCM files specifically (pcm_s16le, pcm_l16, pcm_raw), you must pass this parameter. PCM files supports sample rate 16000 and 8000.
72
-
73
68
  sample_rate : typing.Optional[str]
74
69
  Audio sample rate for the WebSocket connection. When specified as a connection parameter, only 16kHz and 8kHz are supported. 8kHz is only available via this connection parameter. If not specified, defaults to 16kHz.
75
70
 
@@ -98,8 +93,6 @@ class SpeechToTextStreamingClient:
98
93
  query_params = query_params.add("language-code", language_code)
99
94
  if model is not None:
100
95
  query_params = query_params.add("model", model)
101
- if input_audio_codec is not None:
102
- query_params = query_params.add("input_audio_codec", input_audio_codec)
103
96
  if sample_rate is not None:
104
97
  query_params = query_params.add("sample_rate", sample_rate)
105
98
  if high_vad_sensitivity is not None:
@@ -153,7 +146,6 @@ class AsyncSpeechToTextStreamingClient:
153
146
  *,
154
147
  language_code: SpeechToTextStreamingLanguageCode,
155
148
  model: typing.Optional[typing.Literal["saarika:v2.5"]] = None,
156
- input_audio_codec: typing.Optional[SpeechToTextStreamingInputAudioCodec] = None,
157
149
  sample_rate: typing.Optional[str] = None,
158
150
  high_vad_sensitivity: typing.Optional[SpeechToTextStreamingHighVadSensitivity] = None,
159
151
  vad_signals: typing.Optional[SpeechToTextStreamingVadSignals] = None,
@@ -176,9 +168,6 @@ class AsyncSpeechToTextStreamingClient:
176
168
  model : typing.Optional[typing.Literal["saarika:v2.5"]]
177
169
  Speech to text model to use
178
170
 
179
- input_audio_codec : typing.Optional[SpeechToTextStreamingInputAudioCodec]
180
- Audio codec/format of the input file. Our API automatically detects all codec formats, but for PCM files specifically (pcm_s16le, pcm_l16, pcm_raw), you must pass this parameter. PCM files supports sample rate 16000 and 8000.
181
-
182
171
  sample_rate : typing.Optional[str]
183
172
  Audio sample rate for the WebSocket connection. When specified as a connection parameter, only 16kHz and 8kHz are supported. 8kHz is only available via this connection parameter. If not specified, defaults to 16kHz.
184
173
 
@@ -207,8 +196,6 @@ class AsyncSpeechToTextStreamingClient:
207
196
  query_params = query_params.add("language-code", language_code)
208
197
  if model is not None:
209
198
  query_params = query_params.add("model", model)
210
- if input_audio_codec is not None:
211
- query_params = query_params.add("input_audio_codec", input_audio_codec)
212
199
  if sample_rate is not None:
213
200
  query_params = query_params.add("sample_rate", sample_rate)
214
201
  if high_vad_sensitivity is not None:
@@ -12,7 +12,6 @@ from ..core.request_options import RequestOptions
12
12
  from .socket_client import AsyncSpeechToTextStreamingSocketClient, SpeechToTextStreamingSocketClient
13
13
  from .types.speech_to_text_streaming_flush_signal import SpeechToTextStreamingFlushSignal
14
14
  from .types.speech_to_text_streaming_high_vad_sensitivity import SpeechToTextStreamingHighVadSensitivity
15
- from .types.speech_to_text_streaming_input_audio_codec import SpeechToTextStreamingInputAudioCodec
16
15
  from .types.speech_to_text_streaming_language_code import SpeechToTextStreamingLanguageCode
17
16
  from .types.speech_to_text_streaming_vad_signals import SpeechToTextStreamingVadSignals
18
17
 
@@ -32,7 +31,6 @@ class RawSpeechToTextStreamingClient:
32
31
  *,
33
32
  language_code: SpeechToTextStreamingLanguageCode,
34
33
  model: typing.Optional[typing.Literal["saarika:v2.5"]] = None,
35
- input_audio_codec: typing.Optional[SpeechToTextStreamingInputAudioCodec] = None,
36
34
  sample_rate: typing.Optional[str] = None,
37
35
  high_vad_sensitivity: typing.Optional[SpeechToTextStreamingHighVadSensitivity] = None,
38
36
  vad_signals: typing.Optional[SpeechToTextStreamingVadSignals] = None,
@@ -55,9 +53,6 @@ class RawSpeechToTextStreamingClient:
55
53
  model : typing.Optional[typing.Literal["saarika:v2.5"]]
56
54
  Speech to text model to use
57
55
 
58
- input_audio_codec : typing.Optional[SpeechToTextStreamingInputAudioCodec]
59
- Audio codec/format of the input file. Our API automatically detects all codec formats, but for PCM files specifically (pcm_s16le, pcm_l16, pcm_raw), you must pass this parameter. PCM files supports sample rate 16000 and 8000.
60
-
61
56
  sample_rate : typing.Optional[str]
62
57
  Audio sample rate for the WebSocket connection. When specified as a connection parameter, only 16kHz and 8kHz are supported. 8kHz is only available via this connection parameter. If not specified, defaults to 16kHz.
63
58
 
@@ -86,8 +81,6 @@ class RawSpeechToTextStreamingClient:
86
81
  query_params = query_params.add("language-code", language_code)
87
82
  if model is not None:
88
83
  query_params = query_params.add("model", model)
89
- if input_audio_codec is not None:
90
- query_params = query_params.add("input_audio_codec", input_audio_codec)
91
84
  if sample_rate is not None:
92
85
  query_params = query_params.add("sample_rate", sample_rate)
93
86
  if high_vad_sensitivity is not None:
@@ -130,7 +123,6 @@ class AsyncRawSpeechToTextStreamingClient:
130
123
  *,
131
124
  language_code: SpeechToTextStreamingLanguageCode,
132
125
  model: typing.Optional[typing.Literal["saarika:v2.5"]] = None,
133
- input_audio_codec: typing.Optional[SpeechToTextStreamingInputAudioCodec] = None,
134
126
  sample_rate: typing.Optional[str] = None,
135
127
  high_vad_sensitivity: typing.Optional[SpeechToTextStreamingHighVadSensitivity] = None,
136
128
  vad_signals: typing.Optional[SpeechToTextStreamingVadSignals] = None,
@@ -153,9 +145,6 @@ class AsyncRawSpeechToTextStreamingClient:
153
145
  model : typing.Optional[typing.Literal["saarika:v2.5"]]
154
146
  Speech to text model to use
155
147
 
156
- input_audio_codec : typing.Optional[SpeechToTextStreamingInputAudioCodec]
157
- Audio codec/format of the input file. Our API automatically detects all codec formats, but for PCM files specifically (pcm_s16le, pcm_l16, pcm_raw), you must pass this parameter. PCM files supports sample rate 16000 and 8000.
158
-
159
148
  sample_rate : typing.Optional[str]
160
149
  Audio sample rate for the WebSocket connection. When specified as a connection parameter, only 16kHz and 8kHz are supported. 8kHz is only available via this connection parameter. If not specified, defaults to 16kHz.
161
150
 
@@ -184,8 +173,6 @@ class AsyncRawSpeechToTextStreamingClient:
184
173
  query_params = query_params.add("language-code", language_code)
185
174
  if model is not None:
186
175
  query_params = query_params.add("model", model)
187
- if input_audio_codec is not None:
188
- query_params = query_params.add("input_audio_codec", input_audio_codec)
189
176
  if sample_rate is not None:
190
177
  query_params = query_params.add("sample_rate", sample_rate)
191
178
  if high_vad_sensitivity is not None:
@@ -2,16 +2,46 @@
2
2
 
3
3
  # isort: skip_file
4
4
 
5
- from .speech_to_text_streaming_flush_signal import SpeechToTextStreamingFlushSignal
6
- from .speech_to_text_streaming_high_vad_sensitivity import SpeechToTextStreamingHighVadSensitivity
7
- from .speech_to_text_streaming_input_audio_codec import SpeechToTextStreamingInputAudioCodec
8
- from .speech_to_text_streaming_language_code import SpeechToTextStreamingLanguageCode
9
- from .speech_to_text_streaming_vad_signals import SpeechToTextStreamingVadSignals
5
+ import typing
6
+ from importlib import import_module
7
+
8
+ if typing.TYPE_CHECKING:
9
+ from .speech_to_text_streaming_flush_signal import SpeechToTextStreamingFlushSignal
10
+ from .speech_to_text_streaming_high_vad_sensitivity import SpeechToTextStreamingHighVadSensitivity
11
+ from .speech_to_text_streaming_language_code import SpeechToTextStreamingLanguageCode
12
+ from .speech_to_text_streaming_vad_signals import SpeechToTextStreamingVadSignals
13
+ _dynamic_imports: typing.Dict[str, str] = {
14
+ "SpeechToTextStreamingFlushSignal": ".speech_to_text_streaming_flush_signal",
15
+ "SpeechToTextStreamingHighVadSensitivity": ".speech_to_text_streaming_high_vad_sensitivity",
16
+ "SpeechToTextStreamingLanguageCode": ".speech_to_text_streaming_language_code",
17
+ "SpeechToTextStreamingVadSignals": ".speech_to_text_streaming_vad_signals",
18
+ }
19
+
20
+
21
+ def __getattr__(attr_name: str) -> typing.Any:
22
+ module_name = _dynamic_imports.get(attr_name)
23
+ if module_name is None:
24
+ raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}")
25
+ try:
26
+ module = import_module(module_name, __package__)
27
+ if module_name == f".{attr_name}":
28
+ return module
29
+ else:
30
+ return getattr(module, attr_name)
31
+ except ImportError as e:
32
+ raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e
33
+ except AttributeError as e:
34
+ raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e
35
+
36
+
37
+ def __dir__():
38
+ lazy_attrs = list(_dynamic_imports.keys())
39
+ return sorted(lazy_attrs)
40
+
10
41
 
11
42
  __all__ = [
12
43
  "SpeechToTextStreamingFlushSignal",
13
44
  "SpeechToTextStreamingHighVadSensitivity",
14
- "SpeechToTextStreamingInputAudioCodec",
15
45
  "SpeechToTextStreamingLanguageCode",
16
46
  "SpeechToTextStreamingVadSignals",
17
47
  ]