sarvamai 0.1.5a12__tar.gz → 0.1.5a13__tar.gz
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-0.1.5a12 → sarvamai-0.1.5a13}/PKG-INFO +1 -1
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/pyproject.toml +1 -1
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/core/client_wrapper.py +2 -2
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/speech_to_text_streaming/socket_client.py +35 -5
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/speech_to_text_translate_streaming/socket_client.py +63 -16
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/README.md +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/__init__.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/chat/__init__.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/chat/client.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/chat/raw_client.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/client.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/core/__init__.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/core/api_error.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/core/datetime_utils.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/core/events.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/core/file.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/core/force_multipart.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/core/http_client.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/core/http_response.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/core/jsonable_encoder.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/core/pydantic_utilities.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/core/query_encoder.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/core/remove_none_from_dict.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/core/request_options.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/core/serialization.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/environment.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/errors/__init__.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/errors/bad_request_error.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/errors/forbidden_error.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/errors/internal_server_error.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/errors/service_unavailable_error.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/errors/too_many_requests_error.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/errors/unprocessable_entity_error.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/play.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/py.typed +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/requests/__init__.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/requests/audio_data.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/requests/audio_message.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/requests/chat_completion_request_assistant_message.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/requests/chat_completion_request_message.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/requests/chat_completion_request_system_message.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/requests/chat_completion_request_user_message.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/requests/chat_completion_response_message.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/requests/choice.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/requests/completion_usage.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/requests/config_message.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/requests/create_chat_completion_response.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/requests/diarized_entry.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/requests/diarized_transcript.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/requests/error_data.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/requests/error_details.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/requests/error_message.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/requests/events_data.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/requests/language_identification_response.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/requests/speech_to_text_response.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/requests/speech_to_text_response_data.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/requests/speech_to_text_streaming_response.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/requests/speech_to_text_transcription_data.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/requests/speech_to_text_translate_response.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/requests/speech_to_text_translate_response_data.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/requests/speech_to_text_translate_streaming_response.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/requests/speech_to_text_translate_transcription_data.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/requests/stop_configuration.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/requests/text_to_speech_response.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/requests/timestamps_model.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/requests/transcription_metrics.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/requests/translation_response.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/requests/transliteration_response.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/speech_to_text/__init__.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/speech_to_text/client.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/speech_to_text/raw_client.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/speech_to_text_streaming/__init__.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/speech_to_text_streaming/client.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/speech_to_text_streaming/raw_client.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/speech_to_text_streaming/types/__init__.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/speech_to_text_streaming/types/speech_to_text_streaming_language_code.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/speech_to_text_streaming/types/speech_to_text_streaming_model.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/speech_to_text_translate_streaming/__init__.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/speech_to_text_translate_streaming/client.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/speech_to_text_translate_streaming/raw_client.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/speech_to_text_translate_streaming/types/__init__.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/speech_to_text_translate_streaming/types/speech_to_text_translate_streaming_model.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/text/__init__.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/text/client.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/text/raw_client.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/text_to_speech/__init__.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/text_to_speech/client.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/text_to_speech/raw_client.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/__init__.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/audio_data.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/audio_data_encoding.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/audio_message.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/chat_completion_request_assistant_message.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/chat_completion_request_message.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/chat_completion_request_system_message.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/chat_completion_request_user_message.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/chat_completion_response_message.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/choice.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/completion_usage.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/config_message.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/create_chat_completion_response.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/diarized_entry.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/diarized_transcript.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/error_code.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/error_data.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/error_details.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/error_message.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/events_data.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/finish_reason.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/format.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/language_identification_response.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/numerals_format.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/reasoning_effort.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/response_type.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/role.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/sarvam_model_ids.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/speech_sample_rate.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/speech_to_text_language.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/speech_to_text_model.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/speech_to_text_response.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/speech_to_text_response_data.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/speech_to_text_streaming_response.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/speech_to_text_transcription_data.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/speech_to_text_translate_language.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/speech_to_text_translate_model.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/speech_to_text_translate_response.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/speech_to_text_translate_response_data.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/speech_to_text_translate_streaming_response.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/speech_to_text_translate_transcription_data.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/spoken_form_numerals_format.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/stop_configuration.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/text_to_speech_language.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/text_to_speech_model.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/text_to_speech_response.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/text_to_speech_speaker.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/timestamps_model.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/transcription_metrics.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/translate_mode.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/translate_model.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/translate_source_language.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/translate_speaker_gender.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/translate_target_language.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/translation_response.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/translatiterate_target_language.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/transliterate_mode.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/transliterate_source_language.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/transliteration_response.py +0 -0
- {sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/version.py +0 -0
|
@@ -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.5a13",
|
|
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.5a13",
|
|
24
24
|
}
|
|
25
25
|
headers["api-subscription-key"] = self.api_subscription_key
|
|
26
26
|
return headers
|
{sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/speech_to_text_streaming/socket_client.py
RENAMED
|
@@ -7,6 +7,7 @@ import websockets
|
|
|
7
7
|
import websockets.sync.connection as websockets_sync_connection
|
|
8
8
|
from ..core.events import EventEmitterMixin, EventType
|
|
9
9
|
from ..core.pydantic_utilities import parse_obj_as
|
|
10
|
+
from ..types.audio_data import AudioData
|
|
10
11
|
from ..types.audio_message import AudioMessage
|
|
11
12
|
from ..types.speech_to_text_streaming_response import SpeechToTextStreamingResponse
|
|
12
13
|
|
|
@@ -20,6 +21,7 @@ class AsyncSpeechToTextStreamingSocketClient(EventEmitterMixin):
|
|
|
20
21
|
|
|
21
22
|
async def __aiter__(self):
|
|
22
23
|
async for message in self._websocket:
|
|
24
|
+
message = json.loads(message) if isinstance(message, str) else message
|
|
23
25
|
yield parse_obj_as(SpeechToTextStreamingSocketClientResponse, message) # type: ignore
|
|
24
26
|
|
|
25
27
|
async def start_listening(self):
|
|
@@ -35,6 +37,7 @@ class AsyncSpeechToTextStreamingSocketClient(EventEmitterMixin):
|
|
|
35
37
|
self._emit(EventType.OPEN, None)
|
|
36
38
|
try:
|
|
37
39
|
async for raw_message in self._websocket:
|
|
40
|
+
raw_message = json.loads(raw_message) if isinstance(raw_message, str) else raw_message
|
|
38
41
|
parsed = parse_obj_as(SpeechToTextStreamingSocketClientResponse, raw_message) # type: ignore
|
|
39
42
|
self._emit(EventType.MESSAGE, parsed)
|
|
40
43
|
except websockets.WebSocketException as exc:
|
|
@@ -42,7 +45,19 @@ class AsyncSpeechToTextStreamingSocketClient(EventEmitterMixin):
|
|
|
42
45
|
finally:
|
|
43
46
|
self._emit(EventType.CLOSE, None)
|
|
44
47
|
|
|
45
|
-
async def
|
|
48
|
+
async def transcribe(self, audio: str, encoding="audio/wav", sample_rate=16000):
|
|
49
|
+
"""
|
|
50
|
+
Sends transcription request to the server.
|
|
51
|
+
:param audio: Base64 encoded audio data
|
|
52
|
+
:param encoding: Audio encoding format (default is "audio/wav")
|
|
53
|
+
:param sample_rate: Audio sample rate in Hz (default is 16000)
|
|
54
|
+
"""
|
|
55
|
+
|
|
56
|
+
return await self._send_speech_to_text_streaming_audio_message(
|
|
57
|
+
message=AudioMessage(audio=AudioData(data=audio, sample_rate=sample_rate, encoding=encoding))
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
async def _send_speech_to_text_streaming_audio_message(self, message: AudioMessage) -> None:
|
|
46
61
|
"""
|
|
47
62
|
Send a message to the websocket connection.
|
|
48
63
|
The message will be sent as a AudioMessage.
|
|
@@ -54,6 +69,7 @@ class AsyncSpeechToTextStreamingSocketClient(EventEmitterMixin):
|
|
|
54
69
|
Receive a message from the websocket connection.
|
|
55
70
|
"""
|
|
56
71
|
data = await self._websocket.recv()
|
|
72
|
+
data = json.loads(data) if isinstance(data, str) else data
|
|
57
73
|
return parse_obj_as(SpeechToTextStreamingSocketClientResponse, data) # type: ignore
|
|
58
74
|
|
|
59
75
|
async def _send(self, data: typing.Any) -> None:
|
|
@@ -78,6 +94,7 @@ class SpeechToTextStreamingSocketClient(EventEmitterMixin):
|
|
|
78
94
|
|
|
79
95
|
def __iter__(self):
|
|
80
96
|
for message in self._websocket:
|
|
97
|
+
message = json.loads(message) if isinstance(message, str) else message
|
|
81
98
|
yield parse_obj_as(SpeechToTextStreamingSocketClientResponse, message) # type: ignore
|
|
82
99
|
|
|
83
100
|
def start_listening(self):
|
|
@@ -93,6 +110,7 @@ class SpeechToTextStreamingSocketClient(EventEmitterMixin):
|
|
|
93
110
|
self._emit(EventType.OPEN, None)
|
|
94
111
|
try:
|
|
95
112
|
for raw_message in self._websocket:
|
|
113
|
+
raw_message = json.loads(raw_message) if isinstance(raw_message, str) else raw_message
|
|
96
114
|
parsed = parse_obj_as(SpeechToTextStreamingSocketClientResponse, raw_message) # type: ignore
|
|
97
115
|
self._emit(EventType.MESSAGE, parsed)
|
|
98
116
|
except websockets.WebSocketException as exc:
|
|
@@ -100,20 +118,32 @@ class SpeechToTextStreamingSocketClient(EventEmitterMixin):
|
|
|
100
118
|
finally:
|
|
101
119
|
self._emit(EventType.CLOSE, None)
|
|
102
120
|
|
|
103
|
-
def
|
|
121
|
+
def transcribe(self, audio: str, encoding="audio/wav", sample_rate=16000) -> None:
|
|
104
122
|
"""
|
|
105
|
-
|
|
106
|
-
|
|
123
|
+
Sends transcription request to the server.
|
|
124
|
+
:param audio: Base64 encoded audio data
|
|
125
|
+
:param encoding (Optional): Audio encoding format (default is "audio/wav")
|
|
126
|
+
:param sample_rate (Optional): Audio sample rate in Hz (default is 16000)
|
|
107
127
|
"""
|
|
108
|
-
self.
|
|
128
|
+
return self._send_speech_to_text_streaming_audio_message(
|
|
129
|
+
message=AudioMessage(audio=AudioData(data=audio, sample_rate=sample_rate, encoding=encoding))
|
|
130
|
+
)
|
|
109
131
|
|
|
110
132
|
def recv(self) -> SpeechToTextStreamingSocketClientResponse:
|
|
111
133
|
"""
|
|
112
134
|
Receive a message from the websocket connection.
|
|
113
135
|
"""
|
|
114
136
|
data = self._websocket.recv()
|
|
137
|
+
data = json.loads(data) if isinstance(data, str) else data
|
|
115
138
|
return parse_obj_as(SpeechToTextStreamingSocketClientResponse, data) # type: ignore
|
|
116
139
|
|
|
140
|
+
def _send_speech_to_text_streaming_audio_message(self, message: AudioMessage) -> None:
|
|
141
|
+
"""
|
|
142
|
+
Send a message to the websocket connection.
|
|
143
|
+
The message will be sent as a AudioMessage.
|
|
144
|
+
"""
|
|
145
|
+
self._send_model(message)
|
|
146
|
+
|
|
117
147
|
def _send(self, data: typing.Any) -> None:
|
|
118
148
|
"""
|
|
119
149
|
Send a message to the websocket connection.
|
|
@@ -7,6 +7,7 @@ import websockets
|
|
|
7
7
|
import websockets.sync.connection as websockets_sync_connection
|
|
8
8
|
from ..core.events import EventEmitterMixin, EventType
|
|
9
9
|
from ..core.pydantic_utilities import parse_obj_as
|
|
10
|
+
from ..types.audio_data import AudioData
|
|
10
11
|
from ..types.audio_message import AudioMessage
|
|
11
12
|
from ..types.config_message import ConfigMessage
|
|
12
13
|
from ..types.speech_to_text_translate_streaming_response import SpeechToTextTranslateStreamingResponse
|
|
@@ -21,6 +22,7 @@ class AsyncSpeechToTextTranslateStreamingSocketClient(EventEmitterMixin):
|
|
|
21
22
|
|
|
22
23
|
async def __aiter__(self):
|
|
23
24
|
async for message in self._websocket:
|
|
25
|
+
message = json.loads(message) if isinstance(message, str) else message
|
|
24
26
|
yield parse_obj_as(SpeechToTextTranslateStreamingSocketClientResponse, message) # type: ignore
|
|
25
27
|
|
|
26
28
|
async def start_listening(self):
|
|
@@ -36,6 +38,7 @@ class AsyncSpeechToTextTranslateStreamingSocketClient(EventEmitterMixin):
|
|
|
36
38
|
self._emit(EventType.OPEN, None)
|
|
37
39
|
try:
|
|
38
40
|
async for raw_message in self._websocket:
|
|
41
|
+
raw_message = json.loads(raw_message) if isinstance(raw_message, str) else raw_message
|
|
39
42
|
parsed = parse_obj_as(SpeechToTextTranslateStreamingSocketClientResponse, raw_message) # type: ignore
|
|
40
43
|
self._emit(EventType.MESSAGE, parsed)
|
|
41
44
|
except websockets.WebSocketException as exc:
|
|
@@ -43,27 +46,48 @@ class AsyncSpeechToTextTranslateStreamingSocketClient(EventEmitterMixin):
|
|
|
43
46
|
finally:
|
|
44
47
|
self._emit(EventType.CLOSE, None)
|
|
45
48
|
|
|
46
|
-
async def
|
|
49
|
+
async def translate(self, audio: str, encoding: str = "audio/wav", sample_rate: int = 16000):
|
|
47
50
|
"""
|
|
48
|
-
|
|
49
|
-
|
|
51
|
+
Sends audio translation request to the server.
|
|
52
|
+
:param audio: Base64 encoded audio data
|
|
53
|
+
:param encoding (Optional): Audio encoding format (default is "audio/wav")
|
|
54
|
+
:param sample_rate (Optional): Audio sample rate in Hz (default is 16000)
|
|
50
55
|
"""
|
|
51
|
-
await self.
|
|
56
|
+
return await self._send_speech_to_text_translate_streaming_audio_message(
|
|
57
|
+
message=AudioMessage(audio=AudioData(data=audio, encoding=encoding, sample_rate=sample_rate))
|
|
58
|
+
)
|
|
52
59
|
|
|
53
|
-
async def
|
|
60
|
+
async def set_prompt(self, prompt: str) -> None:
|
|
54
61
|
"""
|
|
55
|
-
|
|
56
|
-
The
|
|
62
|
+
Set the prompt for the translation.
|
|
63
|
+
The prompt is useful for detecting hotwords in the audio stream.
|
|
64
|
+
This will send a ConfigMessage to the websocket connection.
|
|
57
65
|
"""
|
|
58
|
-
|
|
66
|
+
message = ConfigMessage(prompt=prompt)
|
|
67
|
+
await self._send_config_message(message)
|
|
59
68
|
|
|
60
69
|
async def recv(self) -> SpeechToTextTranslateStreamingSocketClientResponse:
|
|
61
70
|
"""
|
|
62
71
|
Receive a message from the websocket connection.
|
|
63
72
|
"""
|
|
64
73
|
data = await self._websocket.recv()
|
|
74
|
+
data = json.loads(data) if isinstance(data, str) else data
|
|
65
75
|
return parse_obj_as(SpeechToTextTranslateStreamingSocketClientResponse, data) # type: ignore
|
|
66
76
|
|
|
77
|
+
async def _send_speech_to_text_translate_streaming_audio_message(self, message: AudioMessage) -> None:
|
|
78
|
+
"""
|
|
79
|
+
Send a message to the websocket connection.
|
|
80
|
+
The message will be sent as a AudioMessage.
|
|
81
|
+
"""
|
|
82
|
+
await self._send_model(message)
|
|
83
|
+
|
|
84
|
+
async def _send_config_message(self, message: ConfigMessage) -> None:
|
|
85
|
+
"""
|
|
86
|
+
Send a message to the websocket connection.
|
|
87
|
+
The message will be sent as a ConfigMessage.
|
|
88
|
+
"""
|
|
89
|
+
await self._send_model(message)
|
|
90
|
+
|
|
67
91
|
async def _send(self, data: typing.Any) -> None:
|
|
68
92
|
"""
|
|
69
93
|
Send a message to the websocket connection.
|
|
@@ -86,6 +110,7 @@ class SpeechToTextTranslateStreamingSocketClient(EventEmitterMixin):
|
|
|
86
110
|
|
|
87
111
|
def __iter__(self):
|
|
88
112
|
for message in self._websocket:
|
|
113
|
+
message = json.loads(message) if isinstance(message, str) else message
|
|
89
114
|
yield parse_obj_as(SpeechToTextTranslateStreamingSocketClientResponse, message) # type: ignore
|
|
90
115
|
|
|
91
116
|
def start_listening(self):
|
|
@@ -101,6 +126,7 @@ class SpeechToTextTranslateStreamingSocketClient(EventEmitterMixin):
|
|
|
101
126
|
self._emit(EventType.OPEN, None)
|
|
102
127
|
try:
|
|
103
128
|
for raw_message in self._websocket:
|
|
129
|
+
raw_message = json.loads(raw_message) if isinstance(raw_message, str) else raw_message
|
|
104
130
|
parsed = parse_obj_as(SpeechToTextTranslateStreamingSocketClientResponse, raw_message) # type: ignore
|
|
105
131
|
self._emit(EventType.MESSAGE, parsed)
|
|
106
132
|
except websockets.WebSocketException as exc:
|
|
@@ -108,27 +134,48 @@ class SpeechToTextTranslateStreamingSocketClient(EventEmitterMixin):
|
|
|
108
134
|
finally:
|
|
109
135
|
self._emit(EventType.CLOSE, None)
|
|
110
136
|
|
|
111
|
-
def
|
|
137
|
+
def translate(self, audio: str, encoding: str = "audio/wav", sample_rate: int = 16000):
|
|
112
138
|
"""
|
|
113
|
-
|
|
114
|
-
|
|
139
|
+
Sends audio translation request to the server.
|
|
140
|
+
:param audio: Base64 encoded audio data
|
|
141
|
+
:param encoding: Audio encoding format (default is "audio/wav")
|
|
142
|
+
:param sample_rate: Audio sample rate in Hz (default is 16000)
|
|
115
143
|
"""
|
|
116
|
-
self.
|
|
144
|
+
return self._send_speech_to_text_translate_streaming_audio_message(
|
|
145
|
+
message=AudioMessage(audio=AudioData(data=audio, encoding=encoding, sample_rate=sample_rate))
|
|
146
|
+
)
|
|
117
147
|
|
|
118
|
-
def
|
|
148
|
+
def set_prompt(self, prompt: str) -> None:
|
|
119
149
|
"""
|
|
120
|
-
|
|
121
|
-
The
|
|
150
|
+
Set the prompt for the translation.
|
|
151
|
+
The prompt is useful for detecting hotwords in the audio stream.
|
|
152
|
+
This will send a ConfigMessage to the websocket connection.
|
|
122
153
|
"""
|
|
123
|
-
|
|
154
|
+
message = ConfigMessage(prompt=prompt)
|
|
155
|
+
self._send_config_message(message)
|
|
124
156
|
|
|
125
157
|
def recv(self) -> SpeechToTextTranslateStreamingSocketClientResponse:
|
|
126
158
|
"""
|
|
127
159
|
Receive a message from the websocket connection.
|
|
128
160
|
"""
|
|
129
161
|
data = self._websocket.recv()
|
|
162
|
+
data = json.loads(data) if isinstance(data, str) else data
|
|
130
163
|
return parse_obj_as(SpeechToTextTranslateStreamingSocketClientResponse, data) # type: ignore
|
|
131
164
|
|
|
165
|
+
def _send_config_message(self, message: ConfigMessage) -> None:
|
|
166
|
+
"""
|
|
167
|
+
Send a message to the websocket connection.
|
|
168
|
+
The message will be sent as a ConfigMessage.
|
|
169
|
+
"""
|
|
170
|
+
self._send_model(message)
|
|
171
|
+
|
|
172
|
+
def _send_speech_to_text_translate_streaming_audio_message(self, message: AudioMessage) -> None:
|
|
173
|
+
"""
|
|
174
|
+
Send a message to the websocket connection.
|
|
175
|
+
The message will be sent as a AudioMessage.
|
|
176
|
+
"""
|
|
177
|
+
self._send_model(message)
|
|
178
|
+
|
|
132
179
|
def _send(self, data: typing.Any) -> None:
|
|
133
180
|
"""
|
|
134
181
|
Send a message to the websocket connection.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/requests/chat_completion_request_message.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/requests/chat_completion_response_message.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/requests/create_chat_completion_response.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/requests/language_identification_response.py
RENAMED
|
File without changes
|
|
File without changes
|
{sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/requests/speech_to_text_response_data.py
RENAMED
|
File without changes
|
{sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/requests/speech_to_text_streaming_response.py
RENAMED
|
File without changes
|
{sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/requests/speech_to_text_transcription_data.py
RENAMED
|
File without changes
|
{sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/requests/speech_to_text_translate_response.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/speech_to_text_streaming/types/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/speech_to_text_translate_streaming/__init__.py
RENAMED
|
File without changes
|
{sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/speech_to_text_translate_streaming/client.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/chat_completion_request_message.py
RENAMED
|
File without changes
|
{sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/chat_completion_request_system_message.py
RENAMED
|
File without changes
|
{sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/chat_completion_request_user_message.py
RENAMED
|
File without changes
|
{sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/chat_completion_response_message.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/create_chat_completion_response.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/language_identification_response.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/speech_to_text_streaming_response.py
RENAMED
|
File without changes
|
{sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/speech_to_text_transcription_data.py
RENAMED
|
File without changes
|
{sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/speech_to_text_translate_language.py
RENAMED
|
File without changes
|
{sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/speech_to_text_translate_model.py
RENAMED
|
File without changes
|
{sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/speech_to_text_translate_response.py
RENAMED
|
File without changes
|
{sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/speech_to_text_translate_response_data.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sarvamai-0.1.5a12 → sarvamai-0.1.5a13}/src/sarvamai/types/translatiterate_target_language.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|