spitch 1.7.0__tar.gz → 1.9.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.
- spitch-1.9.0/.release-please-manifest.json +3 -0
- {spitch-1.7.0 → spitch-1.9.0}/CHANGELOG.md +17 -0
- {spitch-1.7.0 → spitch-1.9.0}/PKG-INFO +1 -8
- {spitch-1.7.0 → spitch-1.9.0}/README.md +0 -7
- {spitch-1.7.0 → spitch-1.9.0}/api.md +4 -3
- {spitch-1.7.0 → spitch-1.9.0}/pyproject.toml +3 -2
- {spitch-1.7.0 → spitch-1.9.0}/requirements-dev.lock +1 -1
- {spitch-1.7.0 → spitch-1.9.0}/src/spitch/_version.py +1 -1
- {spitch-1.7.0 → spitch-1.9.0}/src/spitch/resources/speech.py +22 -24
- {spitch-1.7.0 → spitch-1.9.0}/src/spitch/resources/text.py +95 -1
- {spitch-1.7.0 → spitch-1.9.0}/src/spitch/types/__init__.py +1 -0
- {spitch-1.7.0 → spitch-1.9.0}/src/spitch/types/speech_generate_params.py +3 -1
- spitch-1.9.0/src/spitch/types/text_translate_params.py +15 -0
- {spitch-1.7.0 → spitch-1.9.0}/tests/api_resources/test_speech.py +48 -64
- {spitch-1.7.0 → spitch-1.9.0}/tests/api_resources/test_text.py +74 -0
- {spitch-1.7.0 → spitch-1.9.0}/tests/test_client.py +10 -10
- {spitch-1.7.0 → spitch-1.9.0}/tests/test_models.py +1 -1
- spitch-1.7.0/.release-please-manifest.json +0 -3
- {spitch-1.7.0 → spitch-1.9.0}/.gitignore +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/CONTRIBUTING.md +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/LICENSE +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/SECURITY.md +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/bin/check-release-environment +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/bin/publish-pypi +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/examples/.keep +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/examples/example.py +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/mypy.ini +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/noxfile.py +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/release-please-config.json +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/requirements.lock +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/src/spitch/__init__.py +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/src/spitch/_base_client.py +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/src/spitch/_client.py +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/src/spitch/_compat.py +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/src/spitch/_constants.py +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/src/spitch/_exceptions.py +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/src/spitch/_files.py +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/src/spitch/_models.py +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/src/spitch/_qs.py +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/src/spitch/_resource.py +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/src/spitch/_response.py +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/src/spitch/_streaming.py +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/src/spitch/_types.py +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/src/spitch/_utils/__init__.py +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/src/spitch/_utils/_logs.py +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/src/spitch/_utils/_proxy.py +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/src/spitch/_utils/_reflection.py +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/src/spitch/_utils/_streams.py +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/src/spitch/_utils/_sync.py +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/src/spitch/_utils/_transform.py +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/src/spitch/_utils/_typing.py +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/src/spitch/_utils/_utils.py +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/src/spitch/lib/.keep +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/src/spitch/py.typed +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/src/spitch/resources/__init__.py +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/src/spitch/types/speech_transcibe_params.py +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/src/spitch/types/speech_transcribe_params.py +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/src/spitch/types/text_tone_mark_params.py +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/tests/__init__.py +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/tests/api_resources/__init__.py +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/tests/conftest.py +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/tests/sample_file.txt +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/tests/test_deepcopy.py +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/tests/test_extract_files.py +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/tests/test_files.py +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/tests/test_qs.py +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/tests/test_required_args.py +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/tests/test_response.py +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/tests/test_streaming.py +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/tests/test_transform.py +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/tests/test_utils/test_proxy.py +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/tests/test_utils/test_typing.py +0 -0
- {spitch-1.7.0 → spitch-1.9.0}/tests/utils.py +0 -0
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.9.0 (2024-10-17)
|
|
4
|
+
|
|
5
|
+
Full Changelog: [v1.8.0...v1.9.0](https://github.com/spi-tch/spitch-python/compare/v1.8.0...v1.9.0)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* **api:** api update ([#42](https://github.com/spi-tch/spitch-python/issues/42)) ([1575f47](https://github.com/spi-tch/spitch-python/commit/1575f47becd40467509030e2f56e2c73ac771958))
|
|
10
|
+
|
|
11
|
+
## 1.8.0 (2024-10-17)
|
|
12
|
+
|
|
13
|
+
Full Changelog: [v1.7.0...v1.8.0](https://github.com/spi-tch/spitch-python/compare/v1.7.0...v1.8.0)
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* **api:** api update ([#37](https://github.com/spi-tch/spitch-python/issues/37)) ([34e4fba](https://github.com/spi-tch/spitch-python/commit/34e4fba09e3744cfb443a3a0de5bf6a59bac50bc))
|
|
18
|
+
* **api:** api update ([#39](https://github.com/spi-tch/spitch-python/issues/39)) ([4cc3eb2](https://github.com/spi-tch/spitch-python/commit/4cc3eb24be8de66ae662de62c45818c0100bf894))
|
|
19
|
+
|
|
3
20
|
## 1.7.0 (2024-10-14)
|
|
4
21
|
|
|
5
22
|
Full Changelog: [v1.6.0...v1.7.0](https://github.com/spi-tch/spitch-python/compare/v1.6.0...v1.7.0)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: spitch
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.9.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
|
|
@@ -69,7 +69,6 @@ client = Spitch(
|
|
|
69
69
|
response = client.speech.generate(
|
|
70
70
|
language="yo",
|
|
71
71
|
text="text",
|
|
72
|
-
voice="sade",
|
|
73
72
|
)
|
|
74
73
|
```
|
|
75
74
|
|
|
@@ -97,7 +96,6 @@ async def main() -> None:
|
|
|
97
96
|
response = await client.speech.generate(
|
|
98
97
|
language="yo",
|
|
99
98
|
text="text",
|
|
100
|
-
voice="sade",
|
|
101
99
|
)
|
|
102
100
|
|
|
103
101
|
|
|
@@ -134,7 +132,6 @@ try:
|
|
|
134
132
|
client.speech.generate(
|
|
135
133
|
language="yo",
|
|
136
134
|
text="text",
|
|
137
|
-
voice="sade",
|
|
138
135
|
)
|
|
139
136
|
except spitch.APIConnectionError as e:
|
|
140
137
|
print("The server could not be reached")
|
|
@@ -181,7 +178,6 @@ client = Spitch(
|
|
|
181
178
|
client.with_options(max_retries=5).speech.generate(
|
|
182
179
|
language="yo",
|
|
183
180
|
text="text",
|
|
184
|
-
voice="sade",
|
|
185
181
|
)
|
|
186
182
|
```
|
|
187
183
|
|
|
@@ -208,7 +204,6 @@ client = Spitch(
|
|
|
208
204
|
client.with_options(timeout=5.0).speech.generate(
|
|
209
205
|
language="yo",
|
|
210
206
|
text="text",
|
|
211
|
-
voice="sade",
|
|
212
207
|
)
|
|
213
208
|
```
|
|
214
209
|
|
|
@@ -251,7 +246,6 @@ client = Spitch()
|
|
|
251
246
|
response = client.speech.with_raw_response.generate(
|
|
252
247
|
language="yo",
|
|
253
248
|
text="text",
|
|
254
|
-
voice="sade",
|
|
255
249
|
)
|
|
256
250
|
print(response.headers.get('X-My-Header'))
|
|
257
251
|
|
|
@@ -273,7 +267,6 @@ To stream the response body, use `.with_streaming_response` instead, which requi
|
|
|
273
267
|
with client.speech.with_streaming_response.generate(
|
|
274
268
|
language="yo",
|
|
275
269
|
text="text",
|
|
276
|
-
voice="sade",
|
|
277
270
|
) as response:
|
|
278
271
|
print(response.headers.get("X-My-Header"))
|
|
279
272
|
|
|
@@ -35,7 +35,6 @@ client = Spitch(
|
|
|
35
35
|
response = client.speech.generate(
|
|
36
36
|
language="yo",
|
|
37
37
|
text="text",
|
|
38
|
-
voice="sade",
|
|
39
38
|
)
|
|
40
39
|
```
|
|
41
40
|
|
|
@@ -63,7 +62,6 @@ async def main() -> None:
|
|
|
63
62
|
response = await client.speech.generate(
|
|
64
63
|
language="yo",
|
|
65
64
|
text="text",
|
|
66
|
-
voice="sade",
|
|
67
65
|
)
|
|
68
66
|
|
|
69
67
|
|
|
@@ -100,7 +98,6 @@ try:
|
|
|
100
98
|
client.speech.generate(
|
|
101
99
|
language="yo",
|
|
102
100
|
text="text",
|
|
103
|
-
voice="sade",
|
|
104
101
|
)
|
|
105
102
|
except spitch.APIConnectionError as e:
|
|
106
103
|
print("The server could not be reached")
|
|
@@ -147,7 +144,6 @@ client = Spitch(
|
|
|
147
144
|
client.with_options(max_retries=5).speech.generate(
|
|
148
145
|
language="yo",
|
|
149
146
|
text="text",
|
|
150
|
-
voice="sade",
|
|
151
147
|
)
|
|
152
148
|
```
|
|
153
149
|
|
|
@@ -174,7 +170,6 @@ client = Spitch(
|
|
|
174
170
|
client.with_options(timeout=5.0).speech.generate(
|
|
175
171
|
language="yo",
|
|
176
172
|
text="text",
|
|
177
|
-
voice="sade",
|
|
178
173
|
)
|
|
179
174
|
```
|
|
180
175
|
|
|
@@ -217,7 +212,6 @@ client = Spitch()
|
|
|
217
212
|
response = client.speech.with_raw_response.generate(
|
|
218
213
|
language="yo",
|
|
219
214
|
text="text",
|
|
220
|
-
voice="sade",
|
|
221
215
|
)
|
|
222
216
|
print(response.headers.get('X-My-Header'))
|
|
223
217
|
|
|
@@ -239,7 +233,6 @@ To stream the response body, use `.with_streaming_response` instead, which requi
|
|
|
239
233
|
with client.speech.with_streaming_response.generate(
|
|
240
234
|
language="yo",
|
|
241
235
|
text="text",
|
|
242
|
-
voice="sade",
|
|
243
236
|
) as response:
|
|
244
237
|
print(response.headers.get("X-My-Header"))
|
|
245
238
|
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
Types:
|
|
4
4
|
|
|
5
5
|
```python
|
|
6
|
-
from spitch.types import SpeechTranscribeResponse
|
|
6
|
+
from spitch.types import SpeechGenerateResponse, SpeechTranscribeResponse
|
|
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>) ->
|
|
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>
|
|
12
12
|
- <code title="post /v1/transcriptions">client.speech.<a href="./src/spitch/resources/speech.py">transcribe</a>(\*\*<a href="src/spitch/types/speech_transcribe_params.py">params</a>) -> <a href="./src/spitch/types/speech_transcribe_response.py">object</a></code>
|
|
13
13
|
|
|
14
14
|
# Text
|
|
@@ -16,9 +16,10 @@ Methods:
|
|
|
16
16
|
Types:
|
|
17
17
|
|
|
18
18
|
```python
|
|
19
|
-
from spitch.types import TextToneMarkResponse
|
|
19
|
+
from spitch.types import TextToneMarkResponse, TextTranslateResponse
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
Methods:
|
|
23
23
|
|
|
24
24
|
- <code title="post /v1/diacritics">client.text.<a href="./src/spitch/resources/text.py">tone_mark</a>(\*\*<a href="src/spitch/types/text_tone_mark_params.py">params</a>) -> <a href="./src/spitch/types/text_tone_mark_response.py">object</a></code>
|
|
25
|
+
- <code title="post /v1/translate">client.text.<a href="./src/spitch/resources/text.py">translate</a>(\*\*<a href="src/spitch/types/text_translate_params.py">params</a>) -> <a href="./src/spitch/types/text_translate_response.py">object</a></code>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "spitch"
|
|
3
|
-
version = "1.
|
|
3
|
+
version = "1.9.0"
|
|
4
4
|
description = "The official Python library for the spitch API"
|
|
5
5
|
dynamic = ["readme"]
|
|
6
6
|
license = "Apache-2.0"
|
|
@@ -63,11 +63,12 @@ format = { chain = [
|
|
|
63
63
|
"format:ruff",
|
|
64
64
|
"format:docs",
|
|
65
65
|
"fix:ruff",
|
|
66
|
+
# run formatting again to fix any inconsistencies when imports are stripped
|
|
67
|
+
"format:ruff",
|
|
66
68
|
]}
|
|
67
69
|
"format:black" = "black ."
|
|
68
70
|
"format:docs" = "python scripts/utils/ruffen-docs.py README.md api.md"
|
|
69
71
|
"format:ruff" = "ruff format"
|
|
70
|
-
"format:isort" = "isort ."
|
|
71
72
|
|
|
72
73
|
"lint" = { chain = [
|
|
73
74
|
"check:ruff",
|
|
@@ -18,18 +18,10 @@ 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,
|
|
23
|
-
StreamedBinaryAPIResponse,
|
|
24
|
-
AsyncStreamedBinaryAPIResponse,
|
|
25
21
|
to_raw_response_wrapper,
|
|
26
22
|
to_streamed_response_wrapper,
|
|
27
23
|
async_to_raw_response_wrapper,
|
|
28
|
-
to_custom_raw_response_wrapper,
|
|
29
24
|
async_to_streamed_response_wrapper,
|
|
30
|
-
to_custom_streamed_response_wrapper,
|
|
31
|
-
async_to_custom_raw_response_wrapper,
|
|
32
|
-
async_to_custom_streamed_response_wrapper,
|
|
33
25
|
)
|
|
34
26
|
from .._base_client import make_request_options
|
|
35
27
|
|
|
@@ -61,14 +53,15 @@ class SpeechResource(SyncAPIResource):
|
|
|
61
53
|
*,
|
|
62
54
|
language: Literal["yo", "en", "ha", "ig"],
|
|
63
55
|
text: str,
|
|
64
|
-
|
|
56
|
+
stream: bool | NotGiven = NOT_GIVEN,
|
|
57
|
+
voice: Literal["sade", "segun", "femi", "funmi"] | NotGiven = NOT_GIVEN,
|
|
65
58
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
66
59
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
67
60
|
extra_headers: Headers | None = None,
|
|
68
61
|
extra_query: Query | None = None,
|
|
69
62
|
extra_body: Body | None = None,
|
|
70
63
|
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
71
|
-
) ->
|
|
64
|
+
) -> object:
|
|
72
65
|
"""
|
|
73
66
|
Synthesize
|
|
74
67
|
|
|
@@ -81,7 +74,6 @@ class SpeechResource(SyncAPIResource):
|
|
|
81
74
|
|
|
82
75
|
timeout: Override the client-level default timeout for this request, in seconds
|
|
83
76
|
"""
|
|
84
|
-
extra_headers = {"Accept": "audio/wav", **(extra_headers or {})}
|
|
85
77
|
return self._post(
|
|
86
78
|
"/v1/speech",
|
|
87
79
|
body=maybe_transform(
|
|
@@ -93,9 +85,13 @@ class SpeechResource(SyncAPIResource):
|
|
|
93
85
|
speech_generate_params.SpeechGenerateParams,
|
|
94
86
|
),
|
|
95
87
|
options=make_request_options(
|
|
96
|
-
extra_headers=extra_headers,
|
|
88
|
+
extra_headers=extra_headers,
|
|
89
|
+
extra_query=extra_query,
|
|
90
|
+
extra_body=extra_body,
|
|
91
|
+
timeout=timeout,
|
|
92
|
+
query=maybe_transform({"stream": stream}, speech_generate_params.SpeechGenerateParams),
|
|
97
93
|
),
|
|
98
|
-
cast_to=
|
|
94
|
+
cast_to=object,
|
|
99
95
|
)
|
|
100
96
|
|
|
101
97
|
def transcribe(
|
|
@@ -171,14 +167,15 @@ class AsyncSpeechResource(AsyncAPIResource):
|
|
|
171
167
|
*,
|
|
172
168
|
language: Literal["yo", "en", "ha", "ig"],
|
|
173
169
|
text: str,
|
|
174
|
-
|
|
170
|
+
stream: bool | NotGiven = NOT_GIVEN,
|
|
171
|
+
voice: Literal["sade", "segun", "femi", "funmi"] | NotGiven = NOT_GIVEN,
|
|
175
172
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
176
173
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
177
174
|
extra_headers: Headers | None = None,
|
|
178
175
|
extra_query: Query | None = None,
|
|
179
176
|
extra_body: Body | None = None,
|
|
180
177
|
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
181
|
-
) ->
|
|
178
|
+
) -> object:
|
|
182
179
|
"""
|
|
183
180
|
Synthesize
|
|
184
181
|
|
|
@@ -191,7 +188,6 @@ class AsyncSpeechResource(AsyncAPIResource):
|
|
|
191
188
|
|
|
192
189
|
timeout: Override the client-level default timeout for this request, in seconds
|
|
193
190
|
"""
|
|
194
|
-
extra_headers = {"Accept": "audio/wav", **(extra_headers or {})}
|
|
195
191
|
return await self._post(
|
|
196
192
|
"/v1/speech",
|
|
197
193
|
body=await async_maybe_transform(
|
|
@@ -203,9 +199,13 @@ class AsyncSpeechResource(AsyncAPIResource):
|
|
|
203
199
|
speech_generate_params.SpeechGenerateParams,
|
|
204
200
|
),
|
|
205
201
|
options=make_request_options(
|
|
206
|
-
extra_headers=extra_headers,
|
|
202
|
+
extra_headers=extra_headers,
|
|
203
|
+
extra_query=extra_query,
|
|
204
|
+
extra_body=extra_body,
|
|
205
|
+
timeout=timeout,
|
|
206
|
+
query=await async_maybe_transform({"stream": stream}, speech_generate_params.SpeechGenerateParams),
|
|
207
207
|
),
|
|
208
|
-
cast_to=
|
|
208
|
+
cast_to=object,
|
|
209
209
|
)
|
|
210
210
|
|
|
211
211
|
async def transcribe(
|
|
@@ -260,9 +260,8 @@ class SpeechResourceWithRawResponse:
|
|
|
260
260
|
def __init__(self, speech: SpeechResource) -> None:
|
|
261
261
|
self._speech = speech
|
|
262
262
|
|
|
263
|
-
self.generate =
|
|
263
|
+
self.generate = to_raw_response_wrapper(
|
|
264
264
|
speech.generate,
|
|
265
|
-
BinaryAPIResponse,
|
|
266
265
|
)
|
|
267
266
|
self.transcribe = to_raw_response_wrapper(
|
|
268
267
|
speech.transcribe,
|
|
@@ -273,9 +272,8 @@ class AsyncSpeechResourceWithRawResponse:
|
|
|
273
272
|
def __init__(self, speech: AsyncSpeechResource) -> None:
|
|
274
273
|
self._speech = speech
|
|
275
274
|
|
|
276
|
-
self.generate =
|
|
275
|
+
self.generate = async_to_raw_response_wrapper(
|
|
277
276
|
speech.generate,
|
|
278
|
-
AsyncBinaryAPIResponse,
|
|
279
277
|
)
|
|
280
278
|
self.transcribe = async_to_raw_response_wrapper(
|
|
281
279
|
speech.transcribe,
|
|
@@ -286,7 +284,7 @@ class SpeechResourceWithStreamingResponse:
|
|
|
286
284
|
def __init__(self, speech: SpeechResource) -> None:
|
|
287
285
|
self._speech = speech
|
|
288
286
|
|
|
289
|
-
self.generate =
|
|
287
|
+
self.generate = to_streamed_response_wrapper(
|
|
290
288
|
speech.generate,
|
|
291
289
|
StreamedBinaryAPIResponse
|
|
292
290
|
)
|
|
@@ -299,7 +297,7 @@ class AsyncSpeechResourceWithStreamingResponse:
|
|
|
299
297
|
def __init__(self, speech: AsyncSpeechResource) -> None:
|
|
300
298
|
self._speech = speech
|
|
301
299
|
|
|
302
|
-
self.generate =
|
|
300
|
+
self.generate = async_to_streamed_response_wrapper(
|
|
303
301
|
speech.generate,
|
|
304
302
|
AsyncStreamedBinaryAPIResponse
|
|
305
303
|
)
|
|
@@ -6,7 +6,7 @@ from typing_extensions import Literal
|
|
|
6
6
|
|
|
7
7
|
import httpx
|
|
8
8
|
|
|
9
|
-
from ..types import text_tone_mark_params
|
|
9
|
+
from ..types import text_tone_mark_params, text_translate_params
|
|
10
10
|
from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
|
|
11
11
|
from .._utils import (
|
|
12
12
|
maybe_transform,
|
|
@@ -84,6 +84,47 @@ class TextResource(SyncAPIResource):
|
|
|
84
84
|
cast_to=object,
|
|
85
85
|
)
|
|
86
86
|
|
|
87
|
+
def translate(
|
|
88
|
+
self,
|
|
89
|
+
*,
|
|
90
|
+
source: Literal["yo", "en", "ha", "ig"],
|
|
91
|
+
target: Literal["yo", "en", "ha", "ig"],
|
|
92
|
+
text: str,
|
|
93
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
94
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
95
|
+
extra_headers: Headers | None = None,
|
|
96
|
+
extra_query: Query | None = None,
|
|
97
|
+
extra_body: Body | None = None,
|
|
98
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
99
|
+
) -> object:
|
|
100
|
+
"""
|
|
101
|
+
Translate
|
|
102
|
+
|
|
103
|
+
Args:
|
|
104
|
+
extra_headers: Send extra headers
|
|
105
|
+
|
|
106
|
+
extra_query: Add additional query parameters to the request
|
|
107
|
+
|
|
108
|
+
extra_body: Add additional JSON properties to the request
|
|
109
|
+
|
|
110
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
111
|
+
"""
|
|
112
|
+
return self._post(
|
|
113
|
+
"/v1/translate",
|
|
114
|
+
body=maybe_transform(
|
|
115
|
+
{
|
|
116
|
+
"source": source,
|
|
117
|
+
"target": target,
|
|
118
|
+
"text": text,
|
|
119
|
+
},
|
|
120
|
+
text_translate_params.TextTranslateParams,
|
|
121
|
+
),
|
|
122
|
+
options=make_request_options(
|
|
123
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
124
|
+
),
|
|
125
|
+
cast_to=object,
|
|
126
|
+
)
|
|
127
|
+
|
|
87
128
|
|
|
88
129
|
class AsyncTextResource(AsyncAPIResource):
|
|
89
130
|
@cached_property
|
|
@@ -144,6 +185,47 @@ class AsyncTextResource(AsyncAPIResource):
|
|
|
144
185
|
cast_to=object,
|
|
145
186
|
)
|
|
146
187
|
|
|
188
|
+
async def translate(
|
|
189
|
+
self,
|
|
190
|
+
*,
|
|
191
|
+
source: Literal["yo", "en", "ha", "ig"],
|
|
192
|
+
target: Literal["yo", "en", "ha", "ig"],
|
|
193
|
+
text: str,
|
|
194
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
195
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
196
|
+
extra_headers: Headers | None = None,
|
|
197
|
+
extra_query: Query | None = None,
|
|
198
|
+
extra_body: Body | None = None,
|
|
199
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
200
|
+
) -> object:
|
|
201
|
+
"""
|
|
202
|
+
Translate
|
|
203
|
+
|
|
204
|
+
Args:
|
|
205
|
+
extra_headers: Send extra headers
|
|
206
|
+
|
|
207
|
+
extra_query: Add additional query parameters to the request
|
|
208
|
+
|
|
209
|
+
extra_body: Add additional JSON properties to the request
|
|
210
|
+
|
|
211
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
212
|
+
"""
|
|
213
|
+
return await self._post(
|
|
214
|
+
"/v1/translate",
|
|
215
|
+
body=await async_maybe_transform(
|
|
216
|
+
{
|
|
217
|
+
"source": source,
|
|
218
|
+
"target": target,
|
|
219
|
+
"text": text,
|
|
220
|
+
},
|
|
221
|
+
text_translate_params.TextTranslateParams,
|
|
222
|
+
),
|
|
223
|
+
options=make_request_options(
|
|
224
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
225
|
+
),
|
|
226
|
+
cast_to=object,
|
|
227
|
+
)
|
|
228
|
+
|
|
147
229
|
|
|
148
230
|
class TextResourceWithRawResponse:
|
|
149
231
|
def __init__(self, text: TextResource) -> None:
|
|
@@ -152,6 +234,9 @@ class TextResourceWithRawResponse:
|
|
|
152
234
|
self.tone_mark = to_raw_response_wrapper(
|
|
153
235
|
text.tone_mark,
|
|
154
236
|
)
|
|
237
|
+
self.translate = to_raw_response_wrapper(
|
|
238
|
+
text.translate,
|
|
239
|
+
)
|
|
155
240
|
|
|
156
241
|
|
|
157
242
|
class AsyncTextResourceWithRawResponse:
|
|
@@ -161,6 +246,9 @@ class AsyncTextResourceWithRawResponse:
|
|
|
161
246
|
self.tone_mark = async_to_raw_response_wrapper(
|
|
162
247
|
text.tone_mark,
|
|
163
248
|
)
|
|
249
|
+
self.translate = async_to_raw_response_wrapper(
|
|
250
|
+
text.translate,
|
|
251
|
+
)
|
|
164
252
|
|
|
165
253
|
|
|
166
254
|
class TextResourceWithStreamingResponse:
|
|
@@ -170,6 +258,9 @@ class TextResourceWithStreamingResponse:
|
|
|
170
258
|
self.tone_mark = to_streamed_response_wrapper(
|
|
171
259
|
text.tone_mark,
|
|
172
260
|
)
|
|
261
|
+
self.translate = to_streamed_response_wrapper(
|
|
262
|
+
text.translate,
|
|
263
|
+
)
|
|
173
264
|
|
|
174
265
|
|
|
175
266
|
class AsyncTextResourceWithStreamingResponse:
|
|
@@ -179,3 +270,6 @@ class AsyncTextResourceWithStreamingResponse:
|
|
|
179
270
|
self.tone_mark = async_to_streamed_response_wrapper(
|
|
180
271
|
text.tone_mark,
|
|
181
272
|
)
|
|
273
|
+
self.translate = async_to_streamed_response_wrapper(
|
|
274
|
+
text.translate,
|
|
275
|
+
)
|
|
@@ -3,5 +3,6 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
from .text_tone_mark_params import TextToneMarkParams as TextToneMarkParams
|
|
6
|
+
from .text_translate_params import TextTranslateParams as TextTranslateParams
|
|
6
7
|
from .speech_generate_params import SpeechGenerateParams as SpeechGenerateParams
|
|
7
8
|
from .speech_transcribe_params import SpeechTranscribeParams as SpeechTranscribeParams
|
|
@@ -0,0 +1,15 @@
|
|
|
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, Required, TypedDict
|
|
6
|
+
|
|
7
|
+
__all__ = ["TextTranslateParams"]
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class TextTranslateParams(TypedDict, total=False):
|
|
11
|
+
source: Required[Literal["yo", "en", "ha", "ig"]]
|
|
12
|
+
|
|
13
|
+
target: Required[Literal["yo", "en", "ha", "ig"]]
|
|
14
|
+
|
|
15
|
+
text: Required[str]
|
|
@@ -5,18 +5,10 @@ from __future__ import annotations
|
|
|
5
5
|
import os
|
|
6
6
|
from typing import Any, cast
|
|
7
7
|
|
|
8
|
-
import httpx
|
|
9
8
|
import pytest
|
|
10
|
-
from respx import MockRouter
|
|
11
9
|
|
|
12
10
|
from spitch import Spitch, AsyncSpitch
|
|
13
11
|
from tests.utils import assert_matches_type
|
|
14
|
-
from spitch._response import (
|
|
15
|
-
BinaryAPIResponse,
|
|
16
|
-
AsyncBinaryAPIResponse,
|
|
17
|
-
StreamedBinaryAPIResponse,
|
|
18
|
-
AsyncStreamedBinaryAPIResponse,
|
|
19
|
-
)
|
|
20
12
|
|
|
21
13
|
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
|
|
22
14
|
|
|
@@ -25,52 +17,48 @@ class TestSpeech:
|
|
|
25
17
|
parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
|
|
26
18
|
|
|
27
19
|
@parametrize
|
|
28
|
-
|
|
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"}))
|
|
20
|
+
def test_method_generate(self, client: Spitch) -> None:
|
|
31
21
|
speech = client.speech.generate(
|
|
32
22
|
language="yo",
|
|
33
23
|
text="text",
|
|
34
|
-
voice="sade",
|
|
35
24
|
)
|
|
36
|
-
|
|
37
|
-
assert speech.json() == {"foo": "bar"}
|
|
38
|
-
assert cast(Any, speech.is_closed) is True
|
|
39
|
-
assert isinstance(speech, BinaryAPIResponse)
|
|
25
|
+
assert_matches_type(object, speech, path=["response"])
|
|
40
26
|
|
|
41
27
|
@parametrize
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
respx_mock.post("/v1/speech").mock(return_value=httpx.Response(200, json={"foo": "bar"}))
|
|
45
|
-
|
|
46
|
-
speech = client.speech.with_raw_response.generate(
|
|
28
|
+
def test_method_generate_with_all_params(self, client: Spitch) -> None:
|
|
29
|
+
speech = client.speech.generate(
|
|
47
30
|
language="yo",
|
|
48
31
|
text="text",
|
|
32
|
+
stream=True,
|
|
49
33
|
voice="sade",
|
|
50
34
|
)
|
|
35
|
+
assert_matches_type(object, speech, path=["response"])
|
|
51
36
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
37
|
+
@parametrize
|
|
38
|
+
def test_raw_response_generate(self, client: Spitch) -> None:
|
|
39
|
+
response = client.speech.with_raw_response.generate(
|
|
40
|
+
language="yo",
|
|
41
|
+
text="text",
|
|
42
|
+
)
|
|
43
|
+
|
|
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"])
|
|
56
48
|
|
|
57
49
|
@parametrize
|
|
58
|
-
|
|
59
|
-
def test_streaming_response_generate(self, client: Spitch, respx_mock: MockRouter) -> None:
|
|
60
|
-
respx_mock.post("/v1/speech").mock(return_value=httpx.Response(200, json={"foo": "bar"}))
|
|
50
|
+
def test_streaming_response_generate(self, client: Spitch) -> None:
|
|
61
51
|
with client.speech.with_streaming_response.generate(
|
|
62
52
|
language="yo",
|
|
63
53
|
text="text",
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
assert
|
|
67
|
-
assert speech.http_request.headers.get("X-Stainless-Lang") == "python"
|
|
54
|
+
) as response:
|
|
55
|
+
assert not response.is_closed
|
|
56
|
+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
|
68
57
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
assert isinstance(speech, StreamedBinaryAPIResponse)
|
|
58
|
+
speech = response.parse()
|
|
59
|
+
assert_matches_type(object, speech, path=["response"])
|
|
72
60
|
|
|
73
|
-
assert cast(Any,
|
|
61
|
+
assert cast(Any, response.is_closed) is True
|
|
74
62
|
|
|
75
63
|
@parametrize
|
|
76
64
|
def test_method_transcribe(self, client: Spitch) -> None:
|
|
@@ -117,52 +105,48 @@ class TestAsyncSpeech:
|
|
|
117
105
|
parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
|
|
118
106
|
|
|
119
107
|
@parametrize
|
|
120
|
-
|
|
121
|
-
async def test_method_generate(self, async_client: AsyncSpitch, respx_mock: MockRouter) -> None:
|
|
122
|
-
respx_mock.post("/v1/speech").mock(return_value=httpx.Response(200, json={"foo": "bar"}))
|
|
108
|
+
async def test_method_generate(self, async_client: AsyncSpitch) -> None:
|
|
123
109
|
speech = await async_client.speech.generate(
|
|
124
110
|
language="yo",
|
|
125
111
|
text="text",
|
|
126
|
-
voice="sade",
|
|
127
112
|
)
|
|
128
|
-
|
|
129
|
-
assert await speech.json() == {"foo": "bar"}
|
|
130
|
-
assert cast(Any, speech.is_closed) is True
|
|
131
|
-
assert isinstance(speech, AsyncBinaryAPIResponse)
|
|
113
|
+
assert_matches_type(object, speech, path=["response"])
|
|
132
114
|
|
|
133
115
|
@parametrize
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
respx_mock.post("/v1/speech").mock(return_value=httpx.Response(200, json={"foo": "bar"}))
|
|
137
|
-
|
|
138
|
-
speech = await async_client.speech.with_raw_response.generate(
|
|
116
|
+
async def test_method_generate_with_all_params(self, async_client: AsyncSpitch) -> None:
|
|
117
|
+
speech = await async_client.speech.generate(
|
|
139
118
|
language="yo",
|
|
140
119
|
text="text",
|
|
120
|
+
stream=True,
|
|
141
121
|
voice="sade",
|
|
142
122
|
)
|
|
123
|
+
assert_matches_type(object, speech, path=["response"])
|
|
143
124
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
125
|
+
@parametrize
|
|
126
|
+
async def test_raw_response_generate(self, async_client: AsyncSpitch) -> None:
|
|
127
|
+
response = await async_client.speech.with_raw_response.generate(
|
|
128
|
+
language="yo",
|
|
129
|
+
text="text",
|
|
130
|
+
)
|
|
131
|
+
|
|
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"])
|
|
148
136
|
|
|
149
137
|
@parametrize
|
|
150
|
-
|
|
151
|
-
async def test_streaming_response_generate(self, async_client: AsyncSpitch, respx_mock: MockRouter) -> None:
|
|
152
|
-
respx_mock.post("/v1/speech").mock(return_value=httpx.Response(200, json={"foo": "bar"}))
|
|
138
|
+
async def test_streaming_response_generate(self, async_client: AsyncSpitch) -> None:
|
|
153
139
|
async with async_client.speech.with_streaming_response.generate(
|
|
154
140
|
language="yo",
|
|
155
141
|
text="text",
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
assert
|
|
159
|
-
assert speech.http_request.headers.get("X-Stainless-Lang") == "python"
|
|
142
|
+
) as response:
|
|
143
|
+
assert not response.is_closed
|
|
144
|
+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
|
160
145
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
assert isinstance(speech, AsyncStreamedBinaryAPIResponse)
|
|
146
|
+
speech = await response.parse()
|
|
147
|
+
assert_matches_type(object, speech, path=["response"])
|
|
164
148
|
|
|
165
|
-
assert cast(Any,
|
|
149
|
+
assert cast(Any, response.is_closed) is True
|
|
166
150
|
|
|
167
151
|
@parametrize
|
|
168
152
|
async def test_method_transcribe(self, async_client: AsyncSpitch) -> None:
|
|
@@ -50,6 +50,43 @@ class TestText:
|
|
|
50
50
|
|
|
51
51
|
assert cast(Any, response.is_closed) is True
|
|
52
52
|
|
|
53
|
+
@parametrize
|
|
54
|
+
def test_method_translate(self, client: Spitch) -> None:
|
|
55
|
+
text = client.text.translate(
|
|
56
|
+
source="yo",
|
|
57
|
+
target="yo",
|
|
58
|
+
text="text",
|
|
59
|
+
)
|
|
60
|
+
assert_matches_type(object, text, path=["response"])
|
|
61
|
+
|
|
62
|
+
@parametrize
|
|
63
|
+
def test_raw_response_translate(self, client: Spitch) -> None:
|
|
64
|
+
response = client.text.with_raw_response.translate(
|
|
65
|
+
source="yo",
|
|
66
|
+
target="yo",
|
|
67
|
+
text="text",
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
assert response.is_closed is True
|
|
71
|
+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
|
72
|
+
text = response.parse()
|
|
73
|
+
assert_matches_type(object, text, path=["response"])
|
|
74
|
+
|
|
75
|
+
@parametrize
|
|
76
|
+
def test_streaming_response_translate(self, client: Spitch) -> None:
|
|
77
|
+
with client.text.with_streaming_response.translate(
|
|
78
|
+
source="yo",
|
|
79
|
+
target="yo",
|
|
80
|
+
text="text",
|
|
81
|
+
) as response:
|
|
82
|
+
assert not response.is_closed
|
|
83
|
+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
|
84
|
+
|
|
85
|
+
text = response.parse()
|
|
86
|
+
assert_matches_type(object, text, path=["response"])
|
|
87
|
+
|
|
88
|
+
assert cast(Any, response.is_closed) is True
|
|
89
|
+
|
|
53
90
|
|
|
54
91
|
class TestAsyncText:
|
|
55
92
|
parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
|
|
@@ -87,3 +124,40 @@ class TestAsyncText:
|
|
|
87
124
|
assert_matches_type(object, text, path=["response"])
|
|
88
125
|
|
|
89
126
|
assert cast(Any, response.is_closed) is True
|
|
127
|
+
|
|
128
|
+
@parametrize
|
|
129
|
+
async def test_method_translate(self, async_client: AsyncSpitch) -> None:
|
|
130
|
+
text = await async_client.text.translate(
|
|
131
|
+
source="yo",
|
|
132
|
+
target="yo",
|
|
133
|
+
text="text",
|
|
134
|
+
)
|
|
135
|
+
assert_matches_type(object, text, path=["response"])
|
|
136
|
+
|
|
137
|
+
@parametrize
|
|
138
|
+
async def test_raw_response_translate(self, async_client: AsyncSpitch) -> None:
|
|
139
|
+
response = await async_client.text.with_raw_response.translate(
|
|
140
|
+
source="yo",
|
|
141
|
+
target="yo",
|
|
142
|
+
text="text",
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
assert response.is_closed is True
|
|
146
|
+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
|
147
|
+
text = await response.parse()
|
|
148
|
+
assert_matches_type(object, text, path=["response"])
|
|
149
|
+
|
|
150
|
+
@parametrize
|
|
151
|
+
async def test_streaming_response_translate(self, async_client: AsyncSpitch) -> None:
|
|
152
|
+
async with async_client.text.with_streaming_response.translate(
|
|
153
|
+
source="yo",
|
|
154
|
+
target="yo",
|
|
155
|
+
text="text",
|
|
156
|
+
) as response:
|
|
157
|
+
assert not response.is_closed
|
|
158
|
+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
|
159
|
+
|
|
160
|
+
text = await response.parse()
|
|
161
|
+
assert_matches_type(object, text, path=["response"])
|
|
162
|
+
|
|
163
|
+
assert cast(Any, response.is_closed) is True
|
|
@@ -705,7 +705,7 @@ class TestSpitch:
|
|
|
705
705
|
with pytest.raises(APITimeoutError):
|
|
706
706
|
self.client.post(
|
|
707
707
|
"/v1/speech",
|
|
708
|
-
body=cast(object, dict(language="yo", text="text"
|
|
708
|
+
body=cast(object, dict(language="yo", text="text")),
|
|
709
709
|
cast_to=httpx.Response,
|
|
710
710
|
options={"headers": {RAW_RESPONSE_HEADER: "stream"}},
|
|
711
711
|
)
|
|
@@ -720,7 +720,7 @@ class TestSpitch:
|
|
|
720
720
|
with pytest.raises(APIStatusError):
|
|
721
721
|
self.client.post(
|
|
722
722
|
"/v1/speech",
|
|
723
|
-
body=cast(object, dict(language="yo", text="text"
|
|
723
|
+
body=cast(object, dict(language="yo", text="text")),
|
|
724
724
|
cast_to=httpx.Response,
|
|
725
725
|
options={"headers": {RAW_RESPONSE_HEADER: "stream"}},
|
|
726
726
|
)
|
|
@@ -744,7 +744,7 @@ class TestSpitch:
|
|
|
744
744
|
|
|
745
745
|
respx_mock.post("/v1/speech").mock(side_effect=retry_handler)
|
|
746
746
|
|
|
747
|
-
response = client.speech.with_raw_response.generate(language="yo", text="text"
|
|
747
|
+
response = client.speech.with_raw_response.generate(language="yo", text="text")
|
|
748
748
|
|
|
749
749
|
assert response.retries_taken == failures_before_success
|
|
750
750
|
assert int(response.http_request.headers.get("x-stainless-retry-count")) == failures_before_success
|
|
@@ -769,7 +769,7 @@ class TestSpitch:
|
|
|
769
769
|
respx_mock.post("/v1/speech").mock(side_effect=retry_handler)
|
|
770
770
|
|
|
771
771
|
response = client.speech.with_raw_response.generate(
|
|
772
|
-
language="yo", text="text",
|
|
772
|
+
language="yo", text="text", extra_headers={"x-stainless-retry-count": Omit()}
|
|
773
773
|
)
|
|
774
774
|
|
|
775
775
|
assert len(response.http_request.headers.get_list("x-stainless-retry-count")) == 0
|
|
@@ -794,7 +794,7 @@ class TestSpitch:
|
|
|
794
794
|
respx_mock.post("/v1/speech").mock(side_effect=retry_handler)
|
|
795
795
|
|
|
796
796
|
response = client.speech.with_raw_response.generate(
|
|
797
|
-
language="yo", text="text",
|
|
797
|
+
language="yo", text="text", extra_headers={"x-stainless-retry-count": "42"}
|
|
798
798
|
)
|
|
799
799
|
|
|
800
800
|
assert response.http_request.headers.get("x-stainless-retry-count") == "42"
|
|
@@ -1476,7 +1476,7 @@ class TestAsyncSpitch:
|
|
|
1476
1476
|
with pytest.raises(APITimeoutError):
|
|
1477
1477
|
await self.client.post(
|
|
1478
1478
|
"/v1/speech",
|
|
1479
|
-
body=cast(object, dict(language="yo", text="text"
|
|
1479
|
+
body=cast(object, dict(language="yo", text="text")),
|
|
1480
1480
|
cast_to=httpx.Response,
|
|
1481
1481
|
options={"headers": {RAW_RESPONSE_HEADER: "stream"}},
|
|
1482
1482
|
)
|
|
@@ -1491,7 +1491,7 @@ class TestAsyncSpitch:
|
|
|
1491
1491
|
with pytest.raises(APIStatusError):
|
|
1492
1492
|
await self.client.post(
|
|
1493
1493
|
"/v1/speech",
|
|
1494
|
-
body=cast(object, dict(language="yo", text="text"
|
|
1494
|
+
body=cast(object, dict(language="yo", text="text")),
|
|
1495
1495
|
cast_to=httpx.Response,
|
|
1496
1496
|
options={"headers": {RAW_RESPONSE_HEADER: "stream"}},
|
|
1497
1497
|
)
|
|
@@ -1518,7 +1518,7 @@ class TestAsyncSpitch:
|
|
|
1518
1518
|
|
|
1519
1519
|
respx_mock.post("/v1/speech").mock(side_effect=retry_handler)
|
|
1520
1520
|
|
|
1521
|
-
response = await client.speech.with_raw_response.generate(language="yo", text="text"
|
|
1521
|
+
response = await client.speech.with_raw_response.generate(language="yo", text="text")
|
|
1522
1522
|
|
|
1523
1523
|
assert response.retries_taken == failures_before_success
|
|
1524
1524
|
assert int(response.http_request.headers.get("x-stainless-retry-count")) == failures_before_success
|
|
@@ -1544,7 +1544,7 @@ class TestAsyncSpitch:
|
|
|
1544
1544
|
respx_mock.post("/v1/speech").mock(side_effect=retry_handler)
|
|
1545
1545
|
|
|
1546
1546
|
response = await client.speech.with_raw_response.generate(
|
|
1547
|
-
language="yo", text="text",
|
|
1547
|
+
language="yo", text="text", extra_headers={"x-stainless-retry-count": Omit()}
|
|
1548
1548
|
)
|
|
1549
1549
|
|
|
1550
1550
|
assert len(response.http_request.headers.get_list("x-stainless-retry-count")) == 0
|
|
@@ -1570,7 +1570,7 @@ class TestAsyncSpitch:
|
|
|
1570
1570
|
respx_mock.post("/v1/speech").mock(side_effect=retry_handler)
|
|
1571
1571
|
|
|
1572
1572
|
response = await client.speech.with_raw_response.generate(
|
|
1573
|
-
language="yo", text="text",
|
|
1573
|
+
language="yo", text="text", extra_headers={"x-stainless-retry-count": "42"}
|
|
1574
1574
|
)
|
|
1575
1575
|
|
|
1576
1576
|
assert response.http_request.headers.get("x-stainless-retry-count") == "42"
|
|
@@ -245,7 +245,7 @@ def test_nested_union_of_mixed_types() -> None:
|
|
|
245
245
|
assert m.foo is True
|
|
246
246
|
|
|
247
247
|
m = Model.construct(foo="CARD_HOLDER")
|
|
248
|
-
assert m.foo
|
|
248
|
+
assert m.foo == "CARD_HOLDER"
|
|
249
249
|
|
|
250
250
|
m = Model.construct(foo={"bar": False})
|
|
251
251
|
assert isinstance(m.foo, Submodel1)
|
|
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
|
|
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
|