casedev 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. casedev/__init__.py +104 -0
  2. casedev/_base_client.py +1995 -0
  3. casedev/_client.py +560 -0
  4. casedev/_compat.py +219 -0
  5. casedev/_constants.py +14 -0
  6. casedev/_exceptions.py +108 -0
  7. casedev/_files.py +123 -0
  8. casedev/_models.py +857 -0
  9. casedev/_qs.py +150 -0
  10. casedev/_resource.py +43 -0
  11. casedev/_response.py +830 -0
  12. casedev/_streaming.py +333 -0
  13. casedev/_types.py +260 -0
  14. casedev/_utils/__init__.py +64 -0
  15. casedev/_utils/_compat.py +45 -0
  16. casedev/_utils/_datetime_parse.py +136 -0
  17. casedev/_utils/_logs.py +25 -0
  18. casedev/_utils/_proxy.py +65 -0
  19. casedev/_utils/_reflection.py +42 -0
  20. casedev/_utils/_resources_proxy.py +24 -0
  21. casedev/_utils/_streams.py +12 -0
  22. casedev/_utils/_sync.py +58 -0
  23. casedev/_utils/_transform.py +457 -0
  24. casedev/_utils/_typing.py +156 -0
  25. casedev/_utils/_utils.py +421 -0
  26. casedev/_version.py +4 -0
  27. casedev/lib/.keep +4 -0
  28. casedev/py.typed +0 -0
  29. casedev/resources/__init__.py +173 -0
  30. casedev/resources/actions/__init__.py +33 -0
  31. casedev/resources/actions/actions.py +102 -0
  32. casedev/resources/actions/v1.py +640 -0
  33. casedev/resources/compute/__init__.py +33 -0
  34. casedev/resources/compute/compute.py +102 -0
  35. casedev/resources/compute/v1/__init__.py +89 -0
  36. casedev/resources/compute/v1/environments.py +492 -0
  37. casedev/resources/compute/v1/functions.py +278 -0
  38. casedev/resources/compute/v1/invoke.py +216 -0
  39. casedev/resources/compute/v1/runs.py +290 -0
  40. casedev/resources/compute/v1/secrets.py +655 -0
  41. casedev/resources/compute/v1/v1.py +583 -0
  42. casedev/resources/convert/__init__.py +33 -0
  43. casedev/resources/convert/convert.py +102 -0
  44. casedev/resources/convert/v1/__init__.py +33 -0
  45. casedev/resources/convert/v1/jobs.py +254 -0
  46. casedev/resources/convert/v1/v1.py +450 -0
  47. casedev/resources/format/__init__.py +33 -0
  48. casedev/resources/format/format.py +102 -0
  49. casedev/resources/format/v1/__init__.py +33 -0
  50. casedev/resources/format/v1/templates.py +419 -0
  51. casedev/resources/format/v1/v1.py +244 -0
  52. casedev/resources/llm/__init__.py +33 -0
  53. casedev/resources/llm/llm.py +192 -0
  54. casedev/resources/llm/v1/__init__.py +33 -0
  55. casedev/resources/llm/v1/chat.py +243 -0
  56. casedev/resources/llm/v1/v1.py +317 -0
  57. casedev/resources/ocr/__init__.py +33 -0
  58. casedev/resources/ocr/ocr.py +102 -0
  59. casedev/resources/ocr/v1.py +407 -0
  60. casedev/resources/search/__init__.py +33 -0
  61. casedev/resources/search/search.py +102 -0
  62. casedev/resources/search/v1.py +1052 -0
  63. casedev/resources/templates/__init__.py +33 -0
  64. casedev/resources/templates/templates.py +102 -0
  65. casedev/resources/templates/v1.py +633 -0
  66. casedev/resources/vault/__init__.py +47 -0
  67. casedev/resources/vault/graphrag.py +256 -0
  68. casedev/resources/vault/objects.py +571 -0
  69. casedev/resources/vault/vault.py +764 -0
  70. casedev/resources/voice/__init__.py +61 -0
  71. casedev/resources/voice/streaming.py +160 -0
  72. casedev/resources/voice/transcription.py +327 -0
  73. casedev/resources/voice/v1/__init__.py +33 -0
  74. casedev/resources/voice/v1/speak.py +478 -0
  75. casedev/resources/voice/v1/v1.py +290 -0
  76. casedev/resources/voice/voice.py +166 -0
  77. casedev/resources/webhooks/__init__.py +33 -0
  78. casedev/resources/webhooks/v1.py +447 -0
  79. casedev/resources/webhooks/webhooks.py +102 -0
  80. casedev/resources/workflows/__init__.py +33 -0
  81. casedev/resources/workflows/v1.py +1053 -0
  82. casedev/resources/workflows/workflows.py +102 -0
  83. casedev/types/__init__.py +12 -0
  84. casedev/types/actions/__init__.py +8 -0
  85. casedev/types/actions/v1_create_params.py +22 -0
  86. casedev/types/actions/v1_create_response.py +33 -0
  87. casedev/types/actions/v1_execute_params.py +16 -0
  88. casedev/types/actions/v1_execute_response.py +31 -0
  89. casedev/types/compute/__init__.py +7 -0
  90. casedev/types/compute/v1/__init__.py +18 -0
  91. casedev/types/compute/v1/environment_create_params.py +12 -0
  92. casedev/types/compute/v1/environment_create_response.py +34 -0
  93. casedev/types/compute/v1/environment_delete_response.py +11 -0
  94. casedev/types/compute/v1/function_get_logs_params.py +12 -0
  95. casedev/types/compute/v1/function_list_params.py +12 -0
  96. casedev/types/compute/v1/invoke_run_params.py +21 -0
  97. casedev/types/compute/v1/invoke_run_response.py +39 -0
  98. casedev/types/compute/v1/run_list_params.py +18 -0
  99. casedev/types/compute/v1/secret_create_params.py +24 -0
  100. casedev/types/compute/v1/secret_create_response.py +24 -0
  101. casedev/types/compute/v1/secret_delete_group_params.py +18 -0
  102. casedev/types/compute/v1/secret_list_params.py +15 -0
  103. casedev/types/compute/v1/secret_retrieve_group_params.py +12 -0
  104. casedev/types/compute/v1/secret_update_group_params.py +16 -0
  105. casedev/types/compute/v1_deploy_params.py +114 -0
  106. casedev/types/compute/v1_deploy_response.py +30 -0
  107. casedev/types/compute/v1_get_usage_params.py +15 -0
  108. casedev/types/convert/__init__.py +8 -0
  109. casedev/types/convert/v1/__init__.py +3 -0
  110. casedev/types/convert/v1_process_params.py +15 -0
  111. casedev/types/convert/v1_process_response.py +19 -0
  112. casedev/types/convert/v1_webhook_params.py +32 -0
  113. casedev/types/convert/v1_webhook_response.py +13 -0
  114. casedev/types/format/__init__.py +5 -0
  115. casedev/types/format/v1/__init__.py +7 -0
  116. casedev/types/format/v1/template_create_params.py +32 -0
  117. casedev/types/format/v1/template_create_response.py +27 -0
  118. casedev/types/format/v1/template_list_params.py +12 -0
  119. casedev/types/format/v1_create_document_params.py +42 -0
  120. casedev/types/llm/__init__.py +5 -0
  121. casedev/types/llm/v1/__init__.py +6 -0
  122. casedev/types/llm/v1/chat_create_completion_params.py +42 -0
  123. casedev/types/llm/v1/chat_create_completion_response.py +49 -0
  124. casedev/types/llm/v1_create_embedding_params.py +27 -0
  125. casedev/types/ocr/__init__.py +6 -0
  126. casedev/types/ocr/v1_process_params.py +44 -0
  127. casedev/types/ocr/v1_process_response.py +32 -0
  128. casedev/types/search/__init__.py +15 -0
  129. casedev/types/search/v1_answer_params.py +45 -0
  130. casedev/types/search/v1_answer_response.py +35 -0
  131. casedev/types/search/v1_contents_params.py +42 -0
  132. casedev/types/search/v1_contents_response.py +31 -0
  133. casedev/types/search/v1_research_params.py +23 -0
  134. casedev/types/search/v1_research_response.py +20 -0
  135. casedev/types/search/v1_retrieve_research_params.py +15 -0
  136. casedev/types/search/v1_search_params.py +56 -0
  137. casedev/types/search/v1_search_response.py +38 -0
  138. casedev/types/search/v1_similar_params.py +44 -0
  139. casedev/types/search/v1_similar_response.py +33 -0
  140. casedev/types/templates/__init__.py +8 -0
  141. casedev/types/templates/v1_execute_params.py +22 -0
  142. casedev/types/templates/v1_execute_response.py +31 -0
  143. casedev/types/templates/v1_list_params.py +32 -0
  144. casedev/types/templates/v1_search_params.py +18 -0
  145. casedev/types/vault/__init__.py +6 -0
  146. casedev/types/vault/object_create_presigned_url_params.py +22 -0
  147. casedev/types/vault/object_create_presigned_url_response.py +51 -0
  148. casedev/types/vault_create_params.py +20 -0
  149. casedev/types/vault_create_response.py +36 -0
  150. casedev/types/vault_ingest_response.py +26 -0
  151. casedev/types/vault_list_response.py +40 -0
  152. casedev/types/vault_search_params.py +27 -0
  153. casedev/types/vault_search_response.py +53 -0
  154. casedev/types/vault_upload_params.py +26 -0
  155. casedev/types/vault_upload_response.py +39 -0
  156. casedev/types/voice/__init__.py +7 -0
  157. casedev/types/voice/transcription_create_params.py +36 -0
  158. casedev/types/voice/transcription_retrieve_response.py +41 -0
  159. casedev/types/voice/v1/__init__.py +6 -0
  160. casedev/types/voice/v1/speak_create_params.py +59 -0
  161. casedev/types/voice/v1/speak_stream_params.py +58 -0
  162. casedev/types/voice/v1_list_voices_params.py +36 -0
  163. casedev/types/webhooks/__init__.py +6 -0
  164. casedev/types/webhooks/v1_create_params.py +20 -0
  165. casedev/types/webhooks/v1_create_response.py +33 -0
  166. casedev/types/workflows/__init__.py +19 -0
  167. casedev/types/workflows/v1_create_params.py +32 -0
  168. casedev/types/workflows/v1_create_response.py +29 -0
  169. casedev/types/workflows/v1_delete_response.py +13 -0
  170. casedev/types/workflows/v1_deploy_response.py +20 -0
  171. casedev/types/workflows/v1_execute_params.py +12 -0
  172. casedev/types/workflows/v1_execute_response.py +22 -0
  173. casedev/types/workflows/v1_list_executions_params.py +13 -0
  174. casedev/types/workflows/v1_list_executions_response.py +27 -0
  175. casedev/types/workflows/v1_list_params.py +18 -0
  176. casedev/types/workflows/v1_list_response.py +37 -0
  177. casedev/types/workflows/v1_retrieve_execution_response.py +31 -0
  178. casedev/types/workflows/v1_retrieve_response.py +35 -0
  179. casedev/types/workflows/v1_undeploy_response.py +13 -0
  180. casedev/types/workflows/v1_update_params.py +26 -0
  181. casedev/types/workflows/v1_update_response.py +17 -0
  182. casedev-0.1.0.dist-info/METADATA +454 -0
  183. casedev-0.1.0.dist-info/RECORD +185 -0
  184. casedev-0.1.0.dist-info/WHEEL +4 -0
  185. casedev-0.1.0.dist-info/licenses/LICENSE +201 -0
