cartesia 2.0.5__tar.gz → 2.0.7__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 (209) hide show
  1. cartesia-2.0.7/LICENSE +201 -0
  2. {cartesia-2.0.5 → cartesia-2.0.7}/PKG-INFO +116 -17
  3. {cartesia-2.0.5 → cartesia-2.0.7}/README.md +112 -15
  4. {cartesia-2.0.5 → cartesia-2.0.7}/pyproject.toml +1 -1
  5. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/__init__.py +22 -0
  6. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/auth/client.py +8 -8
  7. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/auth/requests/token_grant.py +7 -1
  8. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/auth/requests/token_request.py +3 -3
  9. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/auth/types/token_grant.py +7 -2
  10. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/auth/types/token_request.py +3 -3
  11. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/core/client_wrapper.py +1 -1
  12. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/infill/client.py +0 -8
  13. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/stt/__init__.py +6 -0
  14. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/stt/_async_websocket.py +81 -72
  15. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/stt/_websocket.py +42 -20
  16. cartesia-2.0.7/src/cartesia/stt/client.py +450 -0
  17. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/stt/requests/__init__.py +2 -0
  18. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/stt/requests/streaming_transcription_response.py +2 -0
  19. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/stt/requests/transcript_message.py +8 -1
  20. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/stt/requests/transcription_response.py +8 -1
  21. cartesia-2.0.7/src/cartesia/stt/requests/transcription_word.py +20 -0
  22. cartesia-2.0.7/src/cartesia/stt/socket_client.py +138 -0
  23. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/stt/types/__init__.py +4 -0
  24. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/stt/types/streaming_transcription_response.py +2 -0
  25. cartesia-2.0.7/src/cartesia/stt/types/stt_encoding.py +7 -0
  26. cartesia-2.0.5/src/cartesia/stt/types/stt_encoding.py → cartesia-2.0.7/src/cartesia/stt/types/timestamp_granularity.py +1 -1
  27. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/stt/types/transcript_message.py +7 -1
  28. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/stt/types/transcription_response.py +7 -1
  29. cartesia-2.0.7/src/cartesia/stt/types/transcription_word.py +32 -0
  30. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/__init__.py +16 -0
  31. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/client.py +63 -8
  32. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/requests/__init__.py +8 -0
  33. cartesia-2.0.7/src/cartesia/tts/requests/experimental_model_controls.py +17 -0
  34. cartesia-2.0.7/src/cartesia/tts/requests/generation_config.py +23 -0
  35. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/requests/generation_request.py +4 -4
  36. cartesia-2.0.7/src/cartesia/tts/requests/sse_output_format.py +11 -0
  37. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/requests/tts_request.py +2 -0
  38. cartesia-2.0.7/src/cartesia/tts/requests/ttssse_request.py +47 -0
  39. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/requests/web_socket_chunk_response.py +0 -3
  40. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/requests/web_socket_response.py +1 -2
  41. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/requests/web_socket_tts_request.py +9 -1
  42. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/types/__init__.py +8 -0
  43. cartesia-2.0.7/src/cartesia/tts/types/experimental_model_controls.py +28 -0
  44. cartesia-2.0.7/src/cartesia/tts/types/generation_config.py +34 -0
  45. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/types/generation_request.py +4 -4
  46. cartesia-2.0.7/src/cartesia/tts/types/sse_output_format.py +22 -0
  47. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/types/tts_request.py +2 -0
  48. cartesia-2.0.7/src/cartesia/tts/types/ttssse_request.py +58 -0
  49. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/types/web_socket_chunk_response.py +1 -3
  50. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/types/web_socket_response.py +1 -2
  51. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/types/web_socket_tts_request.py +11 -3
  52. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/voice_changer/client.py +0 -8
  53. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/voice_changer/requests/streaming_response.py +0 -2
  54. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/voice_changer/types/streaming_response.py +0 -2
  55. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/voices/client.py +0 -12
  56. cartesia-2.0.5/src/cartesia/stt/socket_client.py +0 -195
  57. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/api_status/__init__.py +0 -0
  58. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/api_status/client.py +0 -0
  59. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/api_status/requests/__init__.py +0 -0
  60. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/api_status/requests/api_info.py +0 -0
  61. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/api_status/types/__init__.py +0 -0
  62. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/api_status/types/api_info.py +0 -0
  63. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/auth/__init__.py +0 -0
  64. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/auth/requests/__init__.py +0 -0
  65. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/auth/requests/token_response.py +0 -0
  66. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/auth/types/__init__.py +0 -0
  67. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/auth/types/token_response.py +0 -0
  68. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/base_client.py +0 -0
  69. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/client.py +0 -0
  70. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/core/__init__.py +0 -0
  71. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/core/api_error.py +0 -0
  72. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/core/datetime_utils.py +0 -0
  73. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/core/file.py +0 -0
  74. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/core/http_client.py +0 -0
  75. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/core/jsonable_encoder.py +0 -0
  76. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/core/pagination.py +0 -0
  77. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/core/pydantic_utilities.py +0 -0
  78. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/core/query_encoder.py +0 -0
  79. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/core/remove_none_from_dict.py +0 -0
  80. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/core/request_options.py +0 -0
  81. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/core/serialization.py +0 -0
  82. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/datasets/__init__.py +0 -0
  83. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/datasets/requests/__init__.py +0 -0
  84. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/datasets/requests/create_dataset_request.py +0 -0
  85. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/datasets/requests/dataset.py +0 -0
  86. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/datasets/requests/dataset_file.py +0 -0
  87. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/datasets/requests/paginated_dataset_files.py +0 -0
  88. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/datasets/requests/paginated_datasets.py +0 -0
  89. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/datasets/types/__init__.py +0 -0
  90. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/datasets/types/create_dataset_request.py +0 -0
  91. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/datasets/types/dataset.py +0 -0
  92. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/datasets/types/dataset_file.py +0 -0
  93. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/datasets/types/file_purpose.py +0 -0
  94. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/datasets/types/paginated_dataset_files.py +0 -0
  95. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/datasets/types/paginated_datasets.py +0 -0
  96. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/embedding/__init__.py +0 -0
  97. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/embedding/types/__init__.py +0 -0
  98. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/embedding/types/embedding.py +0 -0
  99. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/environment.py +0 -0
  100. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/infill/__init__.py +0 -0
  101. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/py.typed +0 -0
  102. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/stt/requests/done_message.py +0 -0
  103. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/stt/requests/error_message.py +0 -0
  104. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/stt/requests/flush_done_message.py +0 -0
  105. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/stt/types/done_message.py +0 -0
  106. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/stt/types/error_message.py +0 -0
  107. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/stt/types/flush_done_message.py +0 -0
  108. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/_async_websocket.py +0 -0
  109. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/_websocket.py +0 -0
  110. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/requests/cancel_context_request.py +0 -0
  111. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/requests/controls.py +0 -0
  112. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/requests/mp_3_output_format.py +0 -0
  113. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/requests/output_format.py +0 -0
  114. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/requests/phoneme_timestamps.py +0 -0
  115. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/requests/raw_output_format.py +0 -0
  116. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/requests/speed.py +0 -0
  117. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/requests/tts_request_embedding_specifier.py +0 -0
  118. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/requests/tts_request_id_specifier.py +0 -0
  119. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/requests/tts_request_voice_specifier.py +0 -0
  120. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/requests/wav_output_format.py +0 -0
  121. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/requests/web_socket_base_response.py +0 -0
  122. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/requests/web_socket_done_response.py +0 -0
  123. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/requests/web_socket_error_response.py +0 -0
  124. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/requests/web_socket_flush_done_response.py +0 -0
  125. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/requests/web_socket_phoneme_timestamps_response.py +0 -0
  126. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/requests/web_socket_raw_output_format.py +0 -0
  127. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/requests/web_socket_request.py +0 -0
  128. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/requests/web_socket_stream_options.py +0 -0
  129. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/requests/web_socket_timestamps_response.py +0 -0
  130. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/requests/web_socket_tts_output.py +0 -0
  131. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/requests/word_timestamps.py +0 -0
  132. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/socket_client.py +0 -0
  133. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/types/cancel_context_request.py +0 -0
  134. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/types/context_id.py +0 -0
  135. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/types/controls.py +0 -0
  136. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/types/emotion.py +0 -0
  137. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/types/flush_id.py +0 -0
  138. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/types/model_speed.py +0 -0
  139. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/types/mp_3_output_format.py +0 -0
  140. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/types/natural_specifier.py +0 -0
  141. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/types/numerical_specifier.py +0 -0
  142. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/types/output_format.py +0 -0
  143. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/types/phoneme_timestamps.py +0 -0
  144. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/types/raw_encoding.py +0 -0
  145. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/types/raw_output_format.py +0 -0
  146. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/types/speed.py +0 -0
  147. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/types/supported_language.py +0 -0
  148. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/types/tts_request_embedding_specifier.py +0 -0
  149. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/types/tts_request_id_specifier.py +0 -0
  150. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/types/tts_request_voice_specifier.py +0 -0
  151. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/types/wav_output_format.py +0 -0
  152. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/types/web_socket_base_response.py +0 -0
  153. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/types/web_socket_done_response.py +0 -0
  154. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/types/web_socket_error_response.py +0 -0
  155. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/types/web_socket_flush_done_response.py +0 -0
  156. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/types/web_socket_phoneme_timestamps_response.py +0 -0
  157. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/types/web_socket_raw_output_format.py +0 -0
  158. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/types/web_socket_request.py +0 -0
  159. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/types/web_socket_stream_options.py +0 -0
  160. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/types/web_socket_timestamps_response.py +0 -0
  161. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/types/web_socket_tts_output.py +0 -0
  162. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/types/word_timestamps.py +0 -0
  163. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/utils/constants.py +0 -0
  164. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/utils/tts.py +0 -0
  165. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/tts/utils/types.py +0 -0
  166. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/version.py +0 -0
  167. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/voice_changer/__init__.py +0 -0
  168. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/voice_changer/requests/__init__.py +0 -0
  169. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/voice_changer/types/__init__.py +0 -0
  170. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/voice_changer/types/output_format_container.py +0 -0
  171. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/voices/__init__.py +0 -0
  172. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/voices/requests/__init__.py +0 -0
  173. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/voices/requests/create_voice_request.py +0 -0
  174. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/voices/requests/embedding_response.py +0 -0
  175. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/voices/requests/embedding_specifier.py +0 -0
  176. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/voices/requests/get_voices_response.py +0 -0
  177. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/voices/requests/id_specifier.py +0 -0
  178. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/voices/requests/localize_dialect.py +0 -0
  179. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/voices/requests/localize_voice_request.py +0 -0
  180. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/voices/requests/mix_voice_specifier.py +0 -0
  181. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/voices/requests/mix_voices_request.py +0 -0
  182. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/voices/requests/update_voice_request.py +0 -0
  183. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/voices/requests/voice.py +0 -0
  184. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/voices/requests/voice_metadata.py +0 -0
  185. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/voices/types/__init__.py +0 -0
  186. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/voices/types/base_voice_id.py +0 -0
  187. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/voices/types/clone_mode.py +0 -0
  188. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/voices/types/create_voice_request.py +0 -0
  189. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/voices/types/embedding_response.py +0 -0
  190. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/voices/types/embedding_specifier.py +0 -0
  191. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/voices/types/gender.py +0 -0
  192. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/voices/types/gender_presentation.py +0 -0
  193. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/voices/types/get_voices_response.py +0 -0
  194. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/voices/types/id_specifier.py +0 -0
  195. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/voices/types/localize_dialect.py +0 -0
  196. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/voices/types/localize_english_dialect.py +0 -0
  197. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/voices/types/localize_french_dialect.py +0 -0
  198. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/voices/types/localize_portuguese_dialect.py +0 -0
  199. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/voices/types/localize_spanish_dialect.py +0 -0
  200. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/voices/types/localize_target_language.py +0 -0
  201. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/voices/types/localize_voice_request.py +0 -0
  202. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/voices/types/mix_voice_specifier.py +0 -0
  203. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/voices/types/mix_voices_request.py +0 -0
  204. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/voices/types/update_voice_request.py +0 -0
  205. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/voices/types/voice.py +0 -0
  206. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/voices/types/voice_expand_options.py +0 -0
  207. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/voices/types/voice_id.py +0 -0
  208. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/voices/types/voice_metadata.py +0 -0
  209. {cartesia-2.0.5 → cartesia-2.0.7}/src/cartesia/voices/types/weight.py +0 -0
