sarvamai 0.1.7__tar.gz → 0.1.8__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.7 → sarvamai-0.1.8}/PKG-INFO +2 -2
- {sarvamai-0.1.7 → sarvamai-0.1.8}/README.md +1 -1
- {sarvamai-0.1.7 → sarvamai-0.1.8}/pyproject.toml +1 -1
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/__init__.py +56 -1
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/client.py +3 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/core/client_wrapper.py +2 -2
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/requests/__init__.py +20 -0
- sarvamai-0.1.8/src/sarvamai/requests/audio_output.py +11 -0
- sarvamai-0.1.8/src/sarvamai/requests/audio_output_data.py +15 -0
- sarvamai-0.1.8/src/sarvamai/requests/configure_connection.py +18 -0
- sarvamai-0.1.8/src/sarvamai/requests/configure_connection_data.py +83 -0
- sarvamai-0.1.8/src/sarvamai/requests/error_response.py +11 -0
- sarvamai-0.1.8/src/sarvamai/requests/error_response_data.py +18 -0
- sarvamai-0.1.8/src/sarvamai/requests/flush_signal.py +14 -0
- sarvamai-0.1.8/src/sarvamai/requests/ping_signal.py +14 -0
- sarvamai-0.1.8/src/sarvamai/requests/send_text.py +11 -0
- sarvamai-0.1.8/src/sarvamai/requests/send_text_data.py +7 -0
- sarvamai-0.1.8/src/sarvamai/text_to_speech_streaming/__init__.py +4 -0
- sarvamai-0.1.8/src/sarvamai/text_to_speech_streaming/client.py +153 -0
- sarvamai-0.1.8/src/sarvamai/text_to_speech_streaming/raw_client.py +130 -0
- sarvamai-0.1.8/src/sarvamai/text_to_speech_streaming/socket_client.py +309 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/__init__.py +26 -0
- sarvamai-0.1.8/src/sarvamai/types/audio_output.py +21 -0
- sarvamai-0.1.8/src/sarvamai/types/audio_output_data.py +27 -0
- sarvamai-0.1.8/src/sarvamai/types/configure_connection.py +28 -0
- sarvamai-0.1.8/src/sarvamai/types/configure_connection_data.py +93 -0
- sarvamai-0.1.8/src/sarvamai/types/configure_connection_data_output_audio_bitrate.py +7 -0
- sarvamai-0.1.8/src/sarvamai/types/configure_connection_data_speaker.py +7 -0
- sarvamai-0.1.8/src/sarvamai/types/configure_connection_data_target_language_code.py +8 -0
- sarvamai-0.1.8/src/sarvamai/types/error_response.py +21 -0
- sarvamai-0.1.8/src/sarvamai/types/error_response_data.py +28 -0
- sarvamai-0.1.8/src/sarvamai/types/flush_signal.py +24 -0
- sarvamai-0.1.8/src/sarvamai/types/ping_signal.py +24 -0
- sarvamai-0.1.8/src/sarvamai/types/send_text.py +21 -0
- sarvamai-0.1.8/src/sarvamai/types/send_text_data.py +19 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/chat/__init__.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/chat/client.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/chat/raw_client.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/core/__init__.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/core/api_error.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/core/datetime_utils.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/core/events.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/core/file.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/core/force_multipart.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/core/http_client.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/core/http_response.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/core/jsonable_encoder.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/core/pydantic_utilities.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/core/query_encoder.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/core/remove_none_from_dict.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/core/request_options.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/core/serialization.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/environment.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/errors/__init__.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/errors/bad_request_error.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/errors/forbidden_error.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/errors/internal_server_error.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/errors/service_unavailable_error.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/errors/too_many_requests_error.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/errors/unprocessable_entity_error.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/play.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/py.typed +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/requests/audio_data.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/requests/audio_message.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/requests/chat_completion_request_assistant_message.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/requests/chat_completion_request_message.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/requests/chat_completion_request_system_message.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/requests/chat_completion_request_user_message.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/requests/chat_completion_response_message.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/requests/choice.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/requests/completion_usage.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/requests/config_message.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/requests/create_chat_completion_response.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/requests/diarized_entry.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/requests/diarized_transcript.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/requests/error_data.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/requests/error_details.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/requests/error_message.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/requests/events_data.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/requests/language_identification_response.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/requests/speech_to_text_response.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/requests/speech_to_text_response_data.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/requests/speech_to_text_streaming_response.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/requests/speech_to_text_transcription_data.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/requests/speech_to_text_translate_response.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/requests/speech_to_text_translate_response_data.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/requests/speech_to_text_translate_streaming_response.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/requests/speech_to_text_translate_transcription_data.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/requests/stop_configuration.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/requests/text_to_speech_response.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/requests/timestamps_model.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/requests/transcription_metrics.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/requests/translation_response.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/requests/transliteration_response.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/speech_to_text/__init__.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/speech_to_text/client.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/speech_to_text/raw_client.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/speech_to_text_streaming/__init__.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/speech_to_text_streaming/client.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/speech_to_text_streaming/raw_client.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/speech_to_text_streaming/socket_client.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/speech_to_text_streaming/types/__init__.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/speech_to_text_streaming/types/speech_to_text_streaming_high_vad_sensitivity.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/speech_to_text_streaming/types/speech_to_text_streaming_language_code.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/speech_to_text_streaming/types/speech_to_text_streaming_model.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/speech_to_text_streaming/types/speech_to_text_streaming_vad_signals.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/speech_to_text_translate_streaming/__init__.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/speech_to_text_translate_streaming/client.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/speech_to_text_translate_streaming/raw_client.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/speech_to_text_translate_streaming/socket_client.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/speech_to_text_translate_streaming/types/__init__.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/speech_to_text_translate_streaming/types/speech_to_text_translate_streaming_high_vad_sensitivity.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/speech_to_text_translate_streaming/types/speech_to_text_translate_streaming_model.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/speech_to_text_translate_streaming/types/speech_to_text_translate_streaming_vad_signals.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/text/__init__.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/text/client.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/text/raw_client.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/text_to_speech/__init__.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/text_to_speech/client.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/text_to_speech/raw_client.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/audio_data.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/audio_message.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/chat_completion_request_assistant_message.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/chat_completion_request_message.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/chat_completion_request_system_message.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/chat_completion_request_user_message.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/chat_completion_response_message.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/choice.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/completion_usage.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/config_message.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/create_chat_completion_response.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/diarized_entry.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/diarized_transcript.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/error_code.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/error_data.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/error_details.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/error_message.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/events_data.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/finish_reason.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/format.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/language_identification_response.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/numerals_format.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/reasoning_effort.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/response_type.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/role.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/sarvam_model_ids.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/speech_sample_rate.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/speech_to_text_language.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/speech_to_text_model.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/speech_to_text_response.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/speech_to_text_response_data.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/speech_to_text_streaming_response.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/speech_to_text_transcription_data.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/speech_to_text_translate_language.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/speech_to_text_translate_model.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/speech_to_text_translate_response.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/speech_to_text_translate_response_data.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/speech_to_text_translate_streaming_response.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/speech_to_text_translate_transcription_data.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/spoken_form_numerals_format.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/stop_configuration.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/text_to_speech_language.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/text_to_speech_model.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/text_to_speech_response.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/text_to_speech_speaker.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/timestamps_model.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/transcription_metrics.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/translate_mode.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/translate_model.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/translate_source_language.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/translate_speaker_gender.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/translate_target_language.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/translation_response.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/translatiterate_target_language.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/transliterate_mode.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/transliterate_source_language.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/types/transliteration_response.py +0 -0
- {sarvamai-0.1.7 → sarvamai-0.1.8}/src/sarvamai/version.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: sarvamai
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.8
|
|
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
|
|
|
@@ -7,7 +7,7 @@ The Sarvam Python library provides convenient access to the Sarvam API from Pyth
|
|
|
7
7
|
|
|
8
8
|
## Documentation
|
|
9
9
|
|
|
10
|
-
API reference documentation is available [here](https://
|
|
10
|
+
API reference documentation is available [here](https://docs.sarvam.ai/api-reference-docs/speech-to-text/).
|
|
11
11
|
|
|
12
12
|
## Installation
|
|
13
13
|
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
from .types import (
|
|
6
6
|
AudioData,
|
|
7
7
|
AudioMessage,
|
|
8
|
+
AudioOutput,
|
|
9
|
+
AudioOutputData,
|
|
8
10
|
ChatCompletionRequestAssistantMessage,
|
|
9
11
|
ChatCompletionRequestMessage,
|
|
10
12
|
ChatCompletionRequestMessage_Assistant,
|
|
@@ -16,6 +18,11 @@ from .types import (
|
|
|
16
18
|
Choice,
|
|
17
19
|
CompletionUsage,
|
|
18
20
|
ConfigMessage,
|
|
21
|
+
ConfigureConnection,
|
|
22
|
+
ConfigureConnectionData,
|
|
23
|
+
ConfigureConnectionDataOutputAudioBitrate,
|
|
24
|
+
ConfigureConnectionDataSpeaker,
|
|
25
|
+
ConfigureConnectionDataTargetLanguageCode,
|
|
19
26
|
CreateChatCompletionResponse,
|
|
20
27
|
DiarizedEntry,
|
|
21
28
|
DiarizedTranscript,
|
|
@@ -23,15 +30,21 @@ from .types import (
|
|
|
23
30
|
ErrorData,
|
|
24
31
|
ErrorDetails,
|
|
25
32
|
ErrorMessage,
|
|
33
|
+
ErrorResponse,
|
|
34
|
+
ErrorResponseData,
|
|
26
35
|
EventsData,
|
|
27
36
|
FinishReason,
|
|
37
|
+
FlushSignal,
|
|
28
38
|
Format,
|
|
29
39
|
LanguageIdentificationResponse,
|
|
30
40
|
NumeralsFormat,
|
|
41
|
+
PingSignal,
|
|
31
42
|
ReasoningEffort,
|
|
32
43
|
ResponseType,
|
|
33
44
|
Role,
|
|
34
45
|
SarvamModelIds,
|
|
46
|
+
SendText,
|
|
47
|
+
SendTextData,
|
|
35
48
|
SpeechSampleRate,
|
|
36
49
|
SpeechToTextLanguage,
|
|
37
50
|
SpeechToTextModel,
|
|
@@ -72,12 +85,22 @@ from .errors import (
|
|
|
72
85
|
TooManyRequestsError,
|
|
73
86
|
UnprocessableEntityError,
|
|
74
87
|
)
|
|
75
|
-
from . import
|
|
88
|
+
from . import (
|
|
89
|
+
chat,
|
|
90
|
+
speech_to_text,
|
|
91
|
+
speech_to_text_streaming,
|
|
92
|
+
speech_to_text_translate_streaming,
|
|
93
|
+
text,
|
|
94
|
+
text_to_speech,
|
|
95
|
+
text_to_speech_streaming,
|
|
96
|
+
)
|
|
76
97
|
from .client import AsyncSarvamAI, SarvamAI
|
|
77
98
|
from .environment import SarvamAIEnvironment
|
|
78
99
|
from .requests import (
|
|
79
100
|
AudioDataParams,
|
|
80
101
|
AudioMessageParams,
|
|
102
|
+
AudioOutputDataParams,
|
|
103
|
+
AudioOutputParams,
|
|
81
104
|
ChatCompletionRequestAssistantMessageParams,
|
|
82
105
|
ChatCompletionRequestMessageParams,
|
|
83
106
|
ChatCompletionRequestMessage_AssistantParams,
|
|
@@ -89,14 +112,22 @@ from .requests import (
|
|
|
89
112
|
ChoiceParams,
|
|
90
113
|
CompletionUsageParams,
|
|
91
114
|
ConfigMessageParams,
|
|
115
|
+
ConfigureConnectionDataParams,
|
|
116
|
+
ConfigureConnectionParams,
|
|
92
117
|
CreateChatCompletionResponseParams,
|
|
93
118
|
DiarizedEntryParams,
|
|
94
119
|
DiarizedTranscriptParams,
|
|
95
120
|
ErrorDataParams,
|
|
96
121
|
ErrorDetailsParams,
|
|
97
122
|
ErrorMessageParams,
|
|
123
|
+
ErrorResponseDataParams,
|
|
124
|
+
ErrorResponseParams,
|
|
98
125
|
EventsDataParams,
|
|
126
|
+
FlushSignalParams,
|
|
99
127
|
LanguageIdentificationResponseParams,
|
|
128
|
+
PingSignalParams,
|
|
129
|
+
SendTextDataParams,
|
|
130
|
+
SendTextParams,
|
|
100
131
|
SpeechToTextResponseDataParams,
|
|
101
132
|
SpeechToTextResponseParams,
|
|
102
133
|
SpeechToTextStreamingResponseParams,
|
|
@@ -131,6 +162,10 @@ __all__ = [
|
|
|
131
162
|
"AudioDataParams",
|
|
132
163
|
"AudioMessage",
|
|
133
164
|
"AudioMessageParams",
|
|
165
|
+
"AudioOutput",
|
|
166
|
+
"AudioOutputData",
|
|
167
|
+
"AudioOutputDataParams",
|
|
168
|
+
"AudioOutputParams",
|
|
134
169
|
"BadRequestError",
|
|
135
170
|
"ChatCompletionRequestAssistantMessage",
|
|
136
171
|
"ChatCompletionRequestAssistantMessageParams",
|
|
@@ -154,6 +189,13 @@ __all__ = [
|
|
|
154
189
|
"CompletionUsageParams",
|
|
155
190
|
"ConfigMessage",
|
|
156
191
|
"ConfigMessageParams",
|
|
192
|
+
"ConfigureConnection",
|
|
193
|
+
"ConfigureConnectionData",
|
|
194
|
+
"ConfigureConnectionDataOutputAudioBitrate",
|
|
195
|
+
"ConfigureConnectionDataParams",
|
|
196
|
+
"ConfigureConnectionDataSpeaker",
|
|
197
|
+
"ConfigureConnectionDataTargetLanguageCode",
|
|
198
|
+
"ConfigureConnectionParams",
|
|
157
199
|
"CreateChatCompletionResponse",
|
|
158
200
|
"CreateChatCompletionResponseParams",
|
|
159
201
|
"DiarizedEntry",
|
|
@@ -167,21 +209,33 @@ __all__ = [
|
|
|
167
209
|
"ErrorDetailsParams",
|
|
168
210
|
"ErrorMessage",
|
|
169
211
|
"ErrorMessageParams",
|
|
212
|
+
"ErrorResponse",
|
|
213
|
+
"ErrorResponseData",
|
|
214
|
+
"ErrorResponseDataParams",
|
|
215
|
+
"ErrorResponseParams",
|
|
170
216
|
"EventsData",
|
|
171
217
|
"EventsDataParams",
|
|
172
218
|
"FinishReason",
|
|
219
|
+
"FlushSignal",
|
|
220
|
+
"FlushSignalParams",
|
|
173
221
|
"ForbiddenError",
|
|
174
222
|
"Format",
|
|
175
223
|
"InternalServerError",
|
|
176
224
|
"LanguageIdentificationResponse",
|
|
177
225
|
"LanguageIdentificationResponseParams",
|
|
178
226
|
"NumeralsFormat",
|
|
227
|
+
"PingSignal",
|
|
228
|
+
"PingSignalParams",
|
|
179
229
|
"ReasoningEffort",
|
|
180
230
|
"ResponseType",
|
|
181
231
|
"Role",
|
|
182
232
|
"SarvamAI",
|
|
183
233
|
"SarvamAIEnvironment",
|
|
184
234
|
"SarvamModelIds",
|
|
235
|
+
"SendText",
|
|
236
|
+
"SendTextData",
|
|
237
|
+
"SendTextDataParams",
|
|
238
|
+
"SendTextParams",
|
|
185
239
|
"ServiceUnavailableError",
|
|
186
240
|
"SpeechSampleRate",
|
|
187
241
|
"SpeechToTextLanguage",
|
|
@@ -244,4 +298,5 @@ __all__ = [
|
|
|
244
298
|
"speech_to_text_translate_streaming",
|
|
245
299
|
"text",
|
|
246
300
|
"text_to_speech",
|
|
301
|
+
"text_to_speech_streaming",
|
|
247
302
|
]
|
|
@@ -16,6 +16,7 @@ from .speech_to_text_translate_streaming.client import (
|
|
|
16
16
|
)
|
|
17
17
|
from .text.client import AsyncTextClient, TextClient
|
|
18
18
|
from .text_to_speech.client import AsyncTextToSpeechClient, TextToSpeechClient
|
|
19
|
+
from .text_to_speech_streaming.client import AsyncTextToSpeechStreamingClient, TextToSpeechStreamingClient
|
|
19
20
|
|
|
20
21
|
|
|
21
22
|
class SarvamAI:
|
|
@@ -86,6 +87,7 @@ class SarvamAI:
|
|
|
86
87
|
self.speech_to_text_translate_streaming = SpeechToTextTranslateStreamingClient(
|
|
87
88
|
client_wrapper=self._client_wrapper
|
|
88
89
|
)
|
|
90
|
+
self.text_to_speech_streaming = TextToSpeechStreamingClient(client_wrapper=self._client_wrapper)
|
|
89
91
|
|
|
90
92
|
|
|
91
93
|
class AsyncSarvamAI:
|
|
@@ -156,3 +158,4 @@ class AsyncSarvamAI:
|
|
|
156
158
|
self.speech_to_text_translate_streaming = AsyncSpeechToTextTranslateStreamingClient(
|
|
157
159
|
client_wrapper=self._client_wrapper
|
|
158
160
|
)
|
|
161
|
+
self.text_to_speech_streaming = AsyncTextToSpeechStreamingClient(client_wrapper=self._client_wrapper)
|
|
@@ -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.8",
|
|
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.8",
|
|
24
24
|
}
|
|
25
25
|
headers["api-subscription-key"] = self.api_subscription_key
|
|
26
26
|
return headers
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
from .audio_data import AudioDataParams
|
|
6
6
|
from .audio_message import AudioMessageParams
|
|
7
|
+
from .audio_output import AudioOutputParams
|
|
8
|
+
from .audio_output_data import AudioOutputDataParams
|
|
7
9
|
from .chat_completion_request_assistant_message import ChatCompletionRequestAssistantMessageParams
|
|
8
10
|
from .chat_completion_request_message import (
|
|
9
11
|
ChatCompletionRequestMessageParams,
|
|
@@ -17,14 +19,22 @@ from .chat_completion_response_message import ChatCompletionResponseMessageParam
|
|
|
17
19
|
from .choice import ChoiceParams
|
|
18
20
|
from .completion_usage import CompletionUsageParams
|
|
19
21
|
from .config_message import ConfigMessageParams
|
|
22
|
+
from .configure_connection import ConfigureConnectionParams
|
|
23
|
+
from .configure_connection_data import ConfigureConnectionDataParams
|
|
20
24
|
from .create_chat_completion_response import CreateChatCompletionResponseParams
|
|
21
25
|
from .diarized_entry import DiarizedEntryParams
|
|
22
26
|
from .diarized_transcript import DiarizedTranscriptParams
|
|
23
27
|
from .error_data import ErrorDataParams
|
|
24
28
|
from .error_details import ErrorDetailsParams
|
|
25
29
|
from .error_message import ErrorMessageParams
|
|
30
|
+
from .error_response import ErrorResponseParams
|
|
31
|
+
from .error_response_data import ErrorResponseDataParams
|
|
26
32
|
from .events_data import EventsDataParams
|
|
33
|
+
from .flush_signal import FlushSignalParams
|
|
27
34
|
from .language_identification_response import LanguageIdentificationResponseParams
|
|
35
|
+
from .ping_signal import PingSignalParams
|
|
36
|
+
from .send_text import SendTextParams
|
|
37
|
+
from .send_text_data import SendTextDataParams
|
|
28
38
|
from .speech_to_text_response import SpeechToTextResponseParams
|
|
29
39
|
from .speech_to_text_response_data import SpeechToTextResponseDataParams
|
|
30
40
|
from .speech_to_text_streaming_response import SpeechToTextStreamingResponseParams
|
|
@@ -43,6 +53,8 @@ from .transliteration_response import TransliterationResponseParams
|
|
|
43
53
|
__all__ = [
|
|
44
54
|
"AudioDataParams",
|
|
45
55
|
"AudioMessageParams",
|
|
56
|
+
"AudioOutputDataParams",
|
|
57
|
+
"AudioOutputParams",
|
|
46
58
|
"ChatCompletionRequestAssistantMessageParams",
|
|
47
59
|
"ChatCompletionRequestMessageParams",
|
|
48
60
|
"ChatCompletionRequestMessage_AssistantParams",
|
|
@@ -54,14 +66,22 @@ __all__ = [
|
|
|
54
66
|
"ChoiceParams",
|
|
55
67
|
"CompletionUsageParams",
|
|
56
68
|
"ConfigMessageParams",
|
|
69
|
+
"ConfigureConnectionDataParams",
|
|
70
|
+
"ConfigureConnectionParams",
|
|
57
71
|
"CreateChatCompletionResponseParams",
|
|
58
72
|
"DiarizedEntryParams",
|
|
59
73
|
"DiarizedTranscriptParams",
|
|
60
74
|
"ErrorDataParams",
|
|
61
75
|
"ErrorDetailsParams",
|
|
62
76
|
"ErrorMessageParams",
|
|
77
|
+
"ErrorResponseDataParams",
|
|
78
|
+
"ErrorResponseParams",
|
|
63
79
|
"EventsDataParams",
|
|
80
|
+
"FlushSignalParams",
|
|
64
81
|
"LanguageIdentificationResponseParams",
|
|
82
|
+
"PingSignalParams",
|
|
83
|
+
"SendTextDataParams",
|
|
84
|
+
"SendTextParams",
|
|
65
85
|
"SpeechToTextResponseDataParams",
|
|
66
86
|
"SpeechToTextResponseParams",
|
|
67
87
|
"SpeechToTextStreamingResponseParams",
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
import typing_extensions
|
|
6
|
+
from .audio_output_data import AudioOutputDataParams
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class AudioOutputParams(typing_extensions.TypedDict):
|
|
10
|
+
type: typing.Literal["audio"]
|
|
11
|
+
data: AudioOutputDataParams
|
|
@@ -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 AudioOutputDataParams(typing_extensions.TypedDict):
|
|
7
|
+
content_type: str
|
|
8
|
+
"""
|
|
9
|
+
MIME type of the audio content (e.g., 'audio/mp3', 'audio/wav')
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
audio: str
|
|
13
|
+
"""
|
|
14
|
+
Base64-encoded audio data ready for playback or download
|
|
15
|
+
"""
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
import typing_extensions
|
|
6
|
+
from .configure_connection_data import ConfigureConnectionDataParams
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class ConfigureConnectionParams(typing_extensions.TypedDict):
|
|
10
|
+
"""
|
|
11
|
+
Configuration message required as the first message after establishing the WebSocket connection.
|
|
12
|
+
This initializes TTS parameters and can be updated at any time during the WebSocket lifecycle
|
|
13
|
+
by sending a new config message. When a config update is sent, any text currently in the buffer
|
|
14
|
+
will be automatically flushed and processed before applying the new configuration.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
type: typing.Literal["config"]
|
|
18
|
+
data: ConfigureConnectionDataParams
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
import typing_extensions
|
|
6
|
+
from ..types.configure_connection_data_output_audio_bitrate import ConfigureConnectionDataOutputAudioBitrate
|
|
7
|
+
from ..types.configure_connection_data_speaker import ConfigureConnectionDataSpeaker
|
|
8
|
+
from ..types.configure_connection_data_target_language_code import ConfigureConnectionDataTargetLanguageCode
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class ConfigureConnectionDataParams(typing_extensions.TypedDict):
|
|
12
|
+
target_language_code: ConfigureConnectionDataTargetLanguageCode
|
|
13
|
+
"""
|
|
14
|
+
The language of the text is BCP-47 format
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
speaker: ConfigureConnectionDataSpeaker
|
|
18
|
+
"""
|
|
19
|
+
The speaker voice to be used for the output audio.
|
|
20
|
+
|
|
21
|
+
**Default:** Anushka
|
|
22
|
+
|
|
23
|
+
**Model Compatibility (Speakers compatible with respective model):**
|
|
24
|
+
- **bulbul:v2:**
|
|
25
|
+
- Female: Anushka, Manisha, Vidya, Arya
|
|
26
|
+
- Male: Abhilash, Karun, Hitesh
|
|
27
|
+
|
|
28
|
+
**Note:** Speaker selection must match the chosen model version.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
pitch: typing_extensions.NotRequired[float]
|
|
32
|
+
"""
|
|
33
|
+
Controls the pitch of the audio. Lower values result in a deeper voice,
|
|
34
|
+
while higher values make it sharper. The suitable range is between -0.75
|
|
35
|
+
and 0.75. Default is 0.0.
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
pace: typing_extensions.NotRequired[float]
|
|
39
|
+
"""
|
|
40
|
+
Controls the speed of the audio. Lower values result in slower speech,
|
|
41
|
+
while higher values make it faster. The suitable range is between 0.5
|
|
42
|
+
and 2.0. Default is 1.0.
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
loudness: typing_extensions.NotRequired[float]
|
|
46
|
+
"""
|
|
47
|
+
Controls the loudness of the audio. Lower values result in quieter audio,
|
|
48
|
+
while higher values make it louder. The suitable range is between 0.3
|
|
49
|
+
and 3.0. Default is 1.0.
|
|
50
|
+
"""
|
|
51
|
+
|
|
52
|
+
speech_sample_rate: typing_extensions.NotRequired[int]
|
|
53
|
+
"""
|
|
54
|
+
Specifies the sample rate of the output audio. Supported values are
|
|
55
|
+
8000, 16000, 22050, 24000 Hz. If not provided, the default is 22050 Hz.
|
|
56
|
+
"""
|
|
57
|
+
|
|
58
|
+
enable_preprocessing: typing_extensions.NotRequired[bool]
|
|
59
|
+
"""
|
|
60
|
+
Controls whether normalization of English words and numeric entities
|
|
61
|
+
(e.g., numbers, dates) is performed. Set to true for better handling
|
|
62
|
+
of mixed-language text. Default is false.
|
|
63
|
+
"""
|
|
64
|
+
|
|
65
|
+
output_audio_codec: typing_extensions.NotRequired[typing.Literal["mp3"]]
|
|
66
|
+
"""
|
|
67
|
+
Audio codec (currently supports MP3 only, optimized for real-time playback)
|
|
68
|
+
"""
|
|
69
|
+
|
|
70
|
+
output_audio_bitrate: typing_extensions.NotRequired[ConfigureConnectionDataOutputAudioBitrate]
|
|
71
|
+
"""
|
|
72
|
+
Audio bitrate (choose from 5 supported bitrate options)
|
|
73
|
+
"""
|
|
74
|
+
|
|
75
|
+
min_buffer_size: typing_extensions.NotRequired[int]
|
|
76
|
+
"""
|
|
77
|
+
Minimum character length that triggers buffer flushing for TTS model processing
|
|
78
|
+
"""
|
|
79
|
+
|
|
80
|
+
max_chunk_length: typing_extensions.NotRequired[int]
|
|
81
|
+
"""
|
|
82
|
+
Maximum length for sentence splitting (adjust based on content length)
|
|
83
|
+
"""
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
import typing_extensions
|
|
6
|
+
from .error_response_data import ErrorResponseDataParams
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class ErrorResponseParams(typing_extensions.TypedDict):
|
|
10
|
+
type: typing.Literal["error"]
|
|
11
|
+
data: ErrorResponseDataParams
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
import typing_extensions
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class ErrorResponseDataParams(typing_extensions.TypedDict):
|
|
9
|
+
message: str
|
|
10
|
+
code: typing_extensions.NotRequired[int]
|
|
11
|
+
"""
|
|
12
|
+
Optional error code for programmatic error handling
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
details: typing_extensions.NotRequired[typing.Dict[str, typing.Optional[typing.Any]]]
|
|
16
|
+
"""
|
|
17
|
+
Additional error details and context information
|
|
18
|
+
"""
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
import typing_extensions
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class FlushSignalParams(typing_extensions.TypedDict):
|
|
9
|
+
"""
|
|
10
|
+
Forces the text buffer to process immediately, regardless of the min_buffer_size threshold.
|
|
11
|
+
Use this when you need to process remaining text that hasn't reached the minimum buffer size.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
type: typing.Literal["flush"]
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
import typing_extensions
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class PingSignalParams(typing_extensions.TypedDict):
|
|
9
|
+
"""
|
|
10
|
+
Send ping signal to keep the WebSocket connection alive. The connection automatically
|
|
11
|
+
closes after one minute of inactivity.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
type: typing.Literal["ping"]
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
import typing_extensions
|
|
6
|
+
from .send_text_data import SendTextDataParams
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class SendTextParams(typing_extensions.TypedDict):
|
|
10
|
+
type: typing.Literal["text"]
|
|
11
|
+
data: SendTextDataParams
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
from contextlib import asynccontextmanager, contextmanager
|
|
5
|
+
|
|
6
|
+
import httpx
|
|
7
|
+
import websockets
|
|
8
|
+
import websockets.sync.client as websockets_sync_client
|
|
9
|
+
from ..core.api_error import ApiError
|
|
10
|
+
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
11
|
+
from ..core.request_options import RequestOptions
|
|
12
|
+
from .raw_client import AsyncRawTextToSpeechStreamingClient, RawTextToSpeechStreamingClient
|
|
13
|
+
from .socket_client import AsyncTextToSpeechStreamingSocketClient, TextToSpeechStreamingSocketClient
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class TextToSpeechStreamingClient:
|
|
17
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
18
|
+
self._raw_client = RawTextToSpeechStreamingClient(client_wrapper=client_wrapper)
|
|
19
|
+
|
|
20
|
+
@property
|
|
21
|
+
def with_raw_response(self) -> RawTextToSpeechStreamingClient:
|
|
22
|
+
"""
|
|
23
|
+
Retrieves a raw implementation of this client that returns raw responses.
|
|
24
|
+
|
|
25
|
+
Returns
|
|
26
|
+
-------
|
|
27
|
+
RawTextToSpeechStreamingClient
|
|
28
|
+
"""
|
|
29
|
+
return self._raw_client
|
|
30
|
+
|
|
31
|
+
@contextmanager
|
|
32
|
+
def connect(
|
|
33
|
+
self,
|
|
34
|
+
*,
|
|
35
|
+
model: typing.Optional[typing.Literal["bulbul:v2"]] = None,
|
|
36
|
+
api_subscription_key: typing.Optional[str] = None,
|
|
37
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
38
|
+
) -> typing.Iterator[TextToSpeechStreamingSocketClient]:
|
|
39
|
+
"""
|
|
40
|
+
Bidirectional WebSocket channel for real-time TTS synthesis.
|
|
41
|
+
Supports streaming, flushing, config updates, and audio playback.
|
|
42
|
+
|
|
43
|
+
Parameters
|
|
44
|
+
----------
|
|
45
|
+
model : typing.Optional[typing.Literal["bulbul:v2"]]
|
|
46
|
+
Text to speech model to use
|
|
47
|
+
|
|
48
|
+
api_subscription_key : typing.Optional[str]
|
|
49
|
+
API subscription key for authentication
|
|
50
|
+
|
|
51
|
+
request_options : typing.Optional[RequestOptions]
|
|
52
|
+
Request-specific configuration.
|
|
53
|
+
|
|
54
|
+
Returns
|
|
55
|
+
-------
|
|
56
|
+
TextToSpeechStreamingSocketClient
|
|
57
|
+
"""
|
|
58
|
+
ws_url = self._raw_client._client_wrapper.get_environment().production + "/text-to-speech/ws"
|
|
59
|
+
query_params = httpx.QueryParams()
|
|
60
|
+
if model is not None:
|
|
61
|
+
query_params = query_params.add("model", model)
|
|
62
|
+
ws_url = ws_url + f"?{query_params}"
|
|
63
|
+
headers = self._raw_client._client_wrapper.get_headers()
|
|
64
|
+
if api_subscription_key is not None:
|
|
65
|
+
headers["Api-Subscription-Key"] = str(api_subscription_key)
|
|
66
|
+
if request_options and "additional_headers" in request_options:
|
|
67
|
+
headers.update(request_options["additional_headers"])
|
|
68
|
+
try:
|
|
69
|
+
with websockets_sync_client.connect(ws_url, additional_headers=headers) as protocol:
|
|
70
|
+
yield TextToSpeechStreamingSocketClient(websocket=protocol)
|
|
71
|
+
except websockets.exceptions.InvalidStatusCode as exc:
|
|
72
|
+
status_code: int = exc.status_code
|
|
73
|
+
if status_code == 401:
|
|
74
|
+
raise ApiError(
|
|
75
|
+
status_code=status_code,
|
|
76
|
+
headers=dict(headers),
|
|
77
|
+
body="Websocket initialized with invalid credentials.",
|
|
78
|
+
)
|
|
79
|
+
raise ApiError(
|
|
80
|
+
status_code=status_code,
|
|
81
|
+
headers=dict(headers),
|
|
82
|
+
body="Unexpected error when initializing websocket connection.",
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
class AsyncTextToSpeechStreamingClient:
|
|
87
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
88
|
+
self._raw_client = AsyncRawTextToSpeechStreamingClient(client_wrapper=client_wrapper)
|
|
89
|
+
|
|
90
|
+
@property
|
|
91
|
+
def with_raw_response(self) -> AsyncRawTextToSpeechStreamingClient:
|
|
92
|
+
"""
|
|
93
|
+
Retrieves a raw implementation of this client that returns raw responses.
|
|
94
|
+
|
|
95
|
+
Returns
|
|
96
|
+
-------
|
|
97
|
+
AsyncRawTextToSpeechStreamingClient
|
|
98
|
+
"""
|
|
99
|
+
return self._raw_client
|
|
100
|
+
|
|
101
|
+
@asynccontextmanager
|
|
102
|
+
async def connect(
|
|
103
|
+
self,
|
|
104
|
+
*,
|
|
105
|
+
model: typing.Optional[typing.Literal["bulbul:v2"]] = None,
|
|
106
|
+
api_subscription_key: typing.Optional[str] = None,
|
|
107
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
108
|
+
) -> typing.AsyncIterator[AsyncTextToSpeechStreamingSocketClient]:
|
|
109
|
+
"""
|
|
110
|
+
Bidirectional WebSocket channel for real-time TTS synthesis.
|
|
111
|
+
Supports streaming, flushing, config updates, and audio playback.
|
|
112
|
+
|
|
113
|
+
Parameters
|
|
114
|
+
----------
|
|
115
|
+
model : typing.Optional[typing.Literal["bulbul:v2"]]
|
|
116
|
+
Text to speech model to use
|
|
117
|
+
|
|
118
|
+
api_subscription_key : typing.Optional[str]
|
|
119
|
+
API subscription key for authentication
|
|
120
|
+
|
|
121
|
+
request_options : typing.Optional[RequestOptions]
|
|
122
|
+
Request-specific configuration.
|
|
123
|
+
|
|
124
|
+
Returns
|
|
125
|
+
-------
|
|
126
|
+
AsyncTextToSpeechStreamingSocketClient
|
|
127
|
+
"""
|
|
128
|
+
ws_url = self._raw_client._client_wrapper.get_environment().production + "/text-to-speech/ws"
|
|
129
|
+
query_params = httpx.QueryParams()
|
|
130
|
+
if model is not None:
|
|
131
|
+
query_params = query_params.add("model", model)
|
|
132
|
+
ws_url = ws_url + f"?{query_params}"
|
|
133
|
+
headers = self._raw_client._client_wrapper.get_headers()
|
|
134
|
+
if api_subscription_key is not None:
|
|
135
|
+
headers["Api-Subscription-Key"] = str(api_subscription_key)
|
|
136
|
+
if request_options and "additional_headers" in request_options:
|
|
137
|
+
headers.update(request_options["additional_headers"])
|
|
138
|
+
try:
|
|
139
|
+
async with websockets.connect(ws_url, extra_headers=headers) as protocol:
|
|
140
|
+
yield AsyncTextToSpeechStreamingSocketClient(websocket=protocol)
|
|
141
|
+
except websockets.exceptions.InvalidStatusCode as exc:
|
|
142
|
+
status_code: int = exc.status_code
|
|
143
|
+
if status_code == 401:
|
|
144
|
+
raise ApiError(
|
|
145
|
+
status_code=status_code,
|
|
146
|
+
headers=dict(headers),
|
|
147
|
+
body="Websocket initialized with invalid credentials.",
|
|
148
|
+
)
|
|
149
|
+
raise ApiError(
|
|
150
|
+
status_code=status_code,
|
|
151
|
+
headers=dict(headers),
|
|
152
|
+
body="Unexpected error when initializing websocket connection.",
|
|
153
|
+
)
|