sarvamai 0.1.8rc3__tar.gz → 0.1.8rc5__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.
Files changed (181) hide show
  1. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/PKG-INFO +1 -1
  2. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/pyproject.toml +1 -1
  3. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/__init__.py +4 -4
  4. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/core/client_wrapper.py +2 -2
  5. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/requests/__init__.py +2 -2
  6. sarvamai-0.1.8rc3/src/sarvamai/requests/close_connection.py → sarvamai-0.1.8rc5/src/sarvamai/requests/flush_signal.py +1 -1
  7. sarvamai-0.1.8rc5/src/sarvamai/text_to_speech_streaming/socket_client.py +275 -0
  8. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/__init__.py +2 -2
  9. sarvamai-0.1.8rc3/src/sarvamai/types/close_connection.py → sarvamai-0.1.8rc5/src/sarvamai/types/flush_signal.py +1 -1
  10. sarvamai-0.1.8rc3/src/sarvamai/text_to_speech_streaming/socket_client.py +0 -175
  11. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/README.md +0 -0
  12. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/chat/__init__.py +0 -0
  13. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/chat/client.py +0 -0
  14. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/chat/raw_client.py +0 -0
  15. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/client.py +0 -0
  16. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/core/__init__.py +0 -0
  17. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/core/api_error.py +0 -0
  18. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/core/datetime_utils.py +0 -0
  19. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/core/events.py +0 -0
  20. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/core/file.py +0 -0
  21. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/core/force_multipart.py +0 -0
  22. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/core/http_client.py +0 -0
  23. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/core/http_response.py +0 -0
  24. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/core/jsonable_encoder.py +0 -0
  25. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/core/pydantic_utilities.py +0 -0
  26. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/core/query_encoder.py +0 -0
  27. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/core/remove_none_from_dict.py +0 -0
  28. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/core/request_options.py +0 -0
  29. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/core/serialization.py +0 -0
  30. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/environment.py +0 -0
  31. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/errors/__init__.py +0 -0
  32. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/errors/bad_request_error.py +0 -0
  33. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/errors/forbidden_error.py +0 -0
  34. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/errors/internal_server_error.py +0 -0
  35. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/errors/service_unavailable_error.py +0 -0
  36. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/errors/too_many_requests_error.py +0 -0
  37. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/errors/unprocessable_entity_error.py +0 -0
  38. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/play.py +0 -0
  39. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/py.typed +0 -0
  40. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/requests/audio_data.py +0 -0
  41. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/requests/audio_message.py +0 -0
  42. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/requests/audio_output.py +0 -0
  43. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/requests/audio_output_data.py +0 -0
  44. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/requests/chat_completion_request_assistant_message.py +0 -0
  45. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/requests/chat_completion_request_message.py +0 -0
  46. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/requests/chat_completion_request_system_message.py +0 -0
  47. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/requests/chat_completion_request_user_message.py +0 -0
  48. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/requests/chat_completion_response_message.py +0 -0
  49. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/requests/choice.py +0 -0
  50. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/requests/completion_usage.py +0 -0
  51. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/requests/config_message.py +0 -0
  52. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/requests/create_chat_completion_response.py +0 -0
  53. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/requests/diarized_entry.py +0 -0
  54. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/requests/diarized_transcript.py +0 -0
  55. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/requests/error_data.py +0 -0
  56. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/requests/error_details.py +0 -0
  57. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/requests/error_message.py +0 -0
  58. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/requests/error_response.py +0 -0
  59. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/requests/error_response_data.py +0 -0
  60. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/requests/events_data.py +0 -0
  61. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/requests/initialize_connection.py +0 -0
  62. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/requests/initialize_connection_data.py +0 -0
  63. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/requests/language_identification_response.py +0 -0
  64. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/requests/ping_signal.py +0 -0
  65. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/requests/send_text.py +0 -0
  66. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/requests/send_text_data.py +0 -0
  67. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/requests/speech_to_text_response.py +0 -0
  68. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/requests/speech_to_text_response_data.py +0 -0
  69. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/requests/speech_to_text_streaming_response.py +0 -0
  70. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/requests/speech_to_text_transcription_data.py +0 -0
  71. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/requests/speech_to_text_translate_response.py +0 -0
  72. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/requests/speech_to_text_translate_response_data.py +0 -0
  73. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/requests/speech_to_text_translate_streaming_response.py +0 -0
  74. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/requests/speech_to_text_translate_transcription_data.py +0 -0
  75. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/requests/stop_configuration.py +0 -0
  76. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/requests/text_to_speech_response.py +0 -0
  77. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/requests/timestamps_model.py +0 -0
  78. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/requests/transcription_metrics.py +0 -0
  79. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/requests/translation_response.py +0 -0
  80. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/requests/transliteration_response.py +0 -0
  81. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/speech_to_text/__init__.py +0 -0
  82. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/speech_to_text/client.py +0 -0
  83. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/speech_to_text/raw_client.py +0 -0
  84. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/speech_to_text_streaming/__init__.py +0 -0
  85. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/speech_to_text_streaming/client.py +0 -0
  86. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/speech_to_text_streaming/raw_client.py +0 -0
  87. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/speech_to_text_streaming/socket_client.py +0 -0
  88. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/speech_to_text_streaming/types/__init__.py +0 -0
  89. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/speech_to_text_streaming/types/speech_to_text_streaming_high_vad_sensitivity.py +0 -0
  90. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/speech_to_text_streaming/types/speech_to_text_streaming_language_code.py +0 -0
  91. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/speech_to_text_streaming/types/speech_to_text_streaming_model.py +0 -0
  92. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/speech_to_text_streaming/types/speech_to_text_streaming_vad_signals.py +0 -0
  93. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/speech_to_text_translate_streaming/__init__.py +0 -0
  94. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/speech_to_text_translate_streaming/client.py +0 -0
  95. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/speech_to_text_translate_streaming/raw_client.py +0 -0
  96. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/speech_to_text_translate_streaming/socket_client.py +0 -0
  97. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/speech_to_text_translate_streaming/types/__init__.py +0 -0
  98. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/speech_to_text_translate_streaming/types/speech_to_text_translate_streaming_high_vad_sensitivity.py +0 -0
  99. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/speech_to_text_translate_streaming/types/speech_to_text_translate_streaming_model.py +0 -0
  100. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/speech_to_text_translate_streaming/types/speech_to_text_translate_streaming_vad_signals.py +0 -0
  101. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/text/__init__.py +0 -0
  102. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/text/client.py +0 -0
  103. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/text/raw_client.py +0 -0
  104. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/text_to_speech/__init__.py +0 -0
  105. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/text_to_speech/client.py +0 -0
  106. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/text_to_speech/raw_client.py +0 -0
  107. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/text_to_speech_streaming/__init__.py +0 -0
  108. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/text_to_speech_streaming/client.py +0 -0
  109. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/text_to_speech_streaming/raw_client.py +0 -0
  110. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/text_to_speech_streaming/types/__init__.py +0 -0
  111. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/text_to_speech_streaming/types/text_to_speech_streaming_model.py +0 -0
  112. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/audio_data.py +0 -0
  113. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/audio_message.py +0 -0
  114. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/audio_output.py +0 -0
  115. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/audio_output_data.py +0 -0
  116. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/chat_completion_request_assistant_message.py +0 -0
  117. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/chat_completion_request_message.py +0 -0
  118. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/chat_completion_request_system_message.py +0 -0
  119. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/chat_completion_request_user_message.py +0 -0
  120. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/chat_completion_response_message.py +0 -0
  121. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/choice.py +0 -0
  122. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/completion_usage.py +0 -0
  123. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/config_message.py +0 -0
  124. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/create_chat_completion_response.py +0 -0
  125. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/diarized_entry.py +0 -0
  126. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/diarized_transcript.py +0 -0
  127. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/error_code.py +0 -0
  128. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/error_data.py +0 -0
  129. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/error_details.py +0 -0
  130. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/error_message.py +0 -0
  131. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/error_response.py +0 -0
  132. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/error_response_data.py +0 -0
  133. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/events_data.py +0 -0
  134. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/finish_reason.py +0 -0
  135. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/format.py +0 -0
  136. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/initialize_connection.py +0 -0
  137. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/initialize_connection_data.py +0 -0
  138. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/initialize_connection_data_output_audio_bitrate.py +0 -0
  139. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/initialize_connection_data_speaker.py +0 -0
  140. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/initialize_connection_data_target_language_code.py +0 -0
  141. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/language_identification_response.py +0 -0
  142. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/numerals_format.py +0 -0
  143. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/ping_signal.py +0 -0
  144. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/reasoning_effort.py +0 -0
  145. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/response_type.py +0 -0
  146. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/role.py +0 -0
  147. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/sarvam_model_ids.py +0 -0
  148. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/send_text.py +0 -0
  149. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/send_text_data.py +0 -0
  150. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/speech_sample_rate.py +0 -0
  151. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/speech_to_text_language.py +0 -0
  152. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/speech_to_text_model.py +0 -0
  153. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/speech_to_text_response.py +0 -0
  154. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/speech_to_text_response_data.py +0 -0
  155. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/speech_to_text_streaming_response.py +0 -0
  156. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/speech_to_text_transcription_data.py +0 -0
  157. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/speech_to_text_translate_language.py +0 -0
  158. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/speech_to_text_translate_model.py +0 -0
  159. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/speech_to_text_translate_response.py +0 -0
  160. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/speech_to_text_translate_response_data.py +0 -0
  161. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/speech_to_text_translate_streaming_response.py +0 -0
  162. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/speech_to_text_translate_transcription_data.py +0 -0
  163. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/spoken_form_numerals_format.py +0 -0
  164. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/stop_configuration.py +0 -0
  165. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/text_to_speech_language.py +0 -0
  166. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/text_to_speech_model.py +0 -0
  167. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/text_to_speech_response.py +0 -0
  168. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/text_to_speech_speaker.py +0 -0
  169. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/timestamps_model.py +0 -0
  170. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/transcription_metrics.py +0 -0
  171. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/translate_mode.py +0 -0
  172. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/translate_model.py +0 -0
  173. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/translate_source_language.py +0 -0
  174. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/translate_speaker_gender.py +0 -0
  175. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/translate_target_language.py +0 -0
  176. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/translation_response.py +0 -0
  177. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/translatiterate_target_language.py +0 -0
  178. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/transliterate_mode.py +0 -0
  179. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/transliterate_source_language.py +0 -0
  180. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/types/transliteration_response.py +0 -0
  181. {sarvamai-0.1.8rc3 → sarvamai-0.1.8rc5}/src/sarvamai/version.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sarvamai