cartesia-2.0.7/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: cartesia
3
- Version: 2.0.5
3
+ Version: 2.0.7
4
4
  Summary:
5
5
  Requires-Python: >=3.8,<4.0
6
6
  Classifier: Intended Audience :: Developers
@@ -16,6 +16,7 @@ Classifier: Programming Language :: Python :: 3.9
16
16
  Classifier: Programming Language :: Python :: 3.10
17
17
  Classifier: Programming Language :: Python :: 3.11
18
18
  Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
19
20
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
21
  Classifier: Typing :: Typed
21
22
  Requires-Dist: aiohttp (>=3.10.10)
@@ -28,6 +29,7 @@ Requires-Dist: pydantic-core (>=2.18.2,<3.0.0)
28
29
  Requires-Dist: pydub (>=0.25.1)
29
30
  Requires-Dist: typing_extensions (>=4.0.0)
30
31
  Requires-Dist: websockets (>=10.4)
32
+ Project-URL: Repository, https://github.com/cartesia-ai/cartesia-python
31
33
  Description-Content-Type: text/markdown
32
34
 
33
35
  # Cartesia Python Library
@@ -230,12 +232,14 @@ with open("path/to/audio.wav", "rb") as f:
230
232
  chunk_size = 640
231
233
  audio_chunks = [audio_data[i:i+chunk_size] for i in range(0, len(audio_data), chunk_size)]