@@ -0,0 +1,478 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing_extensions import Literal
6
+
7
+ import httpx
8
+
9
+ from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
10
+ from ...._utils import maybe_transform, async_maybe_transform
11
+ from ...._compat import cached_property
12
+ from ...._resource import SyncAPIResource, AsyncAPIResource
13
+ from ...._response import (
14
+ BinaryAPIResponse,
15
+ AsyncBinaryAPIResponse,
16
+ StreamedBinaryAPIResponse,
17
+ AsyncStreamedBinaryAPIResponse,
18
+ to_custom_raw_response_wrapper,
19
+ to_custom_streamed_response_wrapper,
20
+ async_to_custom_raw_response_wrapper,
21
+ async_to_custom_streamed_response_wrapper,
22
+ )
23
+ from ...._base_client import make_request_options
24
+ from ....types.voice.v1 import speak_create_params, speak_stream_params
25
+
26
+ __all__ = ["SpeakResource", "AsyncSpeakResource"]
27
+
28
+
29
+ class SpeakResource(SyncAPIResource):
30
+ @cached_property
31
+ def with_raw_response(self) -> SpeakResourceWithRawResponse:
32
+ """
33
+ This property can be used as a prefix for any HTTP method call to return
34
+ the raw response object instead of the parsed content.
35
+
36
+ For more information, see https://www.github.com/CaseMark/casedev-python#accessing-raw-response-data-eg-headers
37
+ """
38
+ return SpeakResourceWithRawResponse(self)
39
+
40
+ @cached_property
41
+ def with_streaming_response(self) -> SpeakResourceWithStreamingResponse:
42
+ """
43
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
44
+
45
+ For more information, see https://www.github.com/CaseMark/casedev-python#with_streaming_response
46
+ """
47
+ return SpeakResourceWithStreamingResponse(self)
48
+
49
+ def create(
50
+ self,
51
+ *,
52
+ text: str,
53
+ apply_text_normalization: bool | Omit = omit,
54
+ enable_logging: bool | Omit = omit,
55
+ language_code: str | Omit = omit,
56
+ model_id: Literal["eleven_multilingual_v2", "eleven_turbo_v2", "eleven_monolingual_v1"] | Omit = omit,
57
+ next_text: str | Omit = omit,
58
+ optimize_streaming_latency: int | Omit = omit,
59
+ output_format: Literal["mp3_44100_128", "mp3_44100_192", "pcm_16000", "pcm_22050", "pcm_24000", "pcm_44100"]
60
+ | Omit = omit,
61
+ previous_text: str | Omit = omit,
62
+ seed: int | Omit = omit,
63
+ voice_id: str | Omit = omit,
64
+ voice_settings: speak_create_params.VoiceSettings | Omit = omit,
65
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
66
+ # The extra values given here take precedence over values defined on the client or passed to this method.
67
+ extra_headers: Headers | None = None,
68
+ extra_query: Query | None = None,
69
+ extra_body: Body | None = None,
70
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
71
+ ) -> BinaryAPIResponse:
72
+ """Convert text to natural-sounding audio using ElevenLabs voices.
73
+
74
+ Ideal for
75
+ creating audio summaries of legal documents, client presentations, or
76
+ accessibility features. Supports multiple languages and voice customization.
77
+
78
+ Args:
79
+ text: Text to convert to speech
80
+
81
+ apply_text_normalization: Apply automatic text normalization
82
+
83
+ enable_logging: Enable request logging
84
+
85
+ language_code: Language code for multilingual models
86
+
87
+ model_id: ElevenLabs model ID
88
+
89
+ next_text: Next context for better pronunciation
90
+
91
+ optimize_streaming_latency: Optimize for streaming latency (0-4)
92
+
93
+ output_format: Audio output format
94
+
95
+ previous_text: Previous context for better pronunciation
96
+
97
+ seed: Seed for reproducible generation
98
+
99
+ voice_id: ElevenLabs voice ID (defaults to Rachel - professional, clear)
100
+
101
+ voice_settings: Voice customization settings
102
+
103
+ extra_headers: Send extra headers
104
+
105
+ extra_query: Add additional query parameters to the request
106
+
107
+ extra_body: Add additional JSON properties to the request
108
+
109
+ timeout: Override the client-level default timeout for this request, in seconds
110
+ """
111
+ extra_headers = {"Accept": "audio/mpeg", **(extra_headers or {})}
112
+ return self._post(
113
+ "/voice/v1/speak",
114
+ body=maybe_transform(
115
+ {
116
+ "text": text,
117
+ "apply_text_normalization": apply_text_normalization,
118
+ "enable_logging": enable_logging,
119
+ "language_code": language_code,
120
+ "model_id": model_id,
121
+ "next_text": next_text,
122
+ "optimize_streaming_latency": optimize_streaming_latency,
123
+ "output_format": output_format,
124
+ "previous_text": previous_text,
125
+ "seed": seed,
126
+ "voice_id": voice_id,
127
+ "voice_settings": voice_settings,
128
+ },
129
+ speak_create_params.SpeakCreateParams,
130
+ ),
131
+ options=make_request_options(
132
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
133
+ ),
134
+ cast_to=BinaryAPIResponse,
135
+ )
136
+
137
+ def stream(
138
+ self,
139
+ *,
140
+ text: str,
141
+ apply_text_normalization: bool | Omit = omit,
142
+ enable_logging: bool | Omit = omit,
143
+ language_code: str | Omit = omit,
144
+ model_id: Literal[
145
+ "eleven_monolingual_v1", "eleven_multilingual_v1", "eleven_multilingual_v2", "eleven_turbo_v2"
146
+ ]
147
+ | Omit = omit,
148
+ next_text: str | Omit = omit,
149
+ optimize_streaming_latency: int | Omit = omit,
150
+ output_format: Literal["mp3_44100_128", "mp3_22050_32", "pcm_16000", "pcm_22050", "pcm_24000", "pcm_44100"]
151
+ | Omit = omit,
152
+ previous_text: str | Omit = omit,
153
+ seed: int | Omit = omit,
154
+ voice_id: str | Omit = omit,
155
+ voice_settings: speak_stream_params.VoiceSettings | Omit = omit,
156
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
157
+ # The extra values given here take precedence over values defined on the client or passed to this method.
158
+ extra_headers: Headers | None = None,
159
+ extra_query: Query | None = None,
160
+ extra_body: Body | None = None,
161
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
162
+ ) -> BinaryAPIResponse:
163
+ """
164
+ Convert text to speech using ElevenLabs AI voices with streaming for real-time
165
+ playback. Returns audio data as an MP3 stream for immediate playback with
166
+ minimal latency. Perfect for legal document narration, client presentations, or
167
+ accessibility features.
168
+
169
+ Args:
170
+ text: Text to convert to speech
171
+
172
+ apply_text_normalization: Apply text normalization
173
+
174
+ enable_logging: Enable request logging
175
+
176
+ language_code: Language code (e.g., 'en', 'es', 'fr')
177
+
178
+ model_id: TTS model to use
179
+
180
+ next_text: Next text for context
181
+
182
+ optimize_streaming_latency: Optimize for streaming latency (0-4)
183
+
184
+ output_format: Audio output format
185
+
186
+ previous_text: Previous text for context
187
+
188
+ seed: Random seed for reproducible generation
189
+
190
+ voice_id: ElevenLabs voice ID (defaults to Rachel for professional clarity)
191
+
192
+ extra_headers: Send extra headers
193
+
194
+ extra_query: Add additional query parameters to the request
195
+
196
+ extra_body: Add additional JSON properties to the request
197
+
198
+ timeout: Override the client-level default timeout for this request, in seconds
199
+ """
200
+ extra_headers = {"Accept": "audio/mpeg", **(extra_headers or {})}
201
+ return self._post(
202
+ "/voice/v1/speak/stream",
203
+ body=maybe_transform(
204
+ {
205
+ "text": text,
206
+ "apply_text_normalization": apply_text_normalization,
207
+ "enable_logging": enable_logging,
208
+ "language_code": language_code,
209
+ "model_id": model_id,
210
+ "next_text": next_text,
211
+ "optimize_streaming_latency": optimize_streaming_latency,
212
+ "output_format": output_format,
213
+ "previous_text": previous_text,
214
+ "seed": seed,
215
+ "voice_id": voice_id,
216
+ "voice_settings": voice_settings,
217
+ },
218
+ speak_stream_params.SpeakStreamParams,
219
+ ),
220
+ options=make_request_options(
221
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
222
+ ),
223
+ cast_to=BinaryAPIResponse,
224
+ )
225
+
226
+
227
+ class AsyncSpeakResource(AsyncAPIResource):
228
+ @cached_property
229
+ def with_raw_response(self) -> AsyncSpeakResourceWithRawResponse:
230
+ """
231
+ This property can be used as a prefix for any HTTP method call to return
232
+ the raw response object instead of the parsed content.
233
+
234
+ For more information, see https://www.github.com/CaseMark/casedev-python#accessing-raw-response-data-eg-headers
235
+ """
236
+ return AsyncSpeakResourceWithRawResponse(self)
237
+
238
+ @cached_property
239
+ def with_streaming_response(self) -> AsyncSpeakResourceWithStreamingResponse:
240
+ """
241
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
242
+
243
+ For more information, see https://www.github.com/CaseMark/casedev-python#with_streaming_response
244
+ """
245
+ return AsyncSpeakResourceWithStreamingResponse(self)
246
+
247
+ async def create(
248
+ self,
249
+ *,
250
+ text: str,
251
+ apply_text_normalization: bool | Omit = omit,
252
+ enable_logging: bool | Omit = omit,
253
+ language_code: str | Omit = omit,
254
+ model_id: Literal["eleven_multilingual_v2", "eleven_turbo_v2", "eleven_monolingual_v1"] | Omit = omit,
255
+ next_text: str | Omit = omit,
256
+ optimize_streaming_latency: int | Omit = omit,
257
+ output_format: Literal["mp3_44100_128", "mp3_44100_192", "pcm_16000", "pcm_22050", "pcm_24000", "pcm_44100"]
258
+ | Omit = omit,
259
+ previous_text: str | Omit = omit,
260
+ seed: int | Omit = omit,
261
+ voice_id: str | Omit = omit,
262
+ voice_settings: speak_create_params.VoiceSettings | Omit = omit,
263
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
264
+ # The extra values given here take precedence over values defined on the client or passed to this method.
265
+ extra_headers: Headers | None = None,
266
+ extra_query: Query | None = None,
267
+ extra_body: Body | None = None,
268
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
269
+ ) -> AsyncBinaryAPIResponse:
270
+ """Convert text to natural-sounding audio using ElevenLabs voices.
271
+
272
+ Ideal for
273
+ creating audio summaries of legal documents, client presentations, or
274
+ accessibility features. Supports multiple languages and voice customization.
275
+
276
+ Args:
277
+ text: Text to convert to speech
278
+
279
+ apply_text_normalization: Apply automatic text normalization
280
+
281
+ enable_logging: Enable request logging
282
+
283
+ language_code: Language code for multilingual models
284
+
285
+ model_id: ElevenLabs model ID
286
+
287
+ next_text: Next context for better pronunciation
288
+
289
+ optimize_streaming_latency: Optimize for streaming latency (0-4)
290
+
291
+ output_format: Audio output format
292
+
293
+ previous_text: Previous context for better pronunciation
294
+
295
+ seed: Seed for reproducible generation
296
+
297
+ voice_id: ElevenLabs voice ID (defaults to Rachel - professional, clear)
298
+
299
+ voice_settings: Voice customization settings
300
+
301
+ extra_headers: Send extra headers
302
+
303
+ extra_query: Add additional query parameters to the request
304
+
305
+ extra_body: Add additional JSON properties to the request
306
+
307
+ timeout: Override the client-level default timeout for this request, in seconds
308
+ """
309
+ extra_headers = {"Accept": "audio/mpeg", **(extra_headers or {})}
310
+ return await self._post(
311
+ "/voice/v1/speak",
312
+ body=await async_maybe_transform(
313
+ {
314
+ "text": text,
315
+ "apply_text_normalization": apply_text_normalization,
316
+ "enable_logging": enable_logging,
317
+ "language_code": language_code,
318
+ "model_id": model_id,
319
+ "next_text": next_text,
320
+ "optimize_streaming_latency": optimize_streaming_latency,
321
+ "output_format": output_format,
322
+ "previous_text": previous_text,
323
+ "seed": seed,
324
+ "voice_id": voice_id,
325
+ "voice_settings": voice_settings,
326
+ },
327
+ speak_create_params.SpeakCreateParams,
328
+ ),
329
+ options=make_request_options(
330
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
331
+ ),
332
+ cast_to=AsyncBinaryAPIResponse,
333
+ )
334
+
335
+ async def stream(
336
+ self,
337
+ *,
338
+ text: str,
339
+ apply_text_normalization: bool | Omit = omit,
340
+ enable_logging: bool | Omit = omit,
341
+ language_code: str | Omit = omit,
342
+ model_id: Literal[
343
+ "eleven_monolingual_v1", "eleven_multilingual_v1", "eleven_multilingual_v2", "eleven_turbo_v2"
344
+ ]
345
+ | Omit = omit,
346
+ next_text: str | Omit = omit,
347
+ optimize_streaming_latency: int | Omit = omit,
348
+ output_format: Literal["mp3_44100_128", "mp3_22050_32", "pcm_16000", "pcm_22050", "pcm_24000", "pcm_44100"]
349
+ | Omit = omit,
350
+ previous_text: str | Omit = omit,
351
+ seed: int | Omit = omit,
352
+ voice_id: str | Omit = omit,
353
+ voice_settings: speak_stream_params.VoiceSettings | Omit = omit,
354
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
355
+ # The extra values given here take precedence over values defined on the client or passed to this method.
356
+ extra_headers: Headers | None = None,
357
+ extra_query: Query | None = None,
358
+ extra_body: Body | None = None,
359
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
360
+ ) -> AsyncBinaryAPIResponse:
361
+ """
362
+ Convert text to speech using ElevenLabs AI voices with streaming for real-time
363
+ playback. Returns audio data as an MP3 stream for immediate playback with
364
+ minimal latency. Perfect for legal document narration, client presentations, or
365
+ accessibility features.
366
+
367
+ Args:
368
+ text: Text to convert to speech
369
+
370
+ apply_text_normalization: Apply text normalization
371
+
372
+ enable_logging: Enable request logging
373
+
374
+ language_code: Language code (e.g., 'en', 'es', 'fr')
375
+
376
+ model_id: TTS model to use
377
+
378
+ next_text: Next text for context
379
+
380
+ optimize_streaming_latency: Optimize for streaming latency (0-4)
381
+
382
+ output_format: Audio output format
383
+
384
+ previous_text: Previous text for context
385
+
386
+ seed: Random seed for reproducible generation
387
+
388
+ voice_id: ElevenLabs voice ID (defaults to Rachel for professional clarity)
389
+
390
+ extra_headers: Send extra headers
391
+
392
+ extra_query: Add additional query parameters to the request
393
+
394
+ extra_body: Add additional JSON properties to the request
395
+
396
+ timeout: Override the client-level default timeout for this request, in seconds
397
+ """
398
+ extra_headers = {"Accept": "audio/mpeg", **(extra_headers or {})}
399
+ return await self._post(
400
+ "/voice/v1/speak/stream",
401
+ body=await async_maybe_transform(
402
+ {
403
+ "text": text,
404
+ "apply_text_normalization": apply_text_normalization,
405
+ "enable_logging": enable_logging,
406
+ "language_code": language_code,
407
+ "model_id": model_id,
408
+ "next_text": next_text,
409
+ "optimize_streaming_latency": optimize_streaming_latency,
410
+ "output_format": output_format,
411
+ "previous_text": previous_text,
412
+ "seed": seed,
413
+ "voice_id": voice_id,
414
+ "voice_settings": voice_settings,
415
+ },
416
+ speak_stream_params.SpeakStreamParams,
417
+ ),
418
+ options=make_request_options(
419
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
420
+ ),
421
+ cast_to=AsyncBinaryAPIResponse,
422
+ )
423
+
424
+
425
+ class SpeakResourceWithRawResponse:
426
+ def __init__(self, speak: SpeakResource) -> None:
427
+ self._speak = speak
428
+
429
+ self.create = to_custom_raw_response_wrapper(
430
+ speak.create,
431
+ BinaryAPIResponse,
432
+ )
433
+ self.stream = to_custom_raw_response_wrapper(
434
+ speak.stream,
435
+ BinaryAPIResponse,
436
+ )
437
+
438
+
439
+ class AsyncSpeakResourceWithRawResponse:
440
+ def __init__(self, speak: AsyncSpeakResource) -> None:
441
+ self._speak = speak
442
+
443
+ self.create = async_to_custom_raw_response_wrapper(
444
+ speak.create,
445
+ AsyncBinaryAPIResponse,
446
+ )
447
+ self.stream = async_to_custom_raw_response_wrapper(
448
+ speak.stream,
449
+ AsyncBinaryAPIResponse,
450
+ )
451
+
452
+
453
+ class SpeakResourceWithStreamingResponse:
454
+ def __init__(self, speak: SpeakResource) -> None:
455
+ self._speak = speak
456
+
457
+ self.create = to_custom_streamed_response_wrapper(
458
+ speak.create,
459
+ StreamedBinaryAPIResponse,
460
+ )
461
+ self.stream = to_custom_streamed_response_wrapper(
462
+ speak.stream,
463
+ StreamedBinaryAPIResponse,
464
+ )
465
+
466
+
467
+ class AsyncSpeakResourceWithStreamingResponse:
468
+ def __init__(self, speak: AsyncSpeakResource) -> None:
469
+ self._speak = speak
470
+
471
+ self.create = async_to_custom_streamed_response_wrapper(
472
+ speak.create,
473
+ AsyncStreamedBinaryAPIResponse,
474
+ )
475
+ self.stream = async_to_custom_streamed_response_wrapper(
476
+ speak.stream,
477
+ AsyncStreamedBinaryAPIResponse,
478
+ )