3
- Version: 0.1.8rc3
3
+ Version: 0.1.8rc5
4
4
  Summary:
5
5
  Requires-Python: >=3.8,<4.0
6
6
  Classifier: Intended Audience :: Developers
@@ -3,7 +3,7 @@ name = "sarvamai"
3
3
 
4
4
  [tool.poetry]
5
5
  name = "sarvamai"
6
- version = "0.1.8rc3"
6
+ version = "0.1.8rc5"
7
7
  description = ""
8
8
  readme = "README.md"
9
9
  authors = []
@@ -16,7 +16,6 @@ from .types import (
16
16
  ChatCompletionRequestUserMessage,
17
17
  ChatCompletionResponseMessage,
18
18
  Choice,
19
- CloseConnection,
20
19
  CompletionUsage,
21
20
  ConfigMessage,
22
21
  CreateChatCompletionResponse,
@@ -30,6 +29,7 @@ from .types import (
30
29
  ErrorResponseData,
31
30
  EventsData,
32
31
  FinishReason,
32
+ FlushSignal,
33
33
  Format,
34
34
  InitializeConnection,
35
35
  InitializeConnectionData,
@@ -110,7 +110,6 @@ from .requests import (
110
110
  ChatCompletionRequestUserMessageParams,
111
111
  ChatCompletionResponseMessageParams,
112
112
  ChoiceParams,
113
- CloseConnectionParams,
114
113
  CompletionUsageParams,
115
114
  ConfigMessageParams,
116
115
  CreateChatCompletionResponseParams,
@@ -122,6 +121,7 @@ from .requests import (
122
121
  ErrorResponseDataParams,
123
122
  ErrorResponseParams,
124
123
  EventsDataParams,
124
+ FlushSignalParams,
125
125
  InitializeConnectionDataParams,
126
126
  InitializeConnectionParams,
127
127
  LanguageIdentificationResponseParams,
@@ -186,8 +186,6 @@ __all__ = [
186
186
  "ChatCompletionResponseMessageParams",
187
187
  "Choice",
188
188
  "ChoiceParams",
189
- "CloseConnection",
190
- "CloseConnectionParams",
191
189
  "CompletionUsage",
192
190
  "CompletionUsageParams",
193
191
  "ConfigMessage",
@@ -212,6 +210,8 @@ __all__ = [
212
210
  "EventsData",
213
211
  "EventsDataParams",
214
212
  "FinishReason",
213
+ "FlushSignal",
214
+ "FlushSignalParams",
215
215
  "ForbiddenError",
216
216
  "Format",
217
217
  "InitializeConnection",
@@ -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.8rc3",
20
+ "User-Agent": "sarvamai/0.1.8rc5",
21
21
  "X-Fern-Language": "Python",
22
22
  "X-Fern-SDK-Name": "sarvamai",
23
- "X-Fern-SDK-Version": "0.1.8rc3",
23
+ "X-Fern-SDK-Version": "0.1.8rc5",
24
24
  }
25
25
  headers["api-subscription-key"] = self.api_subscription_key
26
26
  return headers
@@ -17,7 +17,6 @@ from .chat_completion_request_system_message import ChatCompletionRequestSystemM
17
17
  from .chat_completion_request_user_message import ChatCompletionRequestUserMessageParams
18
18
  from .chat_completion_response_message import ChatCompletionResponseMessageParams
19
19
  from .choice import ChoiceParams
20
- from .close_connection import CloseConnectionParams
21
20
  from .completion_usage import CompletionUsageParams
22
21
  from .config_message import ConfigMessageParams
23
22
  from .create_chat_completion_response import CreateChatCompletionResponseParams
@@ -29,6 +28,7 @@ from .error_message import ErrorMessageParams
29
28
  from .error_response import ErrorResponseParams
30
29
  from .error_response_data import ErrorResponseDataParams
31
30
  from .events_data import EventsDataParams
31
+ from .flush_signal import FlushSignalParams
32
32
  from .initialize_connection import InitializeConnectionParams
33
33
  from .initialize_connection_data import InitializeConnectionDataParams
34
34
  from .language_identification_response import LanguageIdentificationResponseParams
@@ -64,7 +64,6 @@ __all__ = [
64
64
  "ChatCompletionRequestUserMessageParams",
65
65
  "ChatCompletionResponseMessageParams",
66
66
  "ChoiceParams",
67
- "CloseConnectionParams",
68
67
  "CompletionUsageParams",
69
68
  "ConfigMessageParams",
70
69
  "CreateChatCompletionResponseParams",
@@ -76,6 +75,7 @@ __all__ = [
76
75
  "ErrorResponseDataParams",
77
76
  "ErrorResponseParams",
78
77
  "EventsDataParams",
78
+ "FlushSignalParams",
79
79
  "InitializeConnectionDataParams",
80
80
  "InitializeConnectionParams",
81
81
  "LanguageIdentificationResponseParams",
@@ -5,5 +5,5 @@ import typing
5
5
  import typing_extensions
6
6
 
7
7
 
8
- class CloseConnectionParams(typing_extensions.TypedDict):
8
+ class FlushSignalParams(typing_extensions.TypedDict):
9
9
  type: typing.Literal["flush"]
@@ -0,0 +1,275 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import json
4
+ import typing
5
+
6
+ import websockets
7
+ import websockets.sync.connection as websockets_sync_connection
8
+ from ..core.events import EventEmitterMixin, EventType
9
+ from ..core.pydantic_utilities import parse_obj_as
10
+ from ..types.audio_output import AudioOutput
11
+ from ..types.flush_signal import FlushSignal
12
+ from ..types.error_response import ErrorResponse
13
+ from ..types.initialize_connection import InitializeConnection
14
+ from ..types.initialize_connection_data import InitializeConnectionData
15
+ from ..types.ping_signal import PingSignal
16
+ from ..types.send_text import SendText
17
+ from ..types.send_text_data import SendTextData
18
+
19
+ TextToSpeechStreamingSocketClientResponse = typing.Union[AudioOutput, ErrorResponse]
20
+
21
+
22
+ class AsyncTextToSpeechStreamingSocketClient(EventEmitterMixin):
23
+ def __init__(self, *, websocket: websockets.WebSocketClientProtocol):
24
+ super().__init__()
25
+ self._websocket = websocket
26
+
27
+ async def __aiter__(self):
28
+ async for message in self._websocket:
29
+ message = json.loads(message) if isinstance(message, str) else message
30
+ yield parse_obj_as(TextToSpeechStreamingSocketClientResponse, message) # type: ignore
31
+
32
+ async def start_listening(self):
33
+ """
34
+ Start listening for messages on the websocket connection.
35
+
36
+ Emits events in the following order:
37
+ - EventType.OPEN when connection is established
38
+ - EventType.MESSAGE for each message received
39
+ - EventType.ERROR if an error occurs
40
+ - EventType.CLOSE when connection is closed
41
+ """
42
+ self._emit(EventType.OPEN, None)
43
+ try:
44
+ async for raw_message in self._websocket:
45
+ raw_message = (
46
+ json.loads(raw_message)
47
+ if isinstance(raw_message, str)
48
+ else raw_message
49
+ )
50
+ parsed = parse_obj_as(TextToSpeechStreamingSocketClientResponse, raw_message) # type: ignore
51
+ self._emit(EventType.MESSAGE, parsed)
52
+ except websockets.WebSocketException as exc:
53
+ self._emit(EventType.ERROR, exc)
54
+ finally:
55
+ self._emit(EventType.CLOSE, None)
56
+
57
+ async def initialize_connection(
58
+ self,
59
+ target_language_code: str,
60
+ speaker: str,
61
+ pitch: float = 0.0,
62
+ pace: float = 1.0,
63
+ loudness: float = 1.0,
64
+ speech_sample_rate: int = 22050,
65
+ enable_preprocessing: bool = False,
66
+ output_audio_codec: str = "mp3",
67
+ output_audio_bitrate: str = "128k",
68
+ min_buffer_size: int = 50,
69
+ max_chunk_length: int = 150,
70
+ ) -> None:
71
+ """
72
+ Initialize the TTS connection with configuration parameters.
73
+
74
+ :param target_language_code: Target language code (e.g., 'hi-IN')
75
+ :param speaker: Voice speaker name (e.g., 'meera', 'arvind')
76
+ :param pitch: Voice pitch adjustment (-1.0 to 1.0, default: 0.0)
77
+ :param pace: Speech pace (0.3 to 3.0, default: 1.0)
78
+ :param loudness: Voice loudness (0.1 to 3.0, default: 1.0)
79
+ :param speech_sample_rate: Audio sample rate, default: 22050
80
+ :param enable_preprocessing: Enable text preprocessing, default: False
81
+ :param output_audio_codec: Audio codec, default: 'mp3'
82
+ :param output_audio_bitrate: Audio bitrate, default: '128k'
83
+ :param min_buffer_size: Minimum buffer size, default: 50
84
+ :param max_chunk_length: Maximum chunk length, default: 150
85
+ """
86
+ data = InitializeConnectionData(
87
+ target_language_code=target_language_code,
88
+ speaker=speaker,
89
+ pitch=pitch,
90
+ pace=pace,
91
+ loudness=loudness,
92
+ speech_sample_rate=speech_sample_rate,
93
+ enable_preprocessing=enable_preprocessing,
94
+ output_audio_codec=output_audio_codec,
95
+ output_audio_bitrate=output_audio_bitrate,
96
+ min_buffer_size=min_buffer_size,
97
+ max_chunk_length=max_chunk_length,
98
+ )
99
+ message = InitializeConnection(data=data)
100
+ await self._send_model(message)
101
+
102
+ async def convert(self, text: str) -> None:
103
+ """
104
+ Send text to be converted to speech.
105
+
106
+ :param text: Text to be synthesized (1-2500 characters)
107
+ """
108
+ data = SendTextData(text=text)
109
+ message = SendText(data=data)
110
+ await self._send_model(message)
111
+
112
+ async def flush(self) -> None:
113
+ """
114
+ Signal to flush the buffer and finalize audio output.
115
+ This indicates the end of text input.
116
+ """
117
+ message = FlushSignal()
118
+ await self._send_model(message)
119
+
120
+ async def ping(self) -> None:
121
+ """
122
+ Send ping signal to keep the WebSocket connection alive.
123
+ """
124
+ message = PingSignal()
125
+ await self._send_model(message)
126
+
127
+ async def recv(self) -> TextToSpeechStreamingSocketClientResponse:
128
+ """
129
+ Receive a message from the websocket connection.
130
+ """
131
+ data = await self._websocket.recv()
132
+ data = json.loads(data) if isinstance(data, str) else data
133
+ return parse_obj_as(TextToSpeechStreamingSocketClientResponse, data) # type: ignore
134
+
135
+ async def _send(self, data: typing.Any) -> None:
136
+ """
137
+ Send a message to the websocket connection.
138
+ """
139
+ if isinstance(data, dict):
140
+ data = json.dumps(data)
141
+ await self._websocket.send(data)
142
+
143
+ async def _send_model(self, data: typing.Any) -> None:
144
+ """
145
+ Send a Pydantic model to the websocket connection.
146
+ """
147
+ await self._send(data.dict())
148
+
149
+
150
+ class TextToSpeechStreamingSocketClient(EventEmitterMixin):
151
+ def __init__(self, *, websocket: websockets_sync_connection.Connection):
152
+ super().__init__()
153
+ self._websocket = websocket
154
+
155
+ def __iter__(self):
156
+ for message in self._websocket:
157
+ message = json.loads(message) if isinstance(message, str) else message
158
+ yield parse_obj_as(TextToSpeechStreamingSocketClientResponse, message) # type: ignore
159
+
160
+ def start_listening(self):
161
+ """
162
+ Start listening for messages on the websocket connection.
163
+
164
+ Emits events in the following order:
165
+ - EventType.OPEN when connection is established
166
+ - EventType.MESSAGE for each message received
167
+ - EventType.ERROR if an error occurs
168
+ - EventType.CLOSE when connection is closed
169
+ """
170
+ self._emit(EventType.OPEN, None)
171
+ try:
172
+ for raw_message in self._websocket:
173
+ raw_message = (
174
+ json.loads(raw_message)
175
+ if isinstance(raw_message, str)
176
+ else raw_message
177
+ )
178
+ parsed = parse_obj_as(TextToSpeechStreamingSocketClientResponse, raw_message) # type: ignore
179
+ self._emit(EventType.MESSAGE, parsed)
180
+ except websockets.WebSocketException as exc:
181
+ self._emit(EventType.ERROR, exc)
182
+ finally:
183
+ self._emit(EventType.CLOSE, None)
184
+
185
+ def initialize_connection(
186
+ self,
187
+ target_language_code: str,
188
+ speaker: str,
189
+ pitch: float = 0.0,
190
+ pace: float = 1.0,
191
+ loudness: float = 1.0,
192
+ speech_sample_rate: int = 22050,
193
+ enable_preprocessing: bool = False,
194
+ output_audio_codec: str = "mp3",
195
+ output_audio_bitrate: str = "128k",
196
+ min_buffer_size: int = 50,
197
+ max_chunk_length: int = 150,
198
+ ) -> None:
199
+ """
200
+ Initialize the TTS connection with configuration parameters.
201
+
202
+ :param target_language_code: Target language code (e.g., 'hi-IN')
203
+ :param speaker: Voice speaker name (e.g., 'meera', 'arvind')
204
+ :param pitch: Voice pitch adjustment (-1.0 to 1.0, default: 0.0)
205
+ :param pace: Speech pace (0.3 to 3.0, default: 1.0)
206
+ :param loudness: Voice loudness (0.1 to 3.0, default: 1.0)
207
+ :param speech_sample_rate: Audio sample rate, default: 22050
208
+ :param enable_preprocessing: Enable text preprocessing, default: False
209
+ :param output_audio_codec: Audio codec, default: 'mp3'
210
+ :param output_audio_bitrate: Audio bitrate, default: '128k'
211
+ :param min_buffer_size: Minimum buffer size, default: 50
212
+ :param max_chunk_length: Maximum chunk length, default: 150
213
+ """
214
+ data = InitializeConnectionData(
215
+ target_language_code=target_language_code,
216
+ speaker=speaker,
217
+ pitch=pitch,
218
+ pace=pace,
219
+ loudness=loudness,
220
+ speech_sample_rate=speech_sample_rate,
221
+ enable_preprocessing=enable_preprocessing,
222
+ output_audio_codec=output_audio_codec,
223
+ output_audio_bitrate=output_audio_bitrate,
224
+ min_buffer_size=min_buffer_size,
225
+ max_chunk_length=max_chunk_length,
226
+ )
227
+ message = InitializeConnection(data=data)
228
+ self._send_model(message)
229
+
230
+ def convert(self, text: str) -> None:
231
+ """
232
+ Send text to be converted to speech.
233
+
234
+ :param text: Text to be synthesized (1-2500 characters)
235
+ """
236
+ data = SendTextData(text=text)
237
+ message = SendText(data=data)
238
+ self._send_model(message)
239
+
240
+ def flush(self) -> None:
241
+ """
242
+ Signal to flush the buffer and finalize audio output.
243
+ This indicates the end of text input.
244
+ """
245
+ message = FlushSignal()
246
+ self._send_model(message)
247
+
248
+ def ping(self) -> None:
249
+ """
250
+ Send ping signal to keep the WebSocket connection alive.
251
+ """
252
+ message = PingSignal()
253
+ self._send_model(message)
254
+
255
+ def recv(self) -> TextToSpeechStreamingSocketClientResponse:
256
+ """
257
+ Receive a message from the websocket connection.
258
+ """
259
+ data = self._websocket.recv()
260
+ data = json.loads(data) if isinstance(data, str) else data
261
+ return parse_obj_as(TextToSpeechStreamingSocketClientResponse, data) # type: ignore
262
+
263
+ def _send(self, data: typing.Any) -> None:
264
+ """
265
+ Send a message to the websocket connection.
266
+ """
267
+ if isinstance(data, dict):
268
+ data = json.dumps(data)
269
+ self._websocket.send(data)
270
+
271
+ def _send_model(self, data: typing.Any) -> None:
272
+ """
273
+ Send a Pydantic model to the websocket connection.
274
+ """
275
+ self._send(data.dict())
@@ -17,7 +17,6 @@ from .chat_completion_request_system_message import ChatCompletionRequestSystemM
17
17
  from .chat_completion_request_user_message import ChatCompletionRequestUserMessage
18
18
  from .chat_completion_response_message import ChatCompletionResponseMessage
19
19
  from .choice import Choice
20
- from .close_connection import CloseConnection
21
20
  from .completion_usage import CompletionUsage
22
21
  from .config_message import ConfigMessage
23
22
  from .create_chat_completion_response import CreateChatCompletionResponse
@@ -31,6 +30,7 @@ from .error_response import ErrorResponse
31
30
  from .error_response_data import ErrorResponseData
32
31
  from .events_data import EventsData
33
32
  from .finish_reason import FinishReason
33
+ from .flush_signal import FlushSignal
34
34
  from .format import Format
35
35
  from .initialize_connection import InitializeConnection
36
36
  from .initialize_connection_data import InitializeConnectionData
@@ -92,7 +92,6 @@ __all__ = [
92
92
  "ChatCompletionRequestUserMessage",
93
93
  "ChatCompletionResponseMessage",
94
94
  "Choice",
95
- "CloseConnection",
96
95
  "CompletionUsage",
97
96
  "ConfigMessage",
98
97
  "CreateChatCompletionResponse",
@@ -106,6 +105,7 @@ __all__ = [
106
105
  "ErrorResponseData",
107
106
  "EventsData",
108
107
  "FinishReason",
108
+ "FlushSignal",
109
109
  "Format",
110
110
  "InitializeConnection",
111
111
  "InitializeConnectionData",
@@ -6,7 +6,7 @@ import pydantic
6
6
  from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
7
7
 
8
8
 
9
- class CloseConnection(UniversalBaseModel):
9
+ class FlushSignal(UniversalBaseModel):
10
10
  type: typing.Literal["flush"] = "flush"
11
11
 
12
12
  if IS_PYDANTIC_V2:
@@ -1,175 +0,0 @@
1
- # This file was auto-generated by Fern from our API Definition.
2
-
3
- import json
4
- import typing
5
-
6
- import websockets
7
- import websockets.sync.connection as websockets_sync_connection
8
- from ..core.events import EventEmitterMixin, EventType
9
- from ..core.pydantic_utilities import parse_obj_as
10
- from ..types.audio_output import AudioOutput
11
- from ..types.close_connection import CloseConnection
12
- from ..types.error_response import ErrorResponse
13
- from ..types.initialize_connection import InitializeConnection
14
- from ..types.ping_signal import PingSignal
15
- from ..types.send_text import SendText
16
-
17
- TextToSpeechStreamingSocketClientResponse = typing.Union[AudioOutput, ErrorResponse]
18
-
19
-
20
- class AsyncTextToSpeechStreamingSocketClient(EventEmitterMixin):
21
- def __init__(self, *, websocket: websockets.WebSocketClientProtocol):
22
- super().__init__()
23
- self._websocket = websocket
24
-
25
- async def __aiter__(self):
26
- async for message in self._websocket:
27
- yield parse_obj_as(TextToSpeechStreamingSocketClientResponse, message) # type: ignore
28
-
29
- async def start_listening(self):
30
- """
31
- Start listening for messages on the websocket connection.
32
-
33
- Emits events in the following order:
34
- - EventType.OPEN when connection is established
35
- - EventType.MESSAGE for each message received
36
- - EventType.ERROR if an error occurs
37
- - EventType.CLOSE when connection is closed
38
- """
39
- self._emit(EventType.OPEN, None)
40
- try:
41
- async for raw_message in self._websocket:
42
- parsed = parse_obj_as(TextToSpeechStreamingSocketClientResponse, raw_message) # type: ignore
43
- self._emit(EventType.MESSAGE, parsed)
44
- except websockets.WebSocketException as exc:
45
- self._emit(EventType.ERROR, exc)
46
- finally:
47
- self._emit(EventType.CLOSE, None)
48
-
49
- async def send_initialize_connection(self, message: InitializeConnection) -> None:
50
- """
51
- Send a message to the websocket connection.
52
- The message will be sent as a InitializeConnection.
53
- """
54
- await self._send_model(message)
55
-
56
- async def send_send_text(self, message: SendText) -> None:
57
- """
58
- Send a message to the websocket connection.
59
- The message will be sent as a SendText.
60
- """
61
- await self._send_model(message)
62
-
63
- async def send_close_connection(self, message: CloseConnection) -> None:
64
- """
65
- Send a message to the websocket connection.
66
- The message will be sent as a CloseConnection.
67
- """
68
- await self._send_model(message)
69
-
70
- async def send_ping_signal(self, message: PingSignal) -> None:
71
- """
72
- Send a message to the websocket connection.
73
- The message will be sent as a PingSignal.
74
- """
75
- await self._send_model(message)
76
-
77
- async def recv(self) -> TextToSpeechStreamingSocketClientResponse:
78
- """
79
- Receive a message from the websocket connection.
80
- """
81
- data = await self._websocket.recv()
82
- return parse_obj_as(TextToSpeechStreamingSocketClientResponse, data) # type: ignore
83
-
84
- async def _send(self, data: typing.Any) -> None:
85
- """
86
- Send a message to the websocket connection.
87
- """
88
- if isinstance(data, dict):
89
- data = json.dumps(data)
90
- await self._websocket.send(data)
91
-
92
- async def _send_model(self, data: typing.Any) -> None:
93
- """
94
- Send a Pydantic model to the websocket connection.
95
- """
96
- await self._send(data.dict())
97
-
98
-
99
- class TextToSpeechStreamingSocketClient(EventEmitterMixin):
100
- def __init__(self, *, websocket: websockets_sync_connection.Connection):
101
- super().__init__()
102
- self._websocket = websocket
103
-
104
- def __iter__(self):
105
- for message in self._websocket:
106
- yield parse_obj_as(TextToSpeechStreamingSocketClientResponse, message) # type: ignore
107
-
108
- def start_listening(self):
109
- """
110
- Start listening for messages on the websocket connection.
111
-
112
- Emits events in the following order:
113
- - EventType.OPEN when connection is established
114
- - EventType.MESSAGE for each message received
115
- - EventType.ERROR if an error occurs
116
- - EventType.CLOSE when connection is closed
117
- """
118
- self._emit(EventType.OPEN, None)
119
- try:
120
- for raw_message in self._websocket:
121
- parsed = parse_obj_as(TextToSpeechStreamingSocketClientResponse, raw_message) # type: ignore
122
- self._emit(EventType.MESSAGE, parsed)
123
- except websockets.WebSocketException as exc:
124
- self._emit(EventType.ERROR, exc)
125
- finally:
126
- self._emit(EventType.CLOSE, None)
127
-
128
- def send_initialize_connection(self, message: InitializeConnection) -> None:
129
- """
130
- Send a message to the websocket connection.
131
- The message will be sent as a InitializeConnection.
132
- """
133
- self._send_model(message)
134
-
135
- def send_send_text(self, message: SendText) -> None:
136
- """
137
- Send a message to the websocket connection.
138
- The message will be sent as a SendText.
139
- """
140
- self._send_model(message)
141
-
142
- def send_close_connection(self, message: CloseConnection) -> None:
143
- """
144
- Send a message to the websocket connection.
145
- The message will be sent as a CloseConnection.
146
- """
147
- self._send_model(message)
148
-
149
- def send_ping_signal(self, message: PingSignal) -> None:
150
- """
151
- Send a message to the websocket connection.
152
- The message will be sent as a PingSignal.
153
- """
154
- self._send_model(message)
155
-
156
- def recv(self) -> TextToSpeechStreamingSocketClientResponse:
157
- """
158
- Receive a message from the websocket connection.
159
- """
160
- data = self._websocket.recv()
161
- return parse_obj_as(TextToSpeechStreamingSocketClientResponse, data) # type: ignore
162
-
163
- def _send(self, data: typing.Any) -> None:
164
- """
165
- Send a message to the websocket connection.
166
- """
167
- if isinstance(data, dict):
168
- data = json.dumps(data)
169
- self._websocket.send(data)
170
-
171
- def _send_model(self, data: typing.Any) -> None:
172
- """
173
- Send a Pydantic model to the websocket connection.
174
- """
175
- self._send(data.dict())
File without changes