232
234
 
233
- # Create websocket connection
235
+ # Create websocket connection with endpointing parameters
234
236
  ws = client.stt.websocket(
235
- model="ink-whisper",
236
- language="en", # Must match the language of your audio
237
- encoding="pcm_s16le", # Must match your audio's encoding format
238
- sample_rate=16000, # Must match your audio's sample rate
237
+ model="ink-whisper", # Model (required)
238
+ language="en", # Language of your audio (required)
239
+ encoding="pcm_s16le", # Audio encoding format (required)
240
+ sample_rate=16000, # Audio sample rate (required)
241
+ min_volume=0.1, # Volume threshold for voice activity detection
242
+ max_silence_duration_secs=0.4, # Maximum silence duration before endpointing
239
243
  )
240
244
 
241
245
  # Send audio chunks (streaming approach)
@@ -246,10 +250,20 @@ for chunk in audio_chunks:
246
250
  ws.send("finalize")
247
251
  ws.send("done")
248
252
 
249
- # Receive transcription results
253
+ # Receive transcription results with word-level timestamps
250
254
  for result in ws.receive():
251
255
  if result['type'] == 'transcript':
252
256
  print(f"Transcription: {result['text']}")
257
+
258
+ # Handle word-level timestamps if available
259
+ if 'words' in result and result['words']:
260
+ print("Word-level timestamps:")
261
+ for word_info in result['words']:
262
+ word = word_info['word']
263
+ start = word_info['start']
264
+ end = word_info['end']
265
+ print(f" '{word}': {start:.2f}s - {end:.2f}s")
266
+
253
267
  if result['is_final']:
