spitch 1.2.0__tar.gz → 1.3.0__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.

Potentially problematic release.


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

Files changed (71) hide show
  1. spitch-1.3.0/.release-please-manifest.json +3 -0
  2. {spitch-1.2.0 → spitch-1.3.0}/CHANGELOG.md +8 -0
  3. {spitch-1.2.0 → spitch-1.3.0}/PKG-INFO +1 -1
  4. {spitch-1.2.0 → spitch-1.3.0}/api.md +2 -2
  5. {spitch-1.2.0 → spitch-1.3.0}/pyproject.toml +1 -1
  6. {spitch-1.2.0 → spitch-1.3.0}/src/spitch/_version.py +1 -1
  7. {spitch-1.2.0 → spitch-1.3.0}/src/spitch/resources/speech.py +14 -6
  8. {spitch-1.2.0 → spitch-1.3.0}/tests/api_resources/test_speech.py +74 -34
  9. spitch-1.2.0/.release-please-manifest.json +0 -3
  10. {spitch-1.2.0 → spitch-1.3.0}/.gitignore +0 -0
  11. {spitch-1.2.0 → spitch-1.3.0}/CONTRIBUTING.md +0 -0
  12. {spitch-1.2.0 → spitch-1.3.0}/LICENSE +0 -0
  13. {spitch-1.2.0 → spitch-1.3.0}/README.md +0 -0
  14. {spitch-1.2.0 → spitch-1.3.0}/SECURITY.md +0 -0
  15. {spitch-1.2.0 → spitch-1.3.0}/bin/check-release-environment +0 -0
  16. {spitch-1.2.0 → spitch-1.3.0}/bin/publish-pypi +0 -0
  17. {spitch-1.2.0 → spitch-1.3.0}/examples/.keep +0 -0
  18. {spitch-1.2.0 → spitch-1.3.0}/examples/example.py +0 -0
  19. {spitch-1.2.0 → spitch-1.3.0}/mypy.ini +0 -0
  20. {spitch-1.2.0 → spitch-1.3.0}/noxfile.py +0 -0
  21. {spitch-1.2.0 → spitch-1.3.0}/release-please-config.json +0 -0
  22. {spitch-1.2.0 → spitch-1.3.0}/requirements-dev.lock +0 -0
  23. {spitch-1.2.0 → spitch-1.3.0}/requirements.lock +0 -0
  24. {spitch-1.2.0 → spitch-1.3.0}/src/spitch/__init__.py +0 -0
  25. {spitch-1.2.0 → spitch-1.3.0}/src/spitch/_base_client.py +0 -0
  26. {spitch-1.2.0 → spitch-1.3.0}/src/spitch/_client.py +0 -0
  27. {spitch-1.2.0 → spitch-1.3.0}/src/spitch/_compat.py +0 -0
  28. {spitch-1.2.0 → spitch-1.3.0}/src/spitch/_constants.py +0 -0
  29. {spitch-1.2.0 → spitch-1.3.0}/src/spitch/_exceptions.py +0 -0
  30. {spitch-1.2.0 → spitch-1.3.0}/src/spitch/_files.py +0 -0
  31. {spitch-1.2.0 → spitch-1.3.0}/src/spitch/_models.py +0 -0
  32. {spitch-1.2.0 → spitch-1.3.0}/src/spitch/_qs.py +0 -0
  33. {spitch-1.2.0 → spitch-1.3.0}/src/spitch/_resource.py +0 -0
  34. {spitch-1.2.0 → spitch-1.3.0}/src/spitch/_response.py +0 -0
  35. {spitch-1.2.0 → spitch-1.3.0}/src/spitch/_streaming.py +0 -0
  36. {spitch-1.2.0 → spitch-1.3.0}/src/spitch/_types.py +0 -0
  37. {spitch-1.2.0 → spitch-1.3.0}/src/spitch/_utils/__init__.py +0 -0
  38. {spitch-1.2.0 → spitch-1.3.0}/src/spitch/_utils/_logs.py +0 -0
  39. {spitch-1.2.0 → spitch-1.3.0}/src/spitch/_utils/_proxy.py +0 -0
  40. {spitch-1.2.0 → spitch-1.3.0}/src/spitch/_utils/_reflection.py +0 -0
  41. {spitch-1.2.0 → spitch-1.3.0}/src/spitch/_utils/_streams.py +0 -0
  42. {spitch-1.2.0 → spitch-1.3.0}/src/spitch/_utils/_sync.py +0 -0
  43. {spitch-1.2.0 → spitch-1.3.0}/src/spitch/_utils/_transform.py +0 -0
  44. {spitch-1.2.0 → spitch-1.3.0}/src/spitch/_utils/_typing.py +0 -0
  45. {spitch-1.2.0 → spitch-1.3.0}/src/spitch/_utils/_utils.py +0 -0
  46. {spitch-1.2.0 → spitch-1.3.0}/src/spitch/lib/.keep +0 -0
  47. {spitch-1.2.0 → spitch-1.3.0}/src/spitch/py.typed +0 -0
  48. {spitch-1.2.0 → spitch-1.3.0}/src/spitch/resources/__init__.py +0 -0
  49. {spitch-1.2.0 → spitch-1.3.0}/src/spitch/resources/text.py +0 -0
  50. {spitch-1.2.0 → spitch-1.3.0}/src/spitch/types/__init__.py +0 -0
  51. {spitch-1.2.0 → spitch-1.3.0}/src/spitch/types/speech_generate_params.py +0 -0
  52. {spitch-1.2.0 → spitch-1.3.0}/src/spitch/types/speech_transcibe_params.py +0 -0
  53. {spitch-1.2.0 → spitch-1.3.0}/src/spitch/types/text_tone_mark_params.py +0 -0
  54. {spitch-1.2.0 → spitch-1.3.0}/tests/__init__.py +0 -0
  55. {spitch-1.2.0 → spitch-1.3.0}/tests/api_resources/__init__.py +0 -0
  56. {spitch-1.2.0 → spitch-1.3.0}/tests/api_resources/test_text.py +0 -0
  57. {spitch-1.2.0 → spitch-1.3.0}/tests/conftest.py +0 -0
  58. {spitch-1.2.0 → spitch-1.3.0}/tests/sample_file.txt +0 -0
  59. {spitch-1.2.0 → spitch-1.3.0}/tests/test_client.py +0 -0
  60. {spitch-1.2.0 → spitch-1.3.0}/tests/test_deepcopy.py +0 -0
  61. {spitch-1.2.0 → spitch-1.3.0}/tests/test_extract_files.py +0 -0
  62. {spitch-1.2.0 → spitch-1.3.0}/tests/test_files.py +0 -0
  63. {spitch-1.2.0 → spitch-1.3.0}/tests/test_models.py +0 -0
  64. {spitch-1.2.0 → spitch-1.3.0}/tests/test_qs.py +0 -0
  65. {spitch-1.2.0 → spitch-1.3.0}/tests/test_required_args.py +0 -0
  66. {spitch-1.2.0 → spitch-1.3.0}/tests/test_response.py +0 -0
  67. {spitch-1.2.0 → spitch-1.3.0}/tests/test_streaming.py +0 -0
  68. {spitch-1.2.0 → spitch-1.3.0}/tests/test_transform.py +0 -0
  69. {spitch-1.2.0 → spitch-1.3.0}/tests/test_utils/test_proxy.py +0 -0
  70. {spitch-1.2.0 → spitch-1.3.0}/tests/test_utils/test_typing.py +0 -0
  71. {spitch-1.2.0 → spitch-1.3.0}/tests/utils.py +0 -0
