spitch 1.7.0__tar.gz → 1.8.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.8.0/.release-please-manifest.json +3 -0
- {spitch-1.7.0 → spitch-1.8.0}/CHANGELOG.md +9 -0
- {spitch-1.7.0 → spitch-1.8.0}/PKG-INFO +1 -8
- {spitch-1.7.0 → spitch-1.8.0}/README.md +0 -7
- {spitch-1.7.0 → spitch-1.8.0}/api.md +4 -3
- {spitch-1.7.0 → spitch-1.8.0}/pyproject.toml +3 -2
- {spitch-1.7.0 → spitch-1.8.0}/requirements-dev.lock +1 -1
- {spitch-1.7.0 → spitch-1.8.0}/src/spitch/_version.py +1 -1
- {spitch-1.7.0 → spitch-1.8.0}/src/spitch/resources/speech.py +30 -24
- {spitch-1.7.0 → spitch-1.8.0}/src/spitch/resources/text.py +95 -1
- {spitch-1.7.0 → spitch-1.8.0}/src/spitch/types/__init__.py +1 -0
- {spitch-1.7.0 → spitch-1.8.0}/src/spitch/types/speech_generate_params.py +3 -1
- {spitch-1.7.0 → spitch-1.8.0}/src/spitch/types/speech_transcribe_params.py +4 -0
- spitch-1.8.0/src/spitch/types/text_translate_params.py +15 -0
- {spitch-1.7.0 → spitch-1.8.0}/tests/api_resources/test_speech.py +52 -64
- {spitch-1.7.0 → spitch-1.8.0}/tests/api_resources/test_text.py +74 -0
- {spitch-1.7.0 → spitch-1.8.0}/tests/test_client.py +10 -10
- {spitch-1.7.0 → spitch-1.8.0}/tests/test_models.py +1 -1
- spitch-1.7.0/.release-please-manifest.json +0 -3
- {spitch-1.7.0 → spitch-1.8.0}/.gitignore +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/CONTRIBUTING.md +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/LICENSE +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/SECURITY.md +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/bin/check-release-environment +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/bin/publish-pypi +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/examples/.keep +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/examples/example.py +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/mypy.ini +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/noxfile.py +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/release-please-config.json +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/requirements.lock +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/src/spitch/__init__.py +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/src/spitch/_base_client.py +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/src/spitch/_client.py +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/src/spitch/_compat.py +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/src/spitch/_constants.py +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/src/spitch/_exceptions.py +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/src/spitch/_files.py +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/src/spitch/_models.py +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/src/spitch/_qs.py +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/src/spitch/_resource.py +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/src/spitch/_response.py +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/src/spitch/_streaming.py +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/src/spitch/_types.py +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/src/spitch/_utils/__init__.py +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/src/spitch/_utils/_logs.py +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/src/spitch/_utils/_proxy.py +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/src/spitch/_utils/_reflection.py +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/src/spitch/_utils/_streams.py +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/src/spitch/_utils/_sync.py +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/src/spitch/_utils/_transform.py +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/src/spitch/_utils/_typing.py +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/src/spitch/_utils/_utils.py +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/src/spitch/lib/.keep +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/src/spitch/py.typed +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/src/spitch/resources/__init__.py +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/src/spitch/types/speech_transcibe_params.py +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/src/spitch/types/text_tone_mark_params.py +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/tests/__init__.py +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/tests/api_resources/__init__.py +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/tests/conftest.py +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/tests/sample_file.txt +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/tests/test_deepcopy.py +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/tests/test_extract_files.py +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/tests/test_files.py +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/tests/test_qs.py +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/tests/test_required_args.py +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/tests/test_response.py +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/tests/test_streaming.py +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/tests/test_transform.py +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/tests/test_utils/test_proxy.py +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/tests/test_utils/test_typing.py +0 -0
- {spitch-1.7.0 → spitch-1.8.0}/tests/utils.py +0 -0
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.8.0 (2024-10-17)
|
|
4
|
+
|
|
5
|
+
Full Changelog: [v1.7.0...v1.8.0](https://github.com/spi-tch/spitch-python/compare/v1.7.0...v1.8.0)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* **api:** api update ([#37](https://github.com/spi-tch/spitch-python/issues/37)) ([34e4fba](https://github.com/spi-tch/spitch-python/commit/34e4fba09e3744cfb443a3a0de5bf6a59bac50bc))
|
|
10
|
+
* **api:** api update ([#39](https://github.com/spi-tch/spitch-python/issues/39)) ([4cc3eb2](https://github.com/spi-tch/spitch-python/commit/4cc3eb24be8de66ae662de62c45818c0100bf894))
|
|
11
|
+
|
|
3
12
|
## 1.7.0 (2024-10-14)
|
|
4
13
|
|
|
5
14
|
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.8.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.8.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(
|
|
@@ -103,6 +99,8 @@ class SpeechResource(SyncAPIResource):
|
|
|
103
99
|
*,
|
|
104
100
|
language: Literal["yo", "en", "ha", "ig"],
|
|
105
101
|
content: Optional[FileTypes] | NotGiven = NOT_GIVEN,
|
|
102
|
+
multispeaker: Optional[bool] | NotGiven = NOT_GIVEN,
|
|
103
|
+
timestamp: Optional[bool] | NotGiven = NOT_GIVEN,
|
|
106
104
|
url: Optional[str] | NotGiven = NOT_GIVEN,
|
|
107
105
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
108
106
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
@@ -127,6 +125,8 @@ class SpeechResource(SyncAPIResource):
|
|
|
127
125
|
{
|
|
128
126
|
"language": language,
|
|
129
127
|
"content": content,
|
|
128
|
+
"multispeaker": multispeaker,
|
|
129
|
+
"timestamp": timestamp,
|
|
130
130
|
"url": url,
|
|
131
131
|
}
|
|
132
132
|
)
|
|
@@ -171,14 +171,15 @@ class AsyncSpeechResource(AsyncAPIResource):
|
|
|
171
171
|
*,
|
|
172
172
|
language: Literal["yo", "en", "ha", "ig"],
|
|
173
173
|
text: str,
|
|
174
|
-
|
|
174
|
+
stream: bool | NotGiven = NOT_GIVEN,
|
|
175
|
+
voice: Literal["sade", "segun", "femi", "funmi"] | NotGiven = NOT_GIVEN,
|
|
175
176
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
176
177
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
177
178
|
extra_headers: Headers | None = None,
|
|
178
179
|
extra_query: Query | None = None,
|
|
179
180
|
extra_body: Body | None = None,
|
|
180
181
|
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
181
|
-
) ->
|
|
182
|
+
) -> object:
|
|
182
183
|
"""
|
|
183
184
|
Synthesize
|
|
184
185
|
|
|
@@ -191,7 +192,6 @@ class AsyncSpeechResource(AsyncAPIResource):
|
|
|
191
192
|
|
|
192
193
|
timeout: Override the client-level default timeout for this request, in seconds
|
|
193
194
|
"""
|
|
194
|
-
extra_headers = {"Accept": "audio/wav", **(extra_headers or {})}
|
|
195
195
|
return await self._post(
|
|
196
196
|
"/v1/speech",
|
|
197
197
|
body=await async_maybe_transform(
|
|
@@ -203,9 +203,13 @@ class AsyncSpeechResource(AsyncAPIResource):
|
|
|
203
203
|
speech_generate_params.SpeechGenerateParams,
|
|
204
204
|
),
|
|
205
205
|
options=make_request_options(
|
|
206
|
-
extra_headers=extra_headers,
|
|
206
|
+
extra_headers=extra_headers,
|
|
207
|
+
extra_query=extra_query,
|
|
208
|
+
extra_body=extra_body,
|
|
209
|
+
timeout=timeout,
|
|
210
|
+
query=await async_maybe_transform({"stream": stream}, speech_generate_params.SpeechGenerateParams),
|
|
207
211
|
),
|
|
208
|
-
cast_to=
|
|
212
|
+
cast_to=object,
|
|
209
213
|
)
|
|
210
214
|
|
|
211
215
|
async def transcribe(
|
|
@@ -213,6 +217,8 @@ class AsyncSpeechResource(AsyncAPIResource):
|
|
|
213
217
|
*,
|
|
214
218
|
language: Literal["yo", "en", "ha", "ig"],
|
|
215
219
|
content: Optional[FileTypes] | NotGiven = NOT_GIVEN,
|
|
220
|
+
multispeaker: Optional[bool] | NotGiven = NOT_GIVEN,
|
|
221
|
+
timestamp: Optional[bool] | NotGiven = NOT_GIVEN,
|
|
216
222
|
url: Optional[str] | NotGiven = NOT_GIVEN,
|
|
217
223
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
218
224
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
@@ -237,6 +243,8 @@ class AsyncSpeechResource(AsyncAPIResource):
|
|
|
237
243
|
{
|
|
238
244
|
"language": language,
|
|
239
245
|
"content": content,
|
|
246
|
+
"multispeaker": multispeaker,
|
|
247
|
+
"timestamp": timestamp,
|
|
240
248
|
"url": url,
|
|
241
249
|
}
|
|
242
250
|
)
|
|
@@ -260,9 +268,8 @@ class SpeechResourceWithRawResponse:
|
|
|
260
268
|
def __init__(self, speech: SpeechResource) -> None:
|
|
261
269
|
self._speech = speech
|
|
262
270
|
|
|
263
|
-
self.generate =
|
|
271
|
+
self.generate = to_raw_response_wrapper(
|
|
264
272
|
speech.generate,
|
|
265
|
-
BinaryAPIResponse,
|
|
266
273
|
)
|
|
267
274
|
self.transcribe = to_raw_response_wrapper(
|
|
268
275
|
speech.transcribe,
|
|
@@ -273,9 +280,8 @@ class AsyncSpeechResourceWithRawResponse:
|
|
|
273
280
|
def __init__(self, speech: AsyncSpeechResource) -> None:
|
|
274
281
|
self._speech = speech
|
|
275
282
|
|
|
276
|
-
self.generate =
|
|
283
|
+
self.generate = async_to_raw_response_wrapper(
|
|
277
284
|
speech.generate,
|
|
278
|
-
AsyncBinaryAPIResponse,
|
|
279
285
|
)
|
|
280
286
|
self.transcribe = async_to_raw_response_wrapper(
|
|
281
287
|
speech.transcribe,
|
|
@@ -286,7 +292,7 @@ class SpeechResourceWithStreamingResponse:
|
|
|
286
292
|
def __init__(self, speech: SpeechResource) -> None:
|
|
287
293
|
self._speech = speech
|
|
288
294
|
|
|
289
|
-
self.generate =
|
|
295
|
+
self.generate = to_streamed_response_wrapper(
|
|
290
296
|
speech.generate,
|
|
291
297
|
StreamedBinaryAPIResponse
|
|
292
298
|
)
|
|
@@ -299,7 +305,7 @@ class AsyncSpeechResourceWithStreamingResponse:
|
|
|
299
305
|
def __init__(self, speech: AsyncSpeechResource) -> None:
|
|
300
306
|
self._speech = speech
|
|
301
307
|
|
|
302
|
-
self.generate =
|
|
308
|
+
self.generate = async_to_streamed_response_wrapper(
|
|
303
309
|
speech.generate,
|
|
304
310
|
AsyncStreamedBinaryAPIResponse
|
|
305
311
|
)
|
|
@@ -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:
|
|
@@ -84,6 +72,8 @@ class TestSpeech:
|
|
|
84
72
|
speech = client.speech.transcribe(
|
|
85
73
|
language="yo",
|
|
86
74
|
content=b"raw file contents",
|
|
75
|
+
multispeaker=True,
|
|
76
|
+
timestamp=True,
|
|
87
77
|
url="url",
|
|
88
78
|
)
|
|
89
79
|
assert_matches_type(object, speech, path=["response"])
|
|
@@ -117,52 +107,48 @@ class TestAsyncSpeech:
|
|
|
117
107
|
parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
|
|
118
108
|
|
|
119
109
|
@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"}))
|
|
110
|
+
async def test_method_generate(self, async_client: AsyncSpitch) -> None:
|
|
123
111
|
speech = await async_client.speech.generate(
|
|
124
112
|
language="yo",
|
|
125
113
|
text="text",
|
|
126
|
-
voice="sade",
|
|
127
114
|
)
|
|
128
|
-
|
|
129
|
-
assert await speech.json() == {"foo": "bar"}
|
|
130
|
-
assert cast(Any, speech.is_closed) is True
|
|
131
|
-
assert isinstance(speech, AsyncBinaryAPIResponse)
|
|
115
|
+
assert_matches_type(object, speech, path=["response"])
|
|
132
116
|
|
|
133
117
|
@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(
|
|
118
|
+
async def test_method_generate_with_all_params(self, async_client: AsyncSpitch) -> None:
|
|
119
|
+
speech = await async_client.speech.generate(
|
|
139
120
|
language="yo",
|
|
140
121
|
text="text",
|
|
122
|
+
stream=True,
|
|
141
123
|
voice="sade",
|
|
142
124
|
)
|
|
125
|
+
assert_matches_type(object, speech, path=["response"])
|
|
143
126
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
127
|
+
@parametrize
|
|
128
|
+
async def test_raw_response_generate(self, async_client: AsyncSpitch) -> None:
|
|
129
|
+
response = await async_client.speech.with_raw_response.generate(
|
|
130
|
+
language="yo",
|
|
131
|
+
text="text",
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
assert response.is_closed is True
|
|
135
|
+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
|
136
|
+
speech = await response.parse()
|
|
137
|
+
assert_matches_type(object, speech, path=["response"])
|
|
148
138
|
|
|
149
139
|
@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"}))
|
|
140
|
+
async def test_streaming_response_generate(self, async_client: AsyncSpitch) -> None:
|
|
153
141
|
async with async_client.speech.with_streaming_response.generate(
|
|
154
142
|
language="yo",
|
|
155
143
|
text="text",
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
assert
|
|
159
|
-
assert speech.http_request.headers.get("X-Stainless-Lang") == "python"
|
|
144
|
+
) as response:
|
|
145
|
+
assert not response.is_closed
|
|
146
|
+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
|
160
147
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
assert isinstance(speech, AsyncStreamedBinaryAPIResponse)
|
|
148
|
+
speech = await response.parse()
|
|
149
|
+
assert_matches_type(object, speech, path=["response"])
|
|
164
150
|
|
|
165
|
-
assert cast(Any,
|
|
151
|
+
assert cast(Any, response.is_closed) is True
|
|
166
152
|
|
|
167
153
|
@parametrize
|
|
168
154
|
async def test_method_transcribe(self, async_client: AsyncSpitch) -> None:
|
|
@@ -176,6 +162,8 @@ class TestAsyncSpeech:
|
|
|
176
162
|
speech = await async_client.speech.transcribe(
|
|
177
163
|
language="yo",
|
|
178
164
|
content=b"raw file contents",
|
|
165
|
+
multispeaker=True,
|
|
166
|
+
timestamp=True,
|
|
179
167
|
url="url",
|
|
180
168
|
)
|
|
181
169
|
assert_matches_type(object, speech, path=["response"])
|
|
@@ -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
|