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
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
|
2
2
|
|
|
3
|
+
import typing
|
|
4
|
+
|
|
3
5
|
from ..core.api_error import ApiError
|
|
4
6
|
from ..types.error_message import ErrorMessage
|
|
5
7
|
|
|
6
8
|
|
|
7
9
|
class ServiceUnavailableError(ApiError):
|
|
8
|
-
def __init__(self, body: ErrorMessage):
|
|
9
|
-
super().__init__(status_code=503, body=body)
|
|
10
|
+
def __init__(self, body: ErrorMessage, headers: typing.Optional[typing.Dict[str, str]] = None):
|
|
11
|
+
super().__init__(status_code=503, headers=headers, body=body)
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
|
2
2
|
|
|
3
|
-
from ..core.api_error import ApiError
|
|
4
3
|
import typing
|
|
5
4
|
|
|
5
|
+
from ..core.api_error import ApiError
|
|
6
|
+
|
|
6
7
|
|
|
7
8
|
class TooManyRequestsError(ApiError):
|
|
8
|
-
def __init__(self, body: typing.Optional[typing.Any]):
|
|
9
|
-
super().__init__(status_code=429, body=body)
|
|
9
|
+
def __init__(self, body: typing.Optional[typing.Any], headers: typing.Optional[typing.Dict[str, str]] = None):
|
|
10
|
+
super().__init__(status_code=429, headers=headers, body=body)
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
|
2
2
|
|
|
3
|
-
from ..core.api_error import ApiError
|
|
4
3
|
import typing
|
|
5
4
|
|
|
5
|
+
from ..core.api_error import ApiError
|
|
6
|
+
|
|
6
7
|
|
|
7
8
|
class UnprocessableEntityError(ApiError):
|
|
8
|
-
def __init__(self, body: typing.Optional[typing.Any]):
|
|
9
|
-
super().__init__(status_code=422, body=body)
|
|
9
|
+
def __init__(self, body: typing.Optional[typing.Any], headers: typing.Optional[typing.Dict[str, str]] = None):
|
|
10
|
+
super().__init__(status_code=422, headers=headers, body=body)
|
sarvamai/requests/__init__.py
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
|
2
2
|
|
|
3
|
+
# isort: skip_file
|
|
4
|
+
|
|
5
|
+
from .audio_data import AudioDataParams
|
|
6
|
+
from .audio_message import AudioMessageParams
|
|
3
7
|
from .chat_completion_request_assistant_message import ChatCompletionRequestAssistantMessageParams
|
|
4
8
|
from .chat_completion_request_message import (
|
|
5
9
|
ChatCompletionRequestMessageParams,
|
|
@@ -15,18 +19,26 @@ from .completion_usage import CompletionUsageParams
|
|
|
15
19
|
from .create_chat_completion_response import CreateChatCompletionResponseParams
|
|
16
20
|
from .diarized_entry import DiarizedEntryParams
|
|
17
21
|
from .diarized_transcript import DiarizedTranscriptParams
|
|
22
|
+
from .error_data import ErrorDataParams
|
|
18
23
|
from .error_details import ErrorDetailsParams
|
|
19
24
|
from .error_message import ErrorMessageParams
|
|
25
|
+
from .events_data import EventsDataParams
|
|
20
26
|
from .language_identification_response import LanguageIdentificationResponseParams
|
|
21
27
|
from .speech_to_text_response import SpeechToTextResponseParams
|
|
28
|
+
from .speech_to_text_streaming_response import SpeechToTextStreamingResponseParams
|
|
29
|
+
from .speech_to_text_streaming_response_data import SpeechToTextStreamingResponseDataParams
|
|
22
30
|
from .speech_to_text_translate_response import SpeechToTextTranslateResponseParams
|
|
23
31
|
from .stop_configuration import StopConfigurationParams
|
|
24
32
|
from .text_to_speech_response import TextToSpeechResponseParams
|
|
25
33
|
from .timestamps_model import TimestampsModelParams
|
|
34
|
+
from .transcription_data import TranscriptionDataParams
|
|
35
|
+
from .transcription_metrics import TranscriptionMetricsParams
|
|
26
36
|
from .translation_response import TranslationResponseParams
|
|
27
37
|
from .transliteration_response import TransliterationResponseParams
|
|
28
38
|
|
|
29
39
|
__all__ = [
|
|
40
|
+
"AudioDataParams",
|
|
41
|
+
"AudioMessageParams",
|
|
30
42
|
"ChatCompletionRequestAssistantMessageParams",
|
|
31
43
|
"ChatCompletionRequestMessageParams",
|
|
32
44
|
"ChatCompletionRequestMessage_AssistantParams",
|
|
@@ -40,14 +52,20 @@ __all__ = [
|
|
|
40
52
|
"CreateChatCompletionResponseParams",
|
|
41
53
|
"DiarizedEntryParams",
|
|
42
54
|
"DiarizedTranscriptParams",
|
|
55
|
+
"ErrorDataParams",
|
|
43
56
|
"ErrorDetailsParams",
|
|
44
57
|
"ErrorMessageParams",
|
|
58
|
+
"EventsDataParams",
|
|
45
59
|
"LanguageIdentificationResponseParams",
|
|
46
60
|
"SpeechToTextResponseParams",
|
|
61
|
+
"SpeechToTextStreamingResponseDataParams",
|
|
62
|
+
"SpeechToTextStreamingResponseParams",
|
|
47
63
|
"SpeechToTextTranslateResponseParams",
|
|
48
64
|
"StopConfigurationParams",
|
|
49
65
|
"TextToSpeechResponseParams",
|
|
50
66
|
"TimestampsModelParams",
|
|
67
|
+
"TranscriptionDataParams",
|
|
68
|
+
"TranscriptionMetricsParams",
|
|
51
69
|
"TranslationResponseParams",
|
|
52
70
|
"TransliterationResponseParams",
|
|
53
71
|
]
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing_extensions
|
|
4
|
+
from ..types.audio_data_encoding import AudioDataEncoding
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class AudioDataParams(typing_extensions.TypedDict):
|
|
8
|
+
data: str
|
|
9
|
+
"""
|
|
10
|
+
Base64 encoded audio data
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
sample_rate: int
|
|
14
|
+
"""
|
|
15
|
+
Audio sample rate in Hz (16kHz preferred, 8kHz least preferred)
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
encoding: AudioDataEncoding
|
|
19
|
+
"""
|
|
20
|
+
Audio encoding format
|
|
21
|
+
"""
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
|
-
|
|
4
|
+
|
|
5
5
|
import typing
|
|
6
6
|
|
|
7
|
+
import typing_extensions
|
|
8
|
+
|
|
7
9
|
|
|
8
10
|
class ChatCompletionRequestMessage_AssistantParams(typing_extensions.TypedDict):
|
|
9
11
|
role: typing.Literal["assistant"]
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
|
2
2
|
|
|
3
|
-
import typing_extensions
|
|
4
3
|
import typing
|
|
5
|
-
|
|
4
|
+
|
|
6
5
|
import typing_extensions
|
|
6
|
+
from .choice import ChoiceParams
|
|
7
7
|
from .completion_usage import CompletionUsageParams
|
|
8
8
|
|
|
9
9
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import datetime as dt
|
|
4
|
+
|
|
5
|
+
import typing_extensions
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class EventsDataParams(typing_extensions.TypedDict):
|
|
9
|
+
event_type: str
|
|
10
|
+
"""
|
|
11
|
+
Type of event
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
timestamp: dt.datetime
|
|
15
|
+
"""
|
|
16
|
+
Event timestamp
|
|
17
|
+
"""
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
|
2
2
|
|
|
3
3
|
import typing_extensions
|
|
4
|
-
import typing_extensions
|
|
5
|
-
from .timestamps_model import TimestampsModelParams
|
|
6
4
|
from .diarized_transcript import DiarizedTranscriptParams
|
|
5
|
+
from .timestamps_model import TimestampsModelParams
|
|
7
6
|
|
|
8
7
|
|
|
9
8
|
class SpeechToTextResponseParams(typing_extensions.TypedDict):
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing_extensions
|
|
4
|
+
from ..types.speech_to_text_streaming_response_type import SpeechToTextStreamingResponseType
|
|
5
|
+
from .speech_to_text_streaming_response_data import SpeechToTextStreamingResponseDataParams
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class SpeechToTextStreamingResponseParams(typing_extensions.TypedDict):
|
|
9
|
+
type: SpeechToTextStreamingResponseType
|
|
10
|
+
data: SpeechToTextStreamingResponseDataParams
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
from .error_data import ErrorDataParams
|
|
6
|
+
from .events_data import EventsDataParams
|
|
7
|
+
from .transcription_data import TranscriptionDataParams
|
|
8
|
+
|
|
9
|
+
SpeechToTextStreamingResponseDataParams = typing.Union[TranscriptionDataParams, ErrorDataParams, EventsDataParams]
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
|
2
2
|
|
|
3
|
-
import typing_extensions
|
|
4
|
-
import typing_extensions
|
|
5
3
|
import typing
|
|
6
4
|
|
|
5
|
+
import typing_extensions
|
|
6
|
+
|
|
7
7
|
|
|
8
8
|
class TextToSpeechResponseParams(typing_extensions.TypedDict):
|
|
9
9
|
request_id: typing_extensions.NotRequired[str]
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
import typing_extensions
|
|
6
|
+
from .transcription_metrics import TranscriptionMetricsParams
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class TranscriptionDataParams(typing_extensions.TypedDict):
|
|
10
|
+
request_id: str
|
|
11
|
+
"""
|
|
12
|
+
Unique identifier for the request
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
transcript: str
|
|
16
|
+
"""
|
|
17
|
+
Transcript of the provided speech
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
timestamps: typing_extensions.NotRequired[typing.Dict[str, typing.Optional[typing.Any]]]
|
|
21
|
+
"""
|
|
22
|
+
Timestamp information (if available)
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
diarized_transcript: typing_extensions.NotRequired[typing.Dict[str, typing.Optional[typing.Any]]]
|
|
26
|
+
"""
|
|
27
|
+
Diarized transcript of the provided speech
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
language_code: typing_extensions.NotRequired[str]
|
|
31
|
+
"""
|
|
32
|
+
BCP-47 code of detected language
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
metrics: TranscriptionMetricsParams
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing_extensions
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class TranscriptionMetricsParams(typing_extensions.TypedDict):
|
|
7
|
+
audio_duration: float
|
|
8
|
+
"""
|
|
9
|
+
Duration of processed audio in seconds
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
processing_latency: float
|
|
13
|
+
"""
|
|
14
|
+
Processing latency in seconds
|
|
15
|
+
"""
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
|
2
2
|
|
|
3
3
|
import typing
|
|
4
|
-
|
|
5
|
-
from .raw_client import RawSpeechToTextClient
|
|
4
|
+
|
|
6
5
|
from .. import core
|
|
7
|
-
from ..
|
|
8
|
-
from ..types.speech_to_text_language import SpeechToTextLanguage
|
|
6
|
+
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
9
7
|
from ..core.request_options import RequestOptions
|
|
8
|
+
from ..types.speech_to_text_language import SpeechToTextLanguage
|
|
9
|
+
from ..types.speech_to_text_model import SpeechToTextModel
|
|
10
10
|
from ..types.speech_to_text_response import SpeechToTextResponse
|
|
11
11
|
from ..types.speech_to_text_translate_model import SpeechToTextTranslateModel
|
|
12
12
|
from ..types.speech_to_text_translate_response import SpeechToTextTranslateResponse
|
|
13
|
-
from
|
|
14
|
-
from .raw_client import AsyncRawSpeechToTextClient
|
|
13
|
+
from .raw_client import AsyncRawSpeechToTextClient, RawSpeechToTextClient
|
|
15
14
|
|
|
16
15
|
# this is used as the default value for optional parameters
|
|
17
16
|
OMIT = typing.cast(typing.Any, ...)
|
|
@@ -88,10 +87,10 @@ class SpeechToTextClient:
|
|
|
88
87
|
)
|
|
89
88
|
client.speech_to_text.transcribe()
|
|
90
89
|
"""
|
|
91
|
-
|
|
90
|
+
_response = self._raw_client.transcribe(
|
|
92
91
|
file=file, model=model, language_code=language_code, request_options=request_options
|
|
93
92
|
)
|
|
94
|
-
return
|
|
93
|
+
return _response.data
|
|
95
94
|
|
|
96
95
|
def translate(
|
|
97
96
|
self,
|
|
@@ -144,8 +143,8 @@ class SpeechToTextClient:
|
|
|
144
143
|
)
|
|
145
144
|
client.speech_to_text.translate()
|
|
146
145
|
"""
|
|
147
|
-
|
|
148
|
-
return
|
|
146
|
+
_response = self._raw_client.translate(file=file, prompt=prompt, model=model, request_options=request_options)
|
|
147
|
+
return _response.data
|
|
149
148
|
|
|
150
149
|
|
|
151
150
|
class AsyncSpeechToTextClient:
|
|
@@ -227,10 +226,10 @@ class AsyncSpeechToTextClient:
|
|
|
227
226
|
|
|
228
227
|
asyncio.run(main())
|
|
229
228
|
"""
|
|
230
|
-
|
|
229
|
+
_response = await self._raw_client.transcribe(
|
|
231
230
|
file=file, model=model, language_code=language_code, request_options=request_options
|
|
232
231
|
)
|
|
233
|
-
return
|
|
232
|
+
return _response.data
|
|
234
233
|
|
|
235
234
|
async def translate(
|
|
236
235
|
self,
|
|
@@ -291,7 +290,7 @@ class AsyncSpeechToTextClient:
|
|
|
291
290
|
|
|
292
291
|
asyncio.run(main())
|
|
293
292
|
"""
|
|
294
|
-
|
|
293
|
+
_response = await self._raw_client.translate(
|
|
295
294
|
file=file, prompt=prompt, model=model, request_options=request_options
|
|
296
295
|
)
|
|
297
|
-
return
|
|
296
|
+
return _response.data
|