spitch 1.5.0__tar.gz → 1.7.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.
- spitch-1.7.0/.release-please-manifest.json +3 -0
- {spitch-1.5.0 → spitch-1.7.0}/CHANGELOG.md +26 -0
- {spitch-1.5.0 → spitch-1.7.0}/PKG-INFO +8 -1
- {spitch-1.5.0 → spitch-1.7.0}/README.md +7 -0
- {spitch-1.5.0 → spitch-1.7.0}/api.md +2 -2
- {spitch-1.5.0 → spitch-1.7.0}/examples/example.py +2 -1
- {spitch-1.5.0 → spitch-1.7.0}/pyproject.toml +1 -1
- {spitch-1.5.0 → spitch-1.7.0}/src/spitch/_base_client.py +8 -1
- {spitch-1.5.0 → spitch-1.7.0}/src/spitch/_version.py +1 -1
- {spitch-1.5.0 → spitch-1.7.0}/src/spitch/resources/speech.py +15 -15
- {spitch-1.5.0 → spitch-1.7.0}/src/spitch/types/__init__.py +1 -1
- {spitch-1.5.0 → spitch-1.7.0}/src/spitch/types/speech_generate_params.py +1 -1
- spitch-1.7.0/src/spitch/types/speech_transcribe_params.py +18 -0
- {spitch-1.5.0 → spitch-1.7.0}/tests/api_resources/test_speech.py +20 -42
- {spitch-1.5.0 → spitch-1.7.0}/tests/test_client.py +12 -10
- spitch-1.5.0/.release-please-manifest.json +0 -3
- {spitch-1.5.0 → spitch-1.7.0}/.gitignore +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/CONTRIBUTING.md +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/LICENSE +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/SECURITY.md +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/bin/check-release-environment +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/bin/publish-pypi +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/examples/.keep +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/mypy.ini +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/noxfile.py +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/release-please-config.json +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/requirements-dev.lock +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/requirements.lock +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/src/spitch/__init__.py +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/src/spitch/_client.py +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/src/spitch/_compat.py +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/src/spitch/_constants.py +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/src/spitch/_exceptions.py +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/src/spitch/_files.py +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/src/spitch/_models.py +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/src/spitch/_qs.py +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/src/spitch/_resource.py +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/src/spitch/_response.py +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/src/spitch/_streaming.py +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/src/spitch/_types.py +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/src/spitch/_utils/__init__.py +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/src/spitch/_utils/_logs.py +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/src/spitch/_utils/_proxy.py +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/src/spitch/_utils/_reflection.py +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/src/spitch/_utils/_streams.py +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/src/spitch/_utils/_sync.py +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/src/spitch/_utils/_transform.py +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/src/spitch/_utils/_typing.py +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/src/spitch/_utils/_utils.py +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/src/spitch/lib/.keep +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/src/spitch/py.typed +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/src/spitch/resources/__init__.py +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/src/spitch/resources/text.py +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/src/spitch/types/speech_transcibe_params.py +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/src/spitch/types/text_tone_mark_params.py +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/tests/__init__.py +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/tests/api_resources/__init__.py +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/tests/api_resources/test_text.py +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/tests/conftest.py +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/tests/sample_file.txt +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/tests/test_deepcopy.py +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/tests/test_extract_files.py +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/tests/test_files.py +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/tests/test_models.py +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/tests/test_qs.py +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/tests/test_required_args.py +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/tests/test_response.py +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/tests/test_streaming.py +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/tests/test_transform.py +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/tests/test_utils/test_proxy.py +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/tests/test_utils/test_typing.py +0 -0
- {spitch-1.5.0 → spitch-1.7.0}/tests/utils.py +0 -0
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.7.0 (2024-10-14)
|
|
4
|
+
|
|
5
|
+
Full Changelog: [v1.6.0...v1.7.0](https://github.com/spi-tch/spitch-python/compare/v1.6.0...v1.7.0)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* **api:** api update ([#34](https://github.com/spi-tch/spitch-python/issues/34)) ([1cfe384](https://github.com/spi-tch/spitch-python/commit/1cfe38416d8c82453609132080a167c0ab735f51))
|
|
10
|
+
|
|
11
|
+
## 1.6.0 (2024-10-07)
|
|
12
|
+
|
|
13
|
+
Full Changelog: [v1.5.0...v1.6.0](https://github.com/spi-tch/spitch-python/compare/v1.5.0...v1.6.0)
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* **api:** update via SDK Studio ([#29](https://github.com/spi-tch/spitch-python/issues/29)) ([1dae398](https://github.com/spi-tch/spitch-python/commit/1dae398c9f7ba96bc45d59f4faa2934b2cad59e4))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* **client:** avoid OverflowError with very large retry counts ([#30](https://github.com/spi-tch/spitch-python/issues/30)) ([1e63664](https://github.com/spi-tch/spitch-python/commit/1e63664f64fa1f38f2294df8e06bd60a17885d2f))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Chores
|
|
26
|
+
|
|
27
|
+
* add repr to PageInfo class ([#32](https://github.com/spi-tch/spitch-python/issues/32)) ([ea3c95d](https://github.com/spi-tch/spitch-python/commit/ea3c95d2ce4a9fdd1e558931f8a92904a9394321))
|
|
28
|
+
|
|
3
29
|
## 1.5.0 (2024-10-07)
|
|
4
30
|
|
|
5
31
|
Full Changelog: [v1.4.0...v1.5.0](https://github.com/spi-tch/spitch-python/compare/v1.4.0...v1.5.0)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: spitch
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.7.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,6 +69,7 @@ client = Spitch(
|
|
|
69
69
|
response = client.speech.generate(
|
|
70
70
|
language="yo",
|
|
71
71
|
text="text",
|
|
72
|
+
voice="sade",
|
|
72
73
|
)
|
|
73
74
|
```
|
|
74
75
|
|
|
@@ -96,6 +97,7 @@ async def main() -> None:
|
|
|
96
97
|
response = await client.speech.generate(
|
|
97
98
|
language="yo",
|
|
98
99
|
text="text",
|
|
100
|
+
voice="sade",
|
|
99
101
|
)
|
|
100
102
|
|
|
101
103
|
|
|
@@ -132,6 +134,7 @@ try:
|
|
|
132
134
|
client.speech.generate(
|
|
133
135
|
language="yo",
|
|
134
136
|
text="text",
|
|
137
|
+
voice="sade",
|
|
135
138
|
)
|
|
136
139
|
except spitch.APIConnectionError as e:
|
|
137
140
|
print("The server could not be reached")
|
|
@@ -178,6 +181,7 @@ client = Spitch(
|
|
|
178
181
|
client.with_options(max_retries=5).speech.generate(
|
|
179
182
|
language="yo",
|
|
180
183
|
text="text",
|
|
184
|
+
voice="sade",
|
|
181
185
|
)
|
|
182
186
|
```
|
|
183
187
|
|
|
@@ -204,6 +208,7 @@ client = Spitch(
|
|
|
204
208
|
client.with_options(timeout=5.0).speech.generate(
|
|
205
209
|
language="yo",
|
|
206
210
|
text="text",
|
|
211
|
+
voice="sade",
|
|
207
212
|
)
|
|
208
213
|
```
|
|
209
214
|
|
|
@@ -246,6 +251,7 @@ client = Spitch()
|
|
|
246
251
|
response = client.speech.with_raw_response.generate(
|
|
247
252
|
language="yo",
|
|
248
253
|
text="text",
|
|
254
|
+
voice="sade",
|
|
249
255
|
)
|
|
250
256
|
print(response.headers.get('X-My-Header'))
|
|
251
257
|
|
|
@@ -267,6 +273,7 @@ To stream the response body, use `.with_streaming_response` instead, which requi
|
|
|
267
273
|
with client.speech.with_streaming_response.generate(
|
|
268
274
|
language="yo",
|
|
269
275
|
text="text",
|
|
276
|
+
voice="sade",
|
|
270
277
|
) as response:
|
|
271
278
|
print(response.headers.get("X-My-Header"))
|
|
272
279
|
|
|
@@ -35,6 +35,7 @@ client = Spitch(
|
|
|
35
35
|
response = client.speech.generate(
|
|
36
36
|
language="yo",
|
|
37
37
|
text="text",
|
|
38
|
+
voice="sade",
|
|
38
39
|
)
|
|
39
40
|
```
|
|
40
41
|
|
|
@@ -62,6 +63,7 @@ async def main() -> None:
|
|
|
62
63
|
response = await client.speech.generate(
|
|
63
64
|
language="yo",
|
|
64
65
|
text="text",
|
|
66
|
+
voice="sade",
|
|
65
67
|
)
|
|
66
68
|
|
|
67
69
|
|
|
@@ -98,6 +100,7 @@ try:
|
|
|
98
100
|
client.speech.generate(
|
|
99
101
|
language="yo",
|
|
100
102
|
text="text",
|
|
103
|
+
voice="sade",
|
|
101
104
|
)
|
|
102
105
|
except spitch.APIConnectionError as e:
|
|
103
106
|
print("The server could not be reached")
|
|
@@ -144,6 +147,7 @@ client = Spitch(
|
|
|
144
147
|
client.with_options(max_retries=5).speech.generate(
|
|
145
148
|
language="yo",
|
|
146
149
|
text="text",
|
|
150
|
+
voice="sade",
|
|
147
151
|
)
|
|
148
152
|
```
|
|
149
153
|
|
|
@@ -170,6 +174,7 @@ client = Spitch(
|
|
|
170
174
|
client.with_options(timeout=5.0).speech.generate(
|
|
171
175
|
language="yo",
|
|
172
176
|
text="text",
|
|
177
|
+
voice="sade",
|
|
173
178
|
)
|
|
174
179
|
```
|
|
175
180
|
|
|
@@ -212,6 +217,7 @@ client = Spitch()
|
|
|
212
217
|
response = client.speech.with_raw_response.generate(
|
|
213
218
|
language="yo",
|
|
214
219
|
text="text",
|
|
220
|
+
voice="sade",
|
|
215
221
|
)
|
|
216
222
|
print(response.headers.get('X-My-Header'))
|
|
217
223
|
|
|
@@ -233,6 +239,7 @@ To stream the response body, use `.with_streaming_response` instead, which requi
|
|
|
233
239
|
with client.speech.with_streaming_response.generate(
|
|
234
240
|
language="yo",
|
|
235
241
|
text="text",
|
|
242
|
+
voice="sade",
|
|
236
243
|
) as response:
|
|
237
244
|
print(response.headers.get("X-My-Header"))
|
|
238
245
|
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
Types:
|
|
4
4
|
|
|
5
5
|
```python
|
|
6
|
-
from spitch.types import
|
|
6
|
+
from spitch.types import SpeechTranscribeResponse
|
|
7
7
|
```
|
|
8
8
|
|
|
9
9
|
Methods:
|
|
10
10
|
|
|
11
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
|
-
- <code title="post /v1/transcriptions">client.speech.<a href="./src/spitch/resources/speech.py">
|
|
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
|
|
15
15
|
|
|
@@ -13,7 +13,8 @@ def main() -> None:
|
|
|
13
13
|
start_time = time.time()
|
|
14
14
|
with client.speech.with_streaming_response.generate(
|
|
15
15
|
language="yo",
|
|
16
|
-
text="Bawo ni ololufe?"
|
|
16
|
+
text="Bawo ni ololufe?",
|
|
17
|
+
voice="funmi"
|
|
17
18
|
) as speech:
|
|
18
19
|
print(f"Time to first byte: {int((time.time() - start_time) * 1000)}ms")
|
|
19
20
|
speech.stream_to_file(speech_file_path)
|
|
@@ -143,6 +143,12 @@ class PageInfo:
|
|
|
143
143
|
self.url = url
|
|
144
144
|
self.params = params
|
|
145
145
|
|
|
146
|
+
@override
|
|
147
|
+
def __repr__(self) -> str:
|
|
148
|
+
if self.url:
|
|
149
|
+
return f"{self.__class__.__name__}(url={self.url})"
|
|
150
|
+
return f"{self.__class__.__name__}(params={self.params})"
|
|
151
|
+
|
|
146
152
|
|
|
147
153
|
class BasePage(GenericModel, Generic[_T]):
|
|
148
154
|
"""
|
|
@@ -689,7 +695,8 @@ class BaseClient(Generic[_HttpxClientT, _DefaultStreamT]):
|
|
|
689
695
|
if retry_after is not None and 0 < retry_after <= 60:
|
|
690
696
|
return retry_after
|
|
691
697
|
|
|
692
|
-
|
|
698
|
+
# Also cap retry count to 1000 to avoid any potential overflows with `pow`
|
|
699
|
+
nb_retries = min(max_retries - remaining_retries, 1000)
|
|
693
700
|
|
|
694
701
|
# Apply exponential backoff, but not more than the max.
|
|
695
702
|
sleep_seconds = min(INITIAL_RETRY_DELAY * pow(2.0, nb_retries), MAX_RETRY_DELAY)
|
|
@@ -7,7 +7,7 @@ from typing_extensions import Literal
|
|
|
7
7
|
|
|
8
8
|
import httpx
|
|
9
9
|
|
|
10
|
-
from ..types import speech_generate_params,
|
|
10
|
+
from ..types import speech_generate_params, speech_transcribe_params
|
|
11
11
|
from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven, FileTypes
|
|
12
12
|
from .._utils import (
|
|
13
13
|
extract_files,
|
|
@@ -61,7 +61,7 @@ class SpeechResource(SyncAPIResource):
|
|
|
61
61
|
*,
|
|
62
62
|
language: Literal["yo", "en", "ha", "ig"],
|
|
63
63
|
text: str,
|
|
64
|
-
voice: Literal["sade", "segun", "femi", "funmi"]
|
|
64
|
+
voice: Literal["sade", "segun", "femi", "funmi"],
|
|
65
65
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
66
66
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
67
67
|
extra_headers: Headers | None = None,
|
|
@@ -98,7 +98,7 @@ class SpeechResource(SyncAPIResource):
|
|
|
98
98
|
cast_to=BinaryAPIResponse,
|
|
99
99
|
)
|
|
100
100
|
|
|
101
|
-
def
|
|
101
|
+
def transcribe(
|
|
102
102
|
self,
|
|
103
103
|
*,
|
|
104
104
|
language: Literal["yo", "en", "ha", "ig"],
|
|
@@ -137,7 +137,7 @@ class SpeechResource(SyncAPIResource):
|
|
|
137
137
|
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
|
|
138
138
|
return self._post(
|
|
139
139
|
"/v1/transcriptions",
|
|
140
|
-
body=maybe_transform(body,
|
|
140
|
+
body=maybe_transform(body, speech_transcribe_params.SpeechTranscribeParams),
|
|
141
141
|
files=files,
|
|
142
142
|
options=make_request_options(
|
|
143
143
|
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
@@ -171,7 +171,7 @@ class AsyncSpeechResource(AsyncAPIResource):
|
|
|
171
171
|
*,
|
|
172
172
|
language: Literal["yo", "en", "ha", "ig"],
|
|
173
173
|
text: str,
|
|
174
|
-
voice: Literal["sade", "segun", "femi", "funmi"]
|
|
174
|
+
voice: Literal["sade", "segun", "femi", "funmi"],
|
|
175
175
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
176
176
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
177
177
|
extra_headers: Headers | None = None,
|
|
@@ -208,7 +208,7 @@ class AsyncSpeechResource(AsyncAPIResource):
|
|
|
208
208
|
cast_to=AsyncBinaryAPIResponse,
|
|
209
209
|
)
|
|
210
210
|
|
|
211
|
-
async def
|
|
211
|
+
async def transcribe(
|
|
212
212
|
self,
|
|
213
213
|
*,
|
|
214
214
|
language: Literal["yo", "en", "ha", "ig"],
|
|
@@ -247,7 +247,7 @@ class AsyncSpeechResource(AsyncAPIResource):
|
|
|
247
247
|
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
|
|
248
248
|
return await self._post(
|
|
249
249
|
"/v1/transcriptions",
|
|
250
|
-
body=await async_maybe_transform(body,
|
|
250
|
+
body=await async_maybe_transform(body, speech_transcribe_params.SpeechTranscribeParams),
|
|
251
251
|
files=files,
|
|
252
252
|
options=make_request_options(
|
|
253
253
|
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
@@ -264,8 +264,8 @@ class SpeechResourceWithRawResponse:
|
|
|
264
264
|
speech.generate,
|
|
265
265
|
BinaryAPIResponse,
|
|
266
266
|
)
|
|
267
|
-
self.
|
|
268
|
-
speech.
|
|
267
|
+
self.transcribe = to_raw_response_wrapper(
|
|
268
|
+
speech.transcribe,
|
|
269
269
|
)
|
|
270
270
|
|
|
271
271
|
|
|
@@ -277,8 +277,8 @@ class AsyncSpeechResourceWithRawResponse:
|
|
|
277
277
|
speech.generate,
|
|
278
278
|
AsyncBinaryAPIResponse,
|
|
279
279
|
)
|
|
280
|
-
self.
|
|
281
|
-
speech.
|
|
280
|
+
self.transcribe = async_to_raw_response_wrapper(
|
|
281
|
+
speech.transcribe,
|
|
282
282
|
)
|
|
283
283
|
|
|
284
284
|
|
|
@@ -290,8 +290,8 @@ class SpeechResourceWithStreamingResponse:
|
|
|
290
290
|
speech.generate,
|
|
291
291
|
StreamedBinaryAPIResponse
|
|
292
292
|
)
|
|
293
|
-
self.
|
|
294
|
-
speech.
|
|
293
|
+
self.transcribe = to_streamed_response_wrapper(
|
|
294
|
+
speech.transcribe,
|
|
295
295
|
)
|
|
296
296
|
|
|
297
297
|
|
|
@@ -303,6 +303,6 @@ class AsyncSpeechResourceWithStreamingResponse:
|
|
|
303
303
|
speech.generate,
|
|
304
304
|
AsyncStreamedBinaryAPIResponse
|
|
305
305
|
)
|
|
306
|
-
self.
|
|
307
|
-
speech.
|
|
306
|
+
self.transcribe = async_to_streamed_response_wrapper(
|
|
307
|
+
speech.transcribe,
|
|
308
308
|
)
|
|
@@ -4,4 +4,4 @@ from __future__ import annotations
|
|
|
4
4
|
|
|
5
5
|
from .text_tone_mark_params import TextToneMarkParams as TextToneMarkParams
|
|
6
6
|
from .speech_generate_params import SpeechGenerateParams as SpeechGenerateParams
|
|
7
|
-
from .
|
|
7
|
+
from .speech_transcribe_params import SpeechTranscribeParams as SpeechTranscribeParams
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Optional
|
|
6
|
+
from typing_extensions import Literal, Required, TypedDict
|
|
7
|
+
|
|
8
|
+
from .._types import FileTypes
|
|
9
|
+
|
|
10
|
+
__all__ = ["SpeechTranscribeParams"]
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class SpeechTranscribeParams(TypedDict, total=False):
|
|
14
|
+
language: Required[Literal["yo", "en", "ha", "ig"]]
|
|
15
|
+
|
|
16
|
+
content: Optional[FileTypes]
|
|
17
|
+
|
|
18
|
+
url: Optional[str]
|
|
@@ -27,19 +27,6 @@ class TestSpeech:
|
|
|
27
27
|
@parametrize
|
|
28
28
|
@pytest.mark.respx(base_url=base_url)
|
|
29
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"}))
|
|
31
|
-
speech = client.speech.generate(
|
|
32
|
-
language="yo",
|
|
33
|
-
text="text",
|
|
34
|
-
)
|
|
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)
|
|
39
|
-
|
|
40
|
-
@parametrize
|
|
41
|
-
@pytest.mark.respx(base_url=base_url)
|
|
42
|
-
def test_method_generate_with_all_params(self, client: Spitch, respx_mock: MockRouter) -> None:
|
|
43
30
|
respx_mock.post("/v1/speech").mock(return_value=httpx.Response(200, json={"foo": "bar"}))
|
|
44
31
|
speech = client.speech.generate(
|
|
45
32
|
language="yo",
|
|
@@ -59,6 +46,7 @@ class TestSpeech:
|
|
|
59
46
|
speech = client.speech.with_raw_response.generate(
|
|
60
47
|
language="yo",
|
|
61
48
|
text="text",
|
|
49
|
+
voice="sade",
|
|
62
50
|
)
|
|
63
51
|
|
|
64
52
|
assert speech.is_closed is True
|
|
@@ -73,6 +61,7 @@ class TestSpeech:
|
|
|
73
61
|
with client.speech.with_streaming_response.generate(
|
|
74
62
|
language="yo",
|
|
75
63
|
text="text",
|
|
64
|
+
voice="sade",
|
|
76
65
|
) as speech:
|
|
77
66
|
assert not speech.is_closed
|
|
78
67
|
assert speech.http_request.headers.get("X-Stainless-Lang") == "python"
|
|
@@ -84,15 +73,15 @@ class TestSpeech:
|
|
|
84
73
|
assert cast(Any, speech.is_closed) is True
|
|
85
74
|
|
|
86
75
|
@parametrize
|
|
87
|
-
def
|
|
88
|
-
speech = client.speech.
|
|
76
|
+
def test_method_transcribe(self, client: Spitch) -> None:
|
|
77
|
+
speech = client.speech.transcribe(
|
|
89
78
|
language="yo",
|
|
90
79
|
)
|
|
91
80
|
assert_matches_type(object, speech, path=["response"])
|
|
92
81
|
|
|
93
82
|
@parametrize
|
|
94
|
-
def
|
|
95
|
-
speech = client.speech.
|
|
83
|
+
def test_method_transcribe_with_all_params(self, client: Spitch) -> None:
|
|
84
|
+
speech = client.speech.transcribe(
|
|
96
85
|
language="yo",
|
|
97
86
|
content=b"raw file contents",
|
|
98
87
|
url="url",
|
|
@@ -100,8 +89,8 @@ class TestSpeech:
|
|
|
100
89
|
assert_matches_type(object, speech, path=["response"])
|
|
101
90
|
|
|
102
91
|
@parametrize
|
|
103
|
-
def
|
|
104
|
-
response = client.speech.with_raw_response.
|
|
92
|
+
def test_raw_response_transcribe(self, client: Spitch) -> None:
|
|
93
|
+
response = client.speech.with_raw_response.transcribe(
|
|
105
94
|
language="yo",
|
|
106
95
|
)
|
|
107
96
|
|
|
@@ -111,8 +100,8 @@ class TestSpeech:
|
|
|
111
100
|
assert_matches_type(object, speech, path=["response"])
|
|
112
101
|
|
|
113
102
|
@parametrize
|
|
114
|
-
def
|
|
115
|
-
with client.speech.with_streaming_response.
|
|
103
|
+
def test_streaming_response_transcribe(self, client: Spitch) -> None:
|
|
104
|
+
with client.speech.with_streaming_response.transcribe(
|
|
116
105
|
language="yo",
|
|
117
106
|
) as response:
|
|
118
107
|
assert not response.is_closed
|
|
@@ -130,19 +119,6 @@ class TestAsyncSpeech:
|
|
|
130
119
|
@parametrize
|
|
131
120
|
@pytest.mark.respx(base_url=base_url)
|
|
132
121
|
async def test_method_generate(self, async_client: AsyncSpitch, respx_mock: MockRouter) -> None:
|
|
133
|
-
respx_mock.post("/v1/speech").mock(return_value=httpx.Response(200, json={"foo": "bar"}))
|
|
134
|
-
speech = await async_client.speech.generate(
|
|
135
|
-
language="yo",
|
|
136
|
-
text="text",
|
|
137
|
-
)
|
|
138
|
-
assert speech.is_closed
|
|
139
|
-
assert await speech.json() == {"foo": "bar"}
|
|
140
|
-
assert cast(Any, speech.is_closed) is True
|
|
141
|
-
assert isinstance(speech, AsyncBinaryAPIResponse)
|
|
142
|
-
|
|
143
|
-
@parametrize
|
|
144
|
-
@pytest.mark.respx(base_url=base_url)
|
|
145
|
-
async def test_method_generate_with_all_params(self, async_client: AsyncSpitch, respx_mock: MockRouter) -> None:
|
|
146
122
|
respx_mock.post("/v1/speech").mock(return_value=httpx.Response(200, json={"foo": "bar"}))
|
|
147
123
|
speech = await async_client.speech.generate(
|
|
148
124
|
language="yo",
|
|
@@ -162,6 +138,7 @@ class TestAsyncSpeech:
|
|
|
162
138
|
speech = await async_client.speech.with_raw_response.generate(
|
|
163
139
|
language="yo",
|
|
164
140
|
text="text",
|
|
141
|
+
voice="sade",
|
|
165
142
|
)
|
|
166
143
|
|
|
167
144
|
assert speech.is_closed is True
|
|
@@ -176,6 +153,7 @@ class TestAsyncSpeech:
|
|
|
176
153
|
async with async_client.speech.with_streaming_response.generate(
|
|
177
154
|
language="yo",
|
|
178
155
|
text="text",
|
|
156
|
+
voice="sade",
|
|
179
157
|
) as speech:
|
|
180
158
|
assert not speech.is_closed
|
|
181
159
|
assert speech.http_request.headers.get("X-Stainless-Lang") == "python"
|
|
@@ -187,15 +165,15 @@ class TestAsyncSpeech:
|
|
|
187
165
|
assert cast(Any, speech.is_closed) is True
|
|
188
166
|
|
|
189
167
|
@parametrize
|
|
190
|
-
async def
|
|
191
|
-
speech = await async_client.speech.
|
|
168
|
+
async def test_method_transcribe(self, async_client: AsyncSpitch) -> None:
|
|
169
|
+
speech = await async_client.speech.transcribe(
|
|
192
170
|
language="yo",
|
|
193
171
|
)
|
|
194
172
|
assert_matches_type(object, speech, path=["response"])
|
|
195
173
|
|
|
196
174
|
@parametrize
|
|
197
|
-
async def
|
|
198
|
-
speech = await async_client.speech.
|
|
175
|
+
async def test_method_transcribe_with_all_params(self, async_client: AsyncSpitch) -> None:
|
|
176
|
+
speech = await async_client.speech.transcribe(
|
|
199
177
|
language="yo",
|
|
200
178
|
content=b"raw file contents",
|
|
201
179
|
url="url",
|
|
@@ -203,8 +181,8 @@ class TestAsyncSpeech:
|
|
|
203
181
|
assert_matches_type(object, speech, path=["response"])
|
|
204
182
|
|
|
205
183
|
@parametrize
|
|
206
|
-
async def
|
|
207
|
-
response = await async_client.speech.with_raw_response.
|
|
184
|
+
async def test_raw_response_transcribe(self, async_client: AsyncSpitch) -> None:
|
|
185
|
+
response = await async_client.speech.with_raw_response.transcribe(
|
|
208
186
|
language="yo",
|
|
209
187
|
)
|
|
210
188
|
|
|
@@ -214,8 +192,8 @@ class TestAsyncSpeech:
|
|
|
214
192
|
assert_matches_type(object, speech, path=["response"])
|
|
215
193
|
|
|
216
194
|
@parametrize
|
|
217
|
-
async def
|
|
218
|
-
async with async_client.speech.with_streaming_response.
|
|
195
|
+
async def test_streaming_response_transcribe(self, async_client: AsyncSpitch) -> None:
|
|
196
|
+
async with async_client.speech.with_streaming_response.transcribe(
|
|
219
197
|
language="yo",
|
|
220
198
|
) as response:
|
|
221
199
|
assert not response.is_closed
|
|
@@ -685,6 +685,7 @@ class TestSpitch:
|
|
|
685
685
|
[3, "", 0.5],
|
|
686
686
|
[2, "", 0.5 * 2.0],
|
|
687
687
|
[1, "", 0.5 * 4.0],
|
|
688
|
+
[-1100, "", 7.8], # test large number potentially overflowing
|
|
688
689
|
],
|
|
689
690
|
)
|
|
690
691
|
@mock.patch("time.time", mock.MagicMock(return_value=1696004797))
|
|
@@ -704,7 +705,7 @@ class TestSpitch:
|
|
|
704
705
|
with pytest.raises(APITimeoutError):
|
|
705
706
|
self.client.post(
|
|
706
707
|
"/v1/speech",
|
|
707
|
-
body=cast(object, dict(language="yo", text="text")),
|
|
708
|
+
body=cast(object, dict(language="yo", text="text", voice="sade")),
|
|
708
709
|
cast_to=httpx.Response,
|
|
709
710
|
options={"headers": {RAW_RESPONSE_HEADER: "stream"}},
|
|
710
711
|
)
|
|
@@ -719,7 +720,7 @@ class TestSpitch:
|
|
|
719
720
|
with pytest.raises(APIStatusError):
|
|
720
721
|
self.client.post(
|
|
721
722
|
"/v1/speech",
|
|
722
|
-
body=cast(object, dict(language="yo", text="text")),
|
|
723
|
+
body=cast(object, dict(language="yo", text="text", voice="sade")),
|
|
723
724
|
cast_to=httpx.Response,
|
|
724
725
|
options={"headers": {RAW_RESPONSE_HEADER: "stream"}},
|
|
725
726
|
)
|
|
@@ -743,7 +744,7 @@ class TestSpitch:
|
|
|
743
744
|
|
|
744
745
|
respx_mock.post("/v1/speech").mock(side_effect=retry_handler)
|
|
745
746
|
|
|
746
|
-
response = client.speech.with_raw_response.generate(language="yo", text="text")
|
|
747
|
+
response = client.speech.with_raw_response.generate(language="yo", text="text", voice="sade")
|
|
747
748
|
|
|
748
749
|
assert response.retries_taken == failures_before_success
|
|
749
750
|
assert int(response.http_request.headers.get("x-stainless-retry-count")) == failures_before_success
|
|
@@ -768,7 +769,7 @@ class TestSpitch:
|
|
|
768
769
|
respx_mock.post("/v1/speech").mock(side_effect=retry_handler)
|
|
769
770
|
|
|
770
771
|
response = client.speech.with_raw_response.generate(
|
|
771
|
-
language="yo", text="text", extra_headers={"x-stainless-retry-count": Omit()}
|
|
772
|
+
language="yo", text="text", voice="sade", extra_headers={"x-stainless-retry-count": Omit()}
|
|
772
773
|
)
|
|
773
774
|
|
|
774
775
|
assert len(response.http_request.headers.get_list("x-stainless-retry-count")) == 0
|
|
@@ -793,7 +794,7 @@ class TestSpitch:
|
|
|
793
794
|
respx_mock.post("/v1/speech").mock(side_effect=retry_handler)
|
|
794
795
|
|
|
795
796
|
response = client.speech.with_raw_response.generate(
|
|
796
|
-
language="yo", text="text", extra_headers={"x-stainless-retry-count": "42"}
|
|
797
|
+
language="yo", text="text", voice="sade", extra_headers={"x-stainless-retry-count": "42"}
|
|
797
798
|
)
|
|
798
799
|
|
|
799
800
|
assert response.http_request.headers.get("x-stainless-retry-count") == "42"
|
|
@@ -1454,6 +1455,7 @@ class TestAsyncSpitch:
|
|
|
1454
1455
|
[3, "", 0.5],
|
|
1455
1456
|
[2, "", 0.5 * 2.0],
|
|
1456
1457
|
[1, "", 0.5 * 4.0],
|
|
1458
|
+
[-1100, "", 7.8], # test large number potentially overflowing
|
|
1457
1459
|
],
|
|
1458
1460
|
)
|
|
1459
1461
|
@mock.patch("time.time", mock.MagicMock(return_value=1696004797))
|
|
@@ -1474,7 +1476,7 @@ class TestAsyncSpitch:
|
|
|
1474
1476
|
with pytest.raises(APITimeoutError):
|
|
1475
1477
|
await self.client.post(
|
|
1476
1478
|
"/v1/speech",
|
|
1477
|
-
body=cast(object, dict(language="yo", text="text")),
|
|
1479
|
+
body=cast(object, dict(language="yo", text="text", voice="sade")),
|
|
1478
1480
|
cast_to=httpx.Response,
|
|
1479
1481
|
options={"headers": {RAW_RESPONSE_HEADER: "stream"}},
|
|
1480
1482
|
)
|
|
@@ -1489,7 +1491,7 @@ class TestAsyncSpitch:
|
|
|
1489
1491
|
with pytest.raises(APIStatusError):
|
|
1490
1492
|
await self.client.post(
|
|
1491
1493
|
"/v1/speech",
|
|
1492
|
-
body=cast(object, dict(language="yo", text="text")),
|
|
1494
|
+
body=cast(object, dict(language="yo", text="text", voice="sade")),
|
|
1493
1495
|
cast_to=httpx.Response,
|
|
1494
1496
|
options={"headers": {RAW_RESPONSE_HEADER: "stream"}},
|
|
1495
1497
|
)
|
|
@@ -1516,7 +1518,7 @@ class TestAsyncSpitch:
|
|
|
1516
1518
|
|
|
1517
1519
|
respx_mock.post("/v1/speech").mock(side_effect=retry_handler)
|
|
1518
1520
|
|
|
1519
|
-
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", voice="sade")
|
|
1520
1522
|
|
|
1521
1523
|
assert response.retries_taken == failures_before_success
|
|
1522
1524
|
assert int(response.http_request.headers.get("x-stainless-retry-count")) == failures_before_success
|
|
@@ -1542,7 +1544,7 @@ class TestAsyncSpitch:
|
|
|
1542
1544
|
respx_mock.post("/v1/speech").mock(side_effect=retry_handler)
|
|
1543
1545
|
|
|
1544
1546
|
response = await client.speech.with_raw_response.generate(
|
|
1545
|
-
language="yo", text="text", extra_headers={"x-stainless-retry-count": Omit()}
|
|
1547
|
+
language="yo", text="text", voice="sade", extra_headers={"x-stainless-retry-count": Omit()}
|
|
1546
1548
|
)
|
|
1547
1549
|
|
|
1548
1550
|
assert len(response.http_request.headers.get_list("x-stainless-retry-count")) == 0
|
|
@@ -1568,7 +1570,7 @@ class TestAsyncSpitch:
|
|
|
1568
1570
|
respx_mock.post("/v1/speech").mock(side_effect=retry_handler)
|
|
1569
1571
|
|
|
1570
1572
|
response = await client.speech.with_raw_response.generate(
|
|
1571
|
-
language="yo", text="text", extra_headers={"x-stainless-retry-count": "42"}
|
|
1573
|
+
language="yo", text="text", voice="sade", extra_headers={"x-stainless-retry-count": "42"}
|
|
1572
1574
|
)
|
|
1573
1575
|
|
|
1574
1576
|
assert response.http_request.headers.get("x-stainless-retry-count") == "42"
|
|
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
|
|
File without changes
|