254
268
  print("Final result received")
255
269
  elif result['type'] == 'done':
@@ -270,17 +284,20 @@ from cartesia import AsyncCartesia
270
284
  async def streaming_stt_example():
271
285
  """
272
286
  Advanced async STT example for real-time streaming applications.
273
- This example simulates streaming audio processing with proper error handling.
287
+ This example simulates streaming audio processing with proper error handling
288
+ and demonstrates the new endpointing and word timestamp features.
274
289
  """
275
290
  client = AsyncCartesia(api_key=os.getenv("CARTESIA_API_KEY"))
276
291
 
277
292
  try:
278
- # Create websocket connection
293
+ # Create websocket connection with voice activity detection
279
294
  ws = await client.stt.websocket(
280
- model="ink-whisper",
281
- language="en", # Must match the language of your audio
282
- encoding="pcm_s16le", # Must match your audio's encoding format
283
- sample_rate=16000, # Must match your audio's sample rate
295
+ model="ink-whisper", # Model (required)
296
+ language="en", # Language of your audio (required)
297
+ encoding="pcm_s16le", # Audio encoding format (required)
298
+ sample_rate=16000, # Audio sample rate (required)
299
+ min_volume=0.15, # Volume threshold for voice activity detection
300
+ max_silence_duration_secs=0.3, # Maximum silence duration before endpointing
284
301
  )
285
302
 
286
303
  # Simulate streaming audio data (replace with your audio source)
@@ -319,8 +336,9 @@ async def streaming_stt_example():
319
336
  print(f"Error sending audio: {e}")
320
337
 
321
338
  async def receive_transcripts():
322
- """Receive and process transcription results"""
339
+ """Receive and process transcription results with word timestamps"""
323
340
  full_transcript = ""
341
+ all_word_timestamps = []
324
342
 
325
343
  try:
326
344
  async for result in ws.receive():