@@ -0,0 +1,3 @@
1
+ {
2
+ ".": "1.3.0"
3
+ }
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.3.0 (2024-10-07)
4
+
5
+ Full Changelog: [v1.2.0...v1.3.0](https://github.com/spi-tch/spitch-python/compare/v1.2.0...v1.3.0)
6
+
7
+ ### Features
8
+
9
+ * **api:** update via SDK Studio ([#16](https://github.com/spi-tch/spitch-python/issues/16)) ([77235df](https://github.com/spi-tch/spitch-python/commit/77235df6b0d1f15d064da89bab6f836e78c1db61))
10
+
3
11
  ## 1.2.0 (2024-10-07)
4
12
 
5
13
  Full Changelog: [v1.1.0...v1.2.0](https://github.com/spi-tch/spitch-python/compare/v1.1.0...v1.2.0)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: spitch
3
- Version: 1.2.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
@@ -3,12 +3,12 @@
3
3
  Types:
4
4
 
5
5
  ```python
6
- from spitch.types import SpeechGenerateResponse, SpeechTranscibeResponse
6
+ from spitch.types import SpeechTranscibeResponse
7
7
  ```
8
8
 
9
9
  Methods:
10
10
 
11
- - <code title="post /v1/speech">client.speech.<a href="./src/spitch/resources/speech.py">generate</a>(\*\*<a href="src/spitch/types/speech_generate_params.py">params</a>) -> <a href="./src/spitch/types/speech_generate_response.py">object</a></code>
11
+ - <code title="post /v1/speech">client.speech.<a href="./src/spitch/resources/speech.py">generate</a>(\*\*<a href="src/spitch/types/speech_generate_params.py">params</a>) -> BinaryAPIResponse</code>
12
12
  - <code title="post /v1/transcriptions">client.speech.<a href="./src/spitch/resources/speech.py">transcibe</a>(\*\*<a href="src/spitch/types/speech_transcibe_params.py">params</a>) -> <a href="./src/spitch/types/speech_transcibe_response.py">object</a></code>
13
13
 
14
14
  # Text
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "spitch"
3
- version = "1.2.0"
3
+ version = "1.3.0"
4
4
  description = "The official Python library for the spitch API"
5
5
  dynamic = ["readme"]
6
6
  license = "Apache-2.0"
@@ -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.2.0" # x-release-please-version
4
+ __version__ = "1.3.0" # x-release-please-version
@@ -18,13 +18,17 @@ from .._utils import (
18
18
  from .._compat import cached_property
19
19
  from .._resource import SyncAPIResource, AsyncAPIResource
20
20
  from .._response import (
21
+ BinaryAPIResponse,
22
+ AsyncBinaryAPIResponse,
21
23
  StreamedBinaryAPIResponse,
22
24
  AsyncStreamedBinaryAPIResponse,
23
25
  to_raw_response_wrapper,
24
26
  to_streamed_response_wrapper,
25
27
  async_to_raw_response_wrapper,
28
+ to_custom_raw_response_wrapper,
26
29
  async_to_streamed_response_wrapper,
27
30
  to_custom_streamed_response_wrapper,
31
+ async_to_custom_raw_response_wrapper,
28
32
  async_to_custom_streamed_response_wrapper,
29
33
  )
30
34
  from .._base_client import make_request_options
@@ -65,7 +69,7 @@ class SpeechResource(SyncAPIResource):
65
69
  extra_query: Query | None = None,
66
70
  extra_body: Body | None = None,
67
71
  timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
68
- ) -> object:
72
+ ) -> BinaryAPIResponse:
69
73
  """
70
74
  Synthesize
71
75
 
@@ -78,6 +82,7 @@ class SpeechResource(SyncAPIResource):
78
82
 
79
83
  timeout: Override the client-level default timeout for this request, in seconds
80
84
  """
85
+ extra_headers = {"Accept": "audio/wav", **(extra_headers or {})}
81
86
  return self._post(
82
87
  "/v1/speech",
83
88
  body=maybe_transform(
@@ -95,7 +100,7 @@ class SpeechResource(SyncAPIResource):
95
100
  timeout=timeout,
96
101
  query=maybe_transform({"stream": stream}, speech_generate_params.SpeechGenerateParams),
97
102
  ),
98
- cast_to=object,
103
+ cast_to=BinaryAPIResponse,
99
104
  )
100
105
 
101
106
  def transcibe(
@@ -179,7 +184,7 @@ class AsyncSpeechResource(AsyncAPIResource):
179
184
  extra_query: Query | None = None,
180
185
  extra_body: Body | None = None,
181
186
  timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
182
- ) -> object:
187
+ ) -> AsyncBinaryAPIResponse:
183
188
  """
184
189
  Synthesize
185
190
 
@@ -192,6 +197,7 @@ class AsyncSpeechResource(AsyncAPIResource):
192
197
 
193
198
  timeout: Override the client-level default timeout for this request, in seconds
194
199
  """
200
+ extra_headers = {"Accept": "audio/wav", **(extra_headers or {})}
195
201
  return await self._post(
196
202
  "/v1/speech",
197
203
  body=await async_maybe_transform(
@@ -209,7 +215,7 @@ class AsyncSpeechResource(AsyncAPIResource):
209
215
  timeout=timeout,
210
216
  query=await async_maybe_transform({"stream": stream}, speech_generate_params.SpeechGenerateParams),
211
217
  ),
212
- cast_to=object,
218
+ cast_to=AsyncBinaryAPIResponse,
213
219
  )
214
220
 
215
221
  async def transcibe(
@@ -264,8 +270,9 @@ class SpeechResourceWithRawResponse:
264
270
  def __init__(self, speech: SpeechResource) -> None:
265
271
  self._speech = speech
266
272
 
267
- self.generate = to_raw_response_wrapper(
273
+ self.generate = to_custom_raw_response_wrapper(
268
274
  speech.generate,
275
+ BinaryAPIResponse,
269
276
  )
270
277
  self.transcibe = to_raw_response_wrapper(
271
278
  speech.transcibe,
@@ -276,8 +283,9 @@ class AsyncSpeechResourceWithRawResponse:
276
283
  def __init__(self, speech: AsyncSpeechResource) -> None:
277
284
  self._speech = speech
278
285
 
279
- self.generate = async_to_raw_response_wrapper(
286
+ self.generate = async_to_custom_raw_response_wrapper(
280
287
  speech.generate,
288
+ AsyncBinaryAPIResponse,
281
289
  )
282
290
  self.transcibe = async_to_raw_response_wrapper(
283
291
  speech.transcibe,
@@ -5,10 +5,18 @@ from __future__ import annotations
5
5
  import os
6
6
  from typing import Any, cast
7
7
 
8
+ import httpx
8
9
  import pytest
10
+ from respx import MockRouter
9
11
 
10
12
  from spitch import Spitch, AsyncSpitch
11
13
  from tests.utils import assert_matches_type
14
+ from spitch._response import (
15
+ BinaryAPIResponse,
16
+ AsyncBinaryAPIResponse,
17
+ StreamedBinaryAPIResponse,
18
+ AsyncStreamedBinaryAPIResponse,
19
+ )
12
20
 
13
21
  base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
14
22
 
@@ -17,48 +25,64 @@ class TestSpeech:
17
25
  parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
18
26
 
19
27
  @parametrize
20
- def test_method_generate(self, client: Spitch) -> None:
28
+ @pytest.mark.respx(base_url=base_url)
29
+ def test_method_generate(self, client: Spitch, respx_mock: MockRouter) -> None:
30
+ respx_mock.post("/v1/speech").mock(return_value=httpx.Response(200, json={"foo": "bar"}))
21
31
  speech = client.speech.generate(
22
32
  language="yo",
23
33
  text="text",
24
34
  )
25
- assert_matches_type(object, speech, path=["response"])
35
+ assert speech.is_closed
36
+ assert speech.json() == {"foo": "bar"}
37
+ assert cast(Any, speech.is_closed) is True
38
+ assert isinstance(speech, BinaryAPIResponse)
26
39
 
27
40
  @parametrize
28
- def test_method_generate_with_all_params(self, client: Spitch) -> None:
41
+ @pytest.mark.respx(base_url=base_url)
42
+ def test_method_generate_with_all_params(self, client: Spitch, respx_mock: MockRouter) -> None:
43
+ respx_mock.post("/v1/speech").mock(return_value=httpx.Response(200, json={"foo": "bar"}))
29
44
  speech = client.speech.generate(
30
45
  language="yo",
31
46
  text="text",
32
47
  stream=True,
33
48
  voice="sade",
34
49
  )
35
- assert_matches_type(object, speech, path=["response"])
50
+ assert speech.is_closed
51
+ assert speech.json() == {"foo": "bar"}
52
+ assert cast(Any, speech.is_closed) is True
53
+ assert isinstance(speech, BinaryAPIResponse)
36
54
 
37
55
  @parametrize
38
- def test_raw_response_generate(self, client: Spitch) -> None:
39
- response = client.speech.with_raw_response.generate(
56
+ @pytest.mark.respx(base_url=base_url)
57
+ def test_raw_response_generate(self, client: Spitch, respx_mock: MockRouter) -> None:
58
+ respx_mock.post("/v1/speech").mock(return_value=httpx.Response(200, json={"foo": "bar"}))
59
+
60
+ speech = client.speech.with_raw_response.generate(
40
61
  language="yo",
41
62
  text="text",
42
63
  )
43
64
 
44
- assert response.is_closed is True
45
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
46
- speech = response.parse()
47
- assert_matches_type(object, speech, path=["response"])
65
+ assert speech.is_closed is True
66
+ assert speech.http_request.headers.get("X-Stainless-Lang") == "python"
67
+ assert speech.json() == {"foo": "bar"}
68
+ assert isinstance(speech, BinaryAPIResponse)
48
69
 
49
70
  @parametrize
50
- def test_streaming_response_generate(self, client: Spitch) -> None:
71
+ @pytest.mark.respx(base_url=base_url)
72
+ def test_streaming_response_generate(self, client: Spitch, respx_mock: MockRouter) -> None:
73
+ respx_mock.post("/v1/speech").mock(return_value=httpx.Response(200, json={"foo": "bar"}))
51
74
  with client.speech.with_streaming_response.generate(
52
75
  language="yo",
53
76
  text="text",
54
- ) as response:
55
- assert not response.is_closed
56
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
77
+ ) as speech:
78
+ assert not speech.is_closed
79
+ assert speech.http_request.headers.get("X-Stainless-Lang") == "python"
57
80
 
58
- speech = response.parse()
59
- assert_matches_type(object, speech, path=["response"])
81
+ assert speech.json() == {"foo": "bar"}
82
+ assert cast(Any, speech.is_closed) is True
83
+ assert isinstance(speech, StreamedBinaryAPIResponse)
60
84
 
61
- assert cast(Any, response.is_closed) is True
85
+ assert cast(Any, speech.is_closed) is True
62
86
 
63
87
  @parametrize
64
88
  def test_method_transcibe(self, client: Spitch) -> None:
@@ -105,48 +129,64 @@ class TestAsyncSpeech:
105
129
  parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
106
130
 
107
131
  @parametrize
108
- async def test_method_generate(self, async_client: AsyncSpitch) -> None:
132
+ @pytest.mark.respx(base_url=base_url)
133
+ async def test_method_generate(self, async_client: AsyncSpitch, respx_mock: MockRouter) -> None:
134
+ respx_mock.post("/v1/speech").mock(return_value=httpx.Response(200, json={"foo": "bar"}))
109
135
  speech = await async_client.speech.generate(
110
136
  language="yo",
111
137
  text="text",
112
138
  )
113
- assert_matches_type(object, speech, path=["response"])
139
+ assert speech.is_closed
140
+ assert await speech.json() == {"foo": "bar"}
141
+ assert cast(Any, speech.is_closed) is True
142
+ assert isinstance(speech, AsyncBinaryAPIResponse)
114
143
 
115
144
  @parametrize
116
- async def test_method_generate_with_all_params(self, async_client: AsyncSpitch) -> None:
145
+ @pytest.mark.respx(base_url=base_url)
146
+ async def test_method_generate_with_all_params(self, async_client: AsyncSpitch, respx_mock: MockRouter) -> None:
147
+ respx_mock.post("/v1/speech").mock(return_value=httpx.Response(200, json={"foo": "bar"}))
117
148
  speech = await async_client.speech.generate(
118
149
  language="yo",
119
150
  text="text",
120
151
  stream=True,
121
152
  voice="sade",
122
153
  )
123
- assert_matches_type(object, speech, path=["response"])
154
+ assert speech.is_closed
155
+ assert await speech.json() == {"foo": "bar"}
156
+ assert cast(Any, speech.is_closed) is True
157
+ assert isinstance(speech, AsyncBinaryAPIResponse)
124
158
 
125
159
  @parametrize
126
- async def test_raw_response_generate(self, async_client: AsyncSpitch) -> None:
127
- response = await async_client.speech.with_raw_response.generate(
160
+ @pytest.mark.respx(base_url=base_url)
161
+ async def test_raw_response_generate(self, async_client: AsyncSpitch, respx_mock: MockRouter) -> None:
162
+ respx_mock.post("/v1/speech").mock(return_value=httpx.Response(200, json={"foo": "bar"}))
163
+
164
+ speech = await async_client.speech.with_raw_response.generate(
128
165
  language="yo",
129
166
  text="text",
130
167
  )
131
168
 
132
- assert response.is_closed is True
133
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
134
- speech = await response.parse()
135
- assert_matches_type(object, speech, path=["response"])
169
+ assert speech.is_closed is True
170
+ assert speech.http_request.headers.get("X-Stainless-Lang") == "python"
171
+ assert await speech.json() == {"foo": "bar"}
172
+ assert isinstance(speech, AsyncBinaryAPIResponse)
136
173
 
137
174
  @parametrize
138
- async def test_streaming_response_generate(self, async_client: AsyncSpitch) -> None:
175
+ @pytest.mark.respx(base_url=base_url)
176
+ async def test_streaming_response_generate(self, async_client: AsyncSpitch, respx_mock: MockRouter) -> None:
177
+ respx_mock.post("/v1/speech").mock(return_value=httpx.Response(200, json={"foo": "bar"}))
139
178
  async with async_client.speech.with_streaming_response.generate(
140
179
  language="yo",
141
180
  text="text",
142
- ) as response:
143
- assert not response.is_closed
144
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
181
+ ) as speech:
182
+ assert not speech.is_closed
183
+ assert speech.http_request.headers.get("X-Stainless-Lang") == "python"
145
184
 
146
- speech = await response.parse()
147
- assert_matches_type(object, speech, path=["response"])
185
+ assert await speech.json() == {"foo": "bar"}
186
+ assert cast(Any, speech.is_closed) is True
187
+ assert isinstance(speech, AsyncStreamedBinaryAPIResponse)
148
188
 
149
- assert cast(Any, response.is_closed) is True
189
+ assert cast(Any, speech.is_closed) is True
150
190
 
151
191
  @parametrize
152
192
  async def test_method_transcibe(self, async_client: AsyncSpitch) -> None:
@@ -1,3 +0,0 @@
1
- {
2
- ".": "1.2.0"
3
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes