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