spitch 1.1.0__py3-none-any.whl → 1.3.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.

Potentially problematic release.


This version of spitch might be problematic. Click here for more details.

spitch/_version.py CHANGED
@@ -1,4 +1,4 @@
1
1
  # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  __title__ = "spitch"
4
- __version__ = "1.1.0" # x-release-please-version
4
+ __version__ = "1.3.0" # x-release-please-version
@@ -2,7 +2,7 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- from typing import Optional
5
+ from typing import Mapping, Optional, cast
6
6
  from typing_extensions import Literal
7
7
 
8
8
  import httpx
@@ -10,19 +10,25 @@ import httpx
10
10
  from ..types import speech_generate_params, speech_transcibe_params
11
11
  from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven, FileTypes
12
12
  from .._utils import (
13
+ extract_files,
13
14
  maybe_transform,
15
+ deepcopy_minimal,
14
16
  async_maybe_transform,
15
17
  )
16
18
  from .._compat import cached_property
17
19
  from .._resource import SyncAPIResource, AsyncAPIResource
18
20
  from .._response import (
21
+ BinaryAPIResponse,
22
+ AsyncBinaryAPIResponse,
19
23
  StreamedBinaryAPIResponse,
20
24
  AsyncStreamedBinaryAPIResponse,
21
25
  to_raw_response_wrapper,
22
26
  to_streamed_response_wrapper,
23
27
  async_to_raw_response_wrapper,
28
+ to_custom_raw_response_wrapper,
24
29
  async_to_streamed_response_wrapper,
25
30
  to_custom_streamed_response_wrapper,
31
+ async_to_custom_raw_response_wrapper,
26
32
  async_to_custom_streamed_response_wrapper,
27
33
  )
28
34
  from .._base_client import make_request_options
@@ -63,7 +69,7 @@ class SpeechResource(SyncAPIResource):
63
69
  extra_query: Query | None = None,
64
70
  extra_body: Body | None = None,
65
71
  timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
66
- ) -> object:
72
+ ) -> BinaryAPIResponse:
67
73
  """
68
74
  Synthesize
69
75
 
@@ -76,6 +82,7 @@ class SpeechResource(SyncAPIResource):
76
82
 
77
83
  timeout: Override the client-level default timeout for this request, in seconds
78
84
  """
85
+ extra_headers = {"Accept": "audio/wav", **(extra_headers or {})}
79
86
  return self._post(
80
87
  "/v1/speech",
81
88
  body=maybe_transform(
@@ -93,7 +100,7 @@ class SpeechResource(SyncAPIResource):
93
100
  timeout=timeout,
94
101
  query=maybe_transform({"stream": stream}, speech_generate_params.SpeechGenerateParams),
95
102
  ),
96
- cast_to=object,
103
+ cast_to=BinaryAPIResponse,
97
104
  )
98
105
 