@@ -328,6 +346,19 @@ async def streaming_stt_example():
328
346
  text = result['text']
329
347
  is_final = result['is_final']
330
348
 
349
+ # Handle word-level timestamps
350
+ if 'words' in result and result['words']:
351
+ word_timestamps = result['words']
352
+ all_word_timestamps.extend(word_timestamps)
353
+
354
+ if is_final:
355
+ print("Word-level timestamps:")
356
+ for word_info in word_timestamps:
357
+ word = word_info['word']
358
+ start = word_info['start']
359
+ end = word_info['end']
360
+ print(f" '{word}': {start:.2f}s - {end:.2f}s")
361
+
331
362
  if is_final:
332
363
  # Final result - this text won't change
333
364
  full_transcript += text + " "
@@ -343,17 +374,18 @@ async def streaming_stt_example():
343
374
  except Exception as e:
344
375
  print(f"Error receiving transcripts: {e}")
345
376
 
346
- return full_transcript.strip()
377
+ return full_transcript.strip(), all_word_timestamps
347
378
 
348
379
  print("Starting streaming STT...")
349
380
 
350
381
  # Use asyncio.gather to run audio sending and transcript receiving concurrently
351
- _, final_transcript = await asyncio.gather(
382
+ _, (final_transcript, word_timestamps) = await asyncio.gather(
352
383
  send_audio(),
353
384
  receive_transcripts()
354
385
  )
355
386
 
356
387
  print(f"\nComplete transcript: {final_transcript}")
388
+ print(f"Total words with timestamps: {len(word_timestamps)}")
357
389
 
358
390
  # Clean up
359
391
  await ws.close()
@@ -368,6 +400,73 @@ if __name__ == "__main__":
368
400
  asyncio.run(streaming_stt_example())
369
401
  ```
370
402
 
403
+ ## Batch Speech-to-Text (STT)
404
+
405
+ For processing pre-recorded audio files, use the batch STT API which supports uploading complete audio files for transcription:
406
+
407
+ ```python
408
+ from cartesia import Cartesia
409
+ import os
410
+
411
+ client = Cartesia(api_key=os.getenv("CARTESIA_API_KEY"))
412
+
413
+ # Transcribe an audio file with word-level timestamps
414
+ with open("path/to/audio.wav", "rb") as audio_file:
415
+ response = client.stt.transcribe(
416
+ file=audio_file, # Audio file to transcribe
417
+ model="ink-whisper", # STT model (required)
418
+ language="en", # Language of the audio (optional)
419
+ timestamp_granularities=["word"], # Include word-level timestamps (optional)
420
+ encoding="pcm_s16le", # Audio encoding (optional)
421
+ sample_rate=16000, # Audio sample rate (optional)
422
+ )
423
+
424
+ # Access transcription results
425
+ print(f"Transcribed text: {response.text}")
426
+ print(f"Audio duration: {response.duration:.2f} seconds")
427
+
428
+ # Process word-level timestamps if requested
429
+ if response.words:
430
+ print("\nWord-level timestamps:")
431
+ for word_info in response.words:
432
+ word = word_info.word
433
+ start = word_info.start
434
+ end = word_info.end
435
+ print(f" '{word}': {start:.2f}s - {end:.2f}s")
436
+ ```
437
+
438
+ ### Async Batch STT
439
+
440
+ ```python
441
+ import asyncio
442
+ from cartesia import AsyncCartesia
443
+ import os
444
+
445
+ async def transcribe_file():
446
+ client = AsyncCartesia(api_key=os.getenv("CARTESIA_API_KEY"))
447
+
448
+ with open("path/to/audio.wav", "rb") as audio_file:
449
+ response = await client.stt.transcribe(
450
+ file=audio_file,
451
+ model="ink-whisper",
452
+ language="en",
453
+ timestamp_granularities=["word"],
454
+ )
455
+
456
+ print(f"Transcribed text: {response.text}")
457
+
458
+ # Process word timestamps
459
+ if response.words:
460
+ for word_info in response.words:
461
+ print(f"'{word_info.word}': {word_info.start:.2f}s - {word_info.end:.2f}s")
462
+
463
+ await client.close()
464
+
465
+ asyncio.run(transcribe_file())
466
+ ```
467
+
468
+ > **Note:** Batch STT also supports OpenAI's audio transcriptions format for easy migration from OpenAI Whisper. See our [migration guide](https://docs.cartesia.ai/api-reference/stt/migrate-from-open-ai) for details.
469
+
371
470
  ## Voices
372
471
 
373
472
  List all available Voices with `client.voices.list`, which returns an iterable that automatically handles pagination:
@@ -198,12 +198,14 @@ with open("path/to/audio.wav", "rb") as f:
198
198
  chunk_size = 640
199
199
  audio_chunks = [audio_data[i:i+chunk_size] for i in range(0, len(audio_data), chunk_size)]
200
200
 
201
- # Create websocket connection
201
+ # Create websocket connection with endpointing parameters
202
202
  ws = client.stt.websocket(
203
- model="ink-whisper",
204
- language="en", # Must match the language of your audio
205
- encoding="pcm_s16le", # Must match your audio's encoding format
206
- sample_rate=16000, # Must match your audio's sample rate
203
+ model="ink-whisper", # Model (required)
204
+ language="en", # Language of your audio (required)
205
+ encoding="pcm_s16le", # Audio encoding format (required)
206
+ sample_rate=16000, # Audio sample rate (required)
207
+ min_volume=0.1, # Volume threshold for voice activity detection
208
+ max_silence_duration_secs=0.4, # Maximum silence duration before endpointing
207
209
  )
208
210
 
209
211
  # Send audio chunks (streaming approach)
@@ -214,10 +216,20 @@ for chunk in audio_chunks:
214
216
  ws.send("finalize")
215
217
  ws.send("done")
216
218
 
217
- # Receive transcription results
219
+ # Receive transcription results with word-level timestamps
218
220
  for result in ws.receive():
219
221
  if result['type'] == 'transcript':
220
222
  print(f"Transcription: {result['text']}")
223
+
224
+ # Handle word-level timestamps if available
225
+ if 'words' in result and result['words']:
226
+ print("Word-level timestamps:")
227
+ for word_info in result['words']:
228
+ word = word_info['word']
229
+ start = word_info['start']
230
+ end = word_info['end']
231
+ print(f" '{word}': {start:.2f}s - {end:.2f}s")
232
+
221
233
  if result['is_final']:
222
234
  print("Final result received")
223
235
  elif result['type'] == 'done':
@@ -238,17 +250,20 @@ from cartesia import AsyncCartesia
238
250
  async def streaming_stt_example():
239
251
  """
240
252
  Advanced async STT example for real-time streaming applications.
241
- This example simulates streaming audio processing with proper error handling.
253
+ This example simulates streaming audio processing with proper error handling
254
+ and demonstrates the new endpointing and word timestamp features.
242
255
  """
243
256
  client = AsyncCartesia(api_key=os.getenv("CARTESIA_API_KEY"))
244
257
 
245
258
  try:
246
- # Create websocket connection
259
+ # Create websocket connection with voice activity detection
247
260
  ws = await client.stt.websocket(
248
- model="ink-whisper",
249
- language="en", # Must match the language of your audio
250
- encoding="pcm_s16le", # Must match your audio's encoding format
251
- sample_rate=16000, # Must match your audio's sample rate
261
+ model="ink-whisper", # Model (required)
262
+ language="en", # Language of your audio (required)
263
+ encoding="pcm_s16le", # Audio encoding format (required)
264
+ sample_rate=16000, # Audio sample rate (required)
265
+ min_volume=0.15, # Volume threshold for voice activity detection
266
+ max_silence_duration_secs=0.3, # Maximum silence duration before endpointing
252
267
  )
253
268
 
254
269
  # Simulate streaming audio data (replace with your audio source)
@@ -287,8 +302,9 @@ async def streaming_stt_example():
287
302
  print(f"Error sending audio: {e}")
288
303
 
289
304
  async def receive_transcripts():
290
- """Receive and process transcription results"""
305
+ """Receive and process transcription results with word timestamps"""
291
306
  full_transcript = ""
307
+ all_word_timestamps = []
292
308
 
293
309
  try:
294
310
  async for result in ws.receive():
@@ -296,6 +312,19 @@ async def streaming_stt_example():
296
312
  text = result['text']
297
313
  is_final = result['is_final']
298
314
 
315
+ # Handle word-level timestamps
316
+ if 'words' in result and result['words']:
317
+ word_timestamps = result['words']
318
+ all_word_timestamps.extend(word_timestamps)
319
+
320
+ if is_final:
321
+ print("Word-level timestamps:")
322
+ for word_info in word_timestamps:
323
+ word = word_info['word']
324
+ start = word_info['start']
325
+ end = word_info['end']
326
+ print(f" '{word}': {start:.2f}s - {end:.2f}s")
327
+
299
328
  if is_final:
300
329
  # Final result - this text won't change
301
330
  full_transcript += text + " "
@@ -311,17 +340,18 @@ async def streaming_stt_example():
311
340
  except Exception as e:
312
341
  print(f"Error receiving transcripts: {e}")
313
342
 
314
- return full_transcript.strip()
343
+ return full_transcript.strip(), all_word_timestamps
315
344
 
316
345
  print("Starting streaming STT...")
317
346
 
318
347
  # Use asyncio.gather to run audio sending and transcript receiving concurrently
319
- _, final_transcript = await asyncio.gather(
348
+ _, (final_transcript, word_timestamps) = await asyncio.gather(
320
349
  send_audio(),
321
350
  receive_transcripts()
322
351
  )
323
352
 
324
353
  print(f"\nComplete transcript: {final_transcript}")
354
+ print(f"Total words with timestamps: {len(word_timestamps)}")
325
355
 
326
356
  # Clean up
327
357
  await ws.close()
@@ -336,6 +366,73 @@ if __name__ == "__main__":
336
366
  asyncio.run(streaming_stt_example())
337
367
  ```
338
368
 
369
+ ## Batch Speech-to-Text (STT)
370
+
371
+ For processing pre-recorded audio files, use the batch STT API which supports uploading complete audio files for transcription:
372
+
373
+ ```python
374
+ from cartesia import Cartesia
375
+ import os
376
+
377
+ client = Cartesia(api_key=os.getenv("CARTESIA_API_KEY"))
378
+
379
+ # Transcribe an audio file with word-level timestamps
380
+ with open("path/to/audio.wav", "rb") as audio_file:
381
+ response = client.stt.transcribe(
382
+ file=audio_file, # Audio file to transcribe
383
+ model="ink-whisper", # STT model (required)
384
+ language="en", # Language of the audio (optional)
385
+ timestamp_granularities=["word"], # Include word-level timestamps (optional)
386
+ encoding="pcm_s16le", # Audio encoding (optional)
387
+ sample_rate=16000, # Audio sample rate (optional)
388
+ )
389
+
390
+ # Access transcription results
391
+ print(f"Transcribed text: {response.text}")
392
+ print(f"Audio duration: {response.duration:.2f} seconds")
393
+
394
+ # Process word-level timestamps if requested
395
+ if response.words:
396
+ print("\nWord-level timestamps:")
397
+ for word_info in response.words:
398
+ word = word_info.word
399
+ start = word_info.start
400
+ end = word_info.end
401
+ print(f" '{word}': {start:.2f}s - {end:.2f}s")
402
+ ```
403
+
404
+ ### Async Batch STT
405
+
406
+ ```python
407
+ import asyncio
408
+ from cartesia import AsyncCartesia
409
+ import os
410
+
411
+ async def transcribe_file():
412
+ client = AsyncCartesia(api_key=os.getenv("CARTESIA_API_KEY"))
413
+
414
+ with open("path/to/audio.wav", "rb") as audio_file:
415
+ response = await client.stt.transcribe(
416
+ file=audio_file,
417
+ model="ink-whisper",
418
+ language="en",
419
+ timestamp_granularities=["word"],
420
+ )
421
+
422
+ print(f"Transcribed text: {response.text}")
423
+
424
+ # Process word timestamps
425
+ if response.words:
426
+ for word_info in response.words:
427
+ print(f"'{word_info.word}': {word_info.start:.2f}s - {word_info.end:.2f}s")
428
+
429
+ await client.close()
430
+
431
+ asyncio.run(transcribe_file())
432
+ ```
433
+
434
+ > **Note:** Batch STT also supports OpenAI's audio transcriptions format for easy migration from OpenAI Whisper. See our [migration guide](https://docs.cartesia.ai/api-reference/stt/migrate-from-open-ai) for details.
435
+
339
436
  ## Voices
340
437
 
341
438
  List all available Voices with `client.voices.list`, which returns an iterable that automatically handles pagination:
@@ -3,7 +3,7 @@ name = "cartesia"
3
3
 
4
4
  [tool.poetry]
5
5
  name = "cartesia"
6
- version = "2.0.5"
6
+ version = "2.0.7"
7
7
  description = ""
8
8
  readme = "README.md"
9
9
  authors = []