99
106
  def transcibe(
@@ -121,16 +128,22 @@ class SpeechResource(SyncAPIResource):
121
128
 
122
129
  timeout: Override the client-level default timeout for this request, in seconds
123
130
  """
131
+ body = deepcopy_minimal(
132
+ {
133
+ "language": language,
134
+ "content": content,
135
+ "url": url,
136
+ }
137
+ )
138
+ files = extract_files(cast(Mapping[str, object], body), paths=[["content"]])
139
+ # It should be noted that the actual Content-Type header that will be
140
+ # sent to the server will contain a `boundary` parameter, e.g.
141
+ # multipart/form-data; boundary=---abc--
142
+ extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
124
143
  return self._post(
125
144
  "/v1/transcriptions",
126
- body=maybe_transform(
127
- {
128
- "language": language,
129
- "content": content,
130
- "url": url,
131
- },
132
- speech_transcibe_params.SpeechTranscibeParams,
133
- ),
145
+ body=maybe_transform(body, speech_transcibe_params.SpeechTranscibeParams),
146
+ files=files,
134
147
  options=make_request_options(
135
148
  extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
136
149
  ),
@@ -171,7 +184,7 @@ class AsyncSpeechResource(AsyncAPIResource):
171
184
  extra_query: Query | None = None,
172
185
  extra_body: Body | None = None,
173
186
  timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
174
- ) -> object:
187
+ ) -> AsyncBinaryAPIResponse:
175
188
  """
176
189
  Synthesize
177
190
 
@@ -184,6 +197,7 @@ class AsyncSpeechResource(AsyncAPIResource):
184
197
 
185
198
  timeout: Override the client-level default timeout for this request, in seconds
186
199
  """
200
+ extra_headers = {"Accept": "audio/wav", **(extra_headers or {})}
187
201
  return await self._post(
188
202
  "/v1/speech",
189
203
  body=await async_maybe_transform(
@@ -201,7 +215,7 @@ class AsyncSpeechResource(AsyncAPIResource):
201
215
  timeout=timeout,
202
216
  query=await async_maybe_transform({"stream": stream}, speech_generate_params.SpeechGenerateParams),
203
217
  ),
204
- cast_to=object,
218
+ cast_to=AsyncBinaryAPIResponse,
205
219
  )
206
220
 
207
221
  async def transcibe(
@@ -229,16 +243,22 @@ class AsyncSpeechResource(AsyncAPIResource):
229
243
 
230
244
  timeout: Override the client-level default timeout for this request, in seconds
231
245
  """
246
+ body = deepcopy_minimal(
247
+ {
248
+ "language": language,
249
+ "content": content,
250
+ "url": url,
251
+ }
252
+ )
253
+ files = extract_files(cast(Mapping[str, object], body), paths=[["content"]])
254
+ # It should be noted that the actual Content-Type header that will be
255
+ # sent to the server will contain a `boundary` parameter, e.g.
256
+ # multipart/form-data; boundary=---abc--
257
+ extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
232
258
  return await self._post(
233
259
  "/v1/transcriptions",
234
- body=await async_maybe_transform(
235
- {
236
- "language": language,
237
- "content": content,
238
- "url": url,
239
- },
240
- speech_transcibe_params.SpeechTranscibeParams,
241
- ),
260
+ body=await async_maybe_transform(body, speech_transcibe_params.SpeechTranscibeParams),
261
+ files=files,
242
262
  options=make_request_options(
243
263
  extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
244
264
  ),
@@ -250,8 +270,9 @@ class SpeechResourceWithRawResponse:
250
270
  def __init__(self, speech: SpeechResource) -> None:
251
271
  self._speech = speech
252
272
 
253
- self.generate = to_raw_response_wrapper(
273
+ self.generate = to_custom_raw_response_wrapper(
254
274
  speech.generate,
275
+ BinaryAPIResponse,
255
276
  )
256
277
  self.transcibe = to_raw_response_wrapper(
257
278
  speech.transcibe,
@@ -262,8 +283,9 @@ class AsyncSpeechResourceWithRawResponse:
262
283
  def __init__(self, speech: AsyncSpeechResource) -> None:
263
284
  self._speech = speech
264
285
 
265
- self.generate = async_to_raw_response_wrapper(
286
+ self.generate = async_to_custom_raw_response_wrapper(
266
287
  speech.generate,
288
+ AsyncBinaryAPIResponse,
267
289
  )
268
290
  self.transcibe = async_to_raw_response_wrapper(
269
291
  speech.transcibe,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: spitch
3
- Version: 1.1.0
3
+ Version: 1.3.0
4
4
  Summary: The official Python library for the spitch API
5
5
  Project-URL: Homepage, https://github.com/spi-tch/spitch-python
6
6
  Project-URL: Repository, https://github.com/spi-tch/spitch-python
@@ -11,7 +11,7 @@ spitch/_resource.py,sha256=TLFPcOOmtxZOQLh3XCNPB_BdrQpp0MIYoKoH52aRAu8,1100
11
11
  spitch/_response.py,sha256=aN6swtguiZ7CC_hWFrwoUa53FgSbjRfZXxYHvfDNGeo,28609
12
12
  spitch/_streaming.py,sha256=5SpId2EIfF8Ee8UUYmJxqgHUGP1ZdHCUHhHCdNJREFA,10100
13
13
  spitch/_types.py,sha256=dsJyGWdBXaYJaRBqn2V3iRsfpWw71rFaSxdSM8sPQYY,6103
14
- spitch/_version.py,sha256=NU_CcMu0lRQBxUT9ZLioDy65oQTpve4TV169gdqzO3I,158
14
+ spitch/_version.py,sha256=c0W0bfKHpBgInBQqGRHV7Ym_2RrKIQWtr3c-ugNMSag,158
15
15
  spitch/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  spitch/_utils/__init__.py,sha256=Uzq1-FIih_VUjzdNVWXks0sdC39KBKLMrZoz-_JOjJ4,1988
17
17
  spitch/_utils/_logs.py,sha256=ApRyYK_WgZfEr_ygBUBXWMlTgeMr2tdNOGlH8jE4oJc,774
@@ -24,13 +24,13 @@ spitch/_utils/_typing.py,sha256=tFbktdpdHCQliwzGsWysgn0P5H0JRdagkZdb_LegGkY,3838
24
24
  spitch/_utils/_utils.py,sha256=tYrr7IX-5NMwsVKbNggbzOM84uNw7XnAe06e2Ln8Or0,11472
25
25
  spitch/lib/.keep,sha256=wuNrz-5SXo3jJaJOJgz4vFHM41YH_g20F5cRQo0vLes,224
26
26
  spitch/resources/__init__.py,sha256=KT6rAvIlWHQk9QdM4Jp8ABziKILaBrrtiO7LCB5Wa5E,976
27
- spitch/resources/speech.py,sha256=nKHWl6_6QDZlQ43VB6ayey6W5Pwp4tHCi48xlg1dOqE,10542
27
+ spitch/resources/speech.py,sha256=lqwdVc-ZBbARtfgwUamr-FKNrBz9lU45wYPvlygdhPs,11796
28
28
  spitch/resources/text.py,sha256=xy7N1q5ioXVMtmcW6iOE8j8n9j4lvnpvO4jJ9FMZmsU,6071
29
29
  spitch/types/__init__.py,sha256=4aa9CgcCmGRqZb4k9F3005Q4Ok-zjiiqw5k3BXIQ3MY,364
30
30
  spitch/types/speech_generate_params.py,sha256=kNVcFxcIcImiLa8r4OEbzeIOqZNtkbSUek99t2ljhaI,425
31
31
  spitch/types/speech_transcibe_params.py,sha256=WvwBsSctqJDXOFJNYyjfijwCnAdJCPkJobESfmLy3aI,448
32
32
  spitch/types/text_tone_mark_params.py,sha256=63P5VElxanYkDP1ZLEuQt97JSgVpMCaAo4WRWLDvhlY,349
33
- spitch-1.1.0.dist-info/METADATA,sha256=LEHPZto27aXNoeQz_hFjDwkKgoV9DwIFxPw-B1ud-nM,12392
34
- spitch-1.1.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
35
- spitch-1.1.0.dist-info/licenses/LICENSE,sha256=529F8Amq5MfoIm33JY544oweKES9vw9_xS1CNx-ztPI,11336
36
- spitch-1.1.0.dist-info/RECORD,,
33
+ spitch-1.3.0.dist-info/METADATA,sha256=AznC_yeZzXHQ0CIbPoMRfgxquNdP3DUeDL8iI3IQUFY,12392
34
+ spitch-1.3.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
35
+ spitch-1.3.0.dist-info/licenses/LICENSE,sha256=529F8Amq5MfoIm33JY544oweKES9vw9_xS1CNx-ztPI,11336
36
+ spitch-1.3.0.dist-info/RECORD,,
File without changes