speechify-api 1.2.3__tar.gz → 1.2.4__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.
Files changed (116) hide show
  1. {speechify_api-1.2.3 → speechify_api-1.2.4}/PKG-INFO +73 -25
  2. {speechify_api-1.2.3 → speechify_api-1.2.4}/README.md +62 -21
  3. {speechify_api-1.2.3 → speechify_api-1.2.4}/pyproject.toml +44 -11
  4. speechify_api-1.2.4/src/speechify/__init__.py +170 -0
  5. speechify_api-1.2.4/src/speechify/_default_clients.py +32 -0
  6. speechify_api-1.2.4/src/speechify/audio/__init__.py +44 -0
  7. speechify_api-1.2.4/src/speechify/audio/client.py +358 -0
  8. speechify_api-1.2.4/src/speechify/audio/raw_client.py +801 -0
  9. speechify_api-1.2.4/src/speechify/audio/types/__init__.py +42 -0
  10. speechify_api-1.2.4/src/speechify/audio/types/get_speech_request_model.py +5 -0
  11. speechify_api-1.2.4/src/speechify/audio/types/get_stream_request_model.py +5 -0
  12. speechify_api-1.2.3/src/speechify/tts/audio/types/audio_stream_request_accept.py → speechify_api-1.2.4/src/speechify/audio/types/stream_audio_request_accept.py +1 -1
  13. speechify_api-1.2.4/src/speechify/client.py +246 -0
  14. speechify_api-1.2.4/src/speechify/core/__init__.py +127 -0
  15. speechify_api-1.2.4/src/speechify/core/api_error.py +23 -0
  16. speechify_api-1.2.4/src/speechify/core/client_wrapper.py +129 -0
  17. speechify_api-1.2.4/src/speechify/core/datetime_utils.py +70 -0
  18. speechify_api-1.2.4/src/speechify/core/force_multipart.py +18 -0
  19. speechify_api-1.2.4/src/speechify/core/http_client.py +839 -0
  20. speechify_api-1.2.4/src/speechify/core/http_response.py +59 -0
  21. speechify_api-1.2.4/src/speechify/core/http_sse/__init__.py +42 -0
  22. speechify_api-1.2.4/src/speechify/core/http_sse/_api.py +170 -0
  23. speechify_api-1.2.4/src/speechify/core/http_sse/_decoders.py +61 -0
  24. speechify_api-1.2.4/src/speechify/core/http_sse/_exceptions.py +7 -0
  25. speechify_api-1.2.4/src/speechify/core/http_sse/_models.py +17 -0
  26. {speechify_api-1.2.3 → speechify_api-1.2.4}/src/speechify/core/jsonable_encoder.py +20 -1
  27. speechify_api-1.2.4/src/speechify/core/logging.py +107 -0
  28. speechify_api-1.2.4/src/speechify/core/parse_error.py +36 -0
  29. speechify_api-1.2.4/src/speechify/core/pydantic_utilities.py +508 -0
  30. {speechify_api-1.2.3 → speechify_api-1.2.4}/src/speechify/core/serialization.py +80 -5
  31. speechify_api-1.2.4/src/speechify/errors/__init__.py +65 -0
  32. speechify_api-1.2.4/src/speechify/errors/bad_gateway_error.py +11 -0
  33. speechify_api-1.2.4/src/speechify/errors/bad_request_error.py +10 -0
  34. speechify_api-1.2.4/src/speechify/errors/forbidden_error.py +11 -0
  35. speechify_api-1.2.4/src/speechify/errors/internal_server_error.py +11 -0
  36. speechify_api-1.2.4/src/speechify/errors/not_found_error.py +10 -0
  37. speechify_api-1.2.4/src/speechify/errors/payment_required_error.py +11 -0
  38. speechify_api-1.2.4/src/speechify/errors/service_unavailable_error.py +11 -0
  39. speechify_api-1.2.4/src/speechify/errors/too_many_requests_error.py +11 -0
  40. speechify_api-1.2.4/src/speechify/errors/unauthorized_error.py +10 -0
  41. speechify_api-1.2.4/src/speechify/errors/unprocessable_entity_error.py +11 -0
  42. speechify_api-1.2.4/src/speechify/types/__init__.py +98 -0
  43. {speechify_api-1.2.3/src/speechify/tts → speechify_api-1.2.4/src/speechify}/types/create_voice_language.py +2 -2
  44. {speechify_api-1.2.3/src/speechify/tts → speechify_api-1.2.4/src/speechify}/types/create_voice_model.py +3 -3
  45. speechify_api-1.2.4/src/speechify/types/create_voice_model_name.py +5 -0
  46. {speechify_api-1.2.3/src/speechify/tts → speechify_api-1.2.4/src/speechify}/types/created_voice.py +4 -4
  47. speechify_api-1.2.4/src/speechify/types/error.py +38 -0
  48. speechify_api-1.2.4/src/speechify/types/error_code.py +49 -0
  49. speechify_api-1.2.4/src/speechify/types/error_detail.py +37 -0
  50. {speechify_api-1.2.3/src/speechify/tts → speechify_api-1.2.4/src/speechify}/types/get_speech_options_request.py +2 -2
  51. {speechify_api-1.2.3/src/speechify/tts → speechify_api-1.2.4/src/speechify}/types/get_speech_response.py +3 -3
  52. {speechify_api-1.2.3/src/speechify/tts → speechify_api-1.2.4/src/speechify}/types/get_stream_options_request.py +2 -2
  53. {speechify_api-1.2.3/src/speechify/tts → speechify_api-1.2.4/src/speechify}/types/get_voice.py +4 -4
  54. {speechify_api-1.2.3/src/speechify/tts → speechify_api-1.2.4/src/speechify}/types/get_voice_language.py +2 -2
  55. {speechify_api-1.2.3/src/speechify/tts → speechify_api-1.2.4/src/speechify}/types/get_voices_model.py +3 -3
  56. speechify_api-1.2.4/src/speechify/types/get_voices_model_name.py +5 -0
  57. {speechify_api-1.2.3/src/speechify/tts → speechify_api-1.2.4/src/speechify}/types/nested_chunk.py +2 -2
  58. {speechify_api-1.2.3/src/speechify/tts → speechify_api-1.2.4/src/speechify}/types/speech_marks.py +3 -3
  59. speechify_api-1.2.4/src/speechify/voices/__init__.py +34 -0
  60. speechify_api-1.2.4/src/speechify/voices/client.py +399 -0
  61. speechify_api-1.2.4/src/speechify/voices/raw_client.py +1093 -0
  62. speechify_api-1.2.4/src/speechify/voices/types/__init__.py +34 -0
  63. speechify_api-1.2.3/src/speechify/tts/voices/types/voices_create_request_gender.py → speechify_api-1.2.4/src/speechify/voices/types/create_voices_request_gender.py +1 -1
  64. speechify_api-1.2.3/src/speechify/__init__.py +0 -17
  65. speechify_api-1.2.3/src/speechify/api/__init__.py +0 -5
  66. speechify_api-1.2.3/src/speechify/api/types/__init__.py +0 -5
  67. speechify_api-1.2.3/src/speechify/api/types/audio_stream_request_accept.py +0 -5
  68. speechify_api-1.2.3/src/speechify/client.py +0 -150
  69. speechify_api-1.2.3/src/speechify/core/__init__.py +0 -47
  70. speechify_api-1.2.3/src/speechify/core/api_error.py +0 -15
  71. speechify_api-1.2.3/src/speechify/core/client_wrapper.py +0 -76
  72. speechify_api-1.2.3/src/speechify/core/datetime_utils.py +0 -28
  73. speechify_api-1.2.3/src/speechify/core/http_client.py +0 -499
  74. speechify_api-1.2.3/src/speechify/core/pydantic_utilities.py +0 -296
  75. speechify_api-1.2.3/src/speechify/tts/__init__.py +0 -80
  76. speechify_api-1.2.3/src/speechify/tts/audio/__init__.py +0 -5
  77. speechify_api-1.2.3/src/speechify/tts/audio/client.py +0 -569
  78. speechify_api-1.2.3/src/speechify/tts/audio/types/__init__.py +0 -8
  79. speechify_api-1.2.3/src/speechify/tts/audio/types/get_speech_request_model.py +0 -7
  80. speechify_api-1.2.3/src/speechify/tts/audio/types/get_stream_request_model.py +0 -7
  81. speechify_api-1.2.3/src/speechify/tts/auth/__init__.py +0 -5
  82. speechify_api-1.2.3/src/speechify/tts/auth/client.py +0 -192
  83. speechify_api-1.2.3/src/speechify/tts/auth/types/__init__.py +0 -5
  84. speechify_api-1.2.3/src/speechify/tts/auth/types/create_access_token_request_scope.py +0 -10
  85. speechify_api-1.2.3/src/speechify/tts/client.py +0 -26
  86. speechify_api-1.2.3/src/speechify/tts/errors/__init__.py +0 -17
  87. speechify_api-1.2.3/src/speechify/tts/errors/bad_request_error.py +0 -9
  88. speechify_api-1.2.3/src/speechify/tts/errors/forbidden_error.py +0 -9
  89. speechify_api-1.2.3/src/speechify/tts/errors/internal_server_error.py +0 -9
  90. speechify_api-1.2.3/src/speechify/tts/errors/not_found_error.py +0 -9
  91. speechify_api-1.2.3/src/speechify/tts/errors/payment_required_error.py +0 -9
  92. speechify_api-1.2.3/src/speechify/tts/errors/unauthorized_error.py +0 -9
  93. speechify_api-1.2.3/src/speechify/tts/types/__init__.py +0 -51
  94. speechify_api-1.2.3/src/speechify/tts/types/access_token.py +0 -34
  95. speechify_api-1.2.3/src/speechify/tts/types/access_token_scope.py +0 -10
  96. speechify_api-1.2.3/src/speechify/tts/types/api_key.py +0 -47
  97. speechify_api-1.2.3/src/speechify/tts/types/create_voice_model_name.py +0 -7
  98. speechify_api-1.2.3/src/speechify/tts/types/get_voices_model_name.py +0 -7
  99. speechify_api-1.2.3/src/speechify/tts/types/o_auth_error.py +0 -21
  100. speechify_api-1.2.3/src/speechify/tts/types/o_auth_error_error.py +0 -10
  101. speechify_api-1.2.3/src/speechify/tts/voices/__init__.py +0 -5
  102. speechify_api-1.2.3/src/speechify/tts/voices/client.py +0 -772
  103. speechify_api-1.2.3/src/speechify/tts/voices/types/__init__.py +0 -5
  104. {speechify_api-1.2.3/src/speechify/tts → speechify_api-1.2.4/src/speechify}/audio/types/get_speech_request_audio_format.py +0 -0
  105. {speechify_api-1.2.3 → speechify_api-1.2.4}/src/speechify/core/file.py +0 -0
  106. {speechify_api-1.2.3 → speechify_api-1.2.4}/src/speechify/core/query_encoder.py +0 -0
  107. {speechify_api-1.2.3 → speechify_api-1.2.4}/src/speechify/core/remove_none_from_dict.py +0 -0
  108. {speechify_api-1.2.3 → speechify_api-1.2.4}/src/speechify/core/request_options.py +0 -0
  109. {speechify_api-1.2.3 → speechify_api-1.2.4}/src/speechify/environment.py +0 -0
  110. {speechify_api-1.2.3 → speechify_api-1.2.4}/src/speechify/py.typed +0 -0
  111. {speechify_api-1.2.3/src/speechify/tts → speechify_api-1.2.4/src/speechify}/types/created_voice_gender.py +0 -0
  112. {speechify_api-1.2.3/src/speechify/tts → speechify_api-1.2.4/src/speechify}/types/created_voice_type.py +0 -0
  113. {speechify_api-1.2.3/src/speechify/tts → speechify_api-1.2.4/src/speechify}/types/get_speech_response_audio_format.py +0 -0
  114. {speechify_api-1.2.3/src/speechify/tts → speechify_api-1.2.4/src/speechify}/types/get_voice_gender.py +0 -0
  115. {speechify_api-1.2.3/src/speechify/tts → speechify_api-1.2.4/src/speechify}/types/get_voice_type.py +0 -0
  116. {speechify_api-1.2.3 → speechify_api-1.2.4}/src/speechify/version.py +0 -0
@@ -1,11 +1,11 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: speechify-api
3
- Version: 1.2.3
3
+ Version: 1.2.4
4
4
  Summary: Official Speechify API SDK
5
5
  Keywords: speechify,ai,api,sdk,text-to-speech,tts
6
6
  Author: Speechify
7
7
  Author-email: support@speechify.com
8
- Requires-Python: >=3.8,<4.0
8
+ Requires-Python: >=3.10,<4.0
9
9
  Classifier: Intended Audience :: Developers
10
10
  Classifier: Operating System :: MacOS
11
11
  Classifier: Operating System :: Microsoft :: Windows
@@ -14,17 +14,24 @@ Classifier: Operating System :: POSIX
14
14
  Classifier: Operating System :: POSIX :: Linux
15
15
  Classifier: Programming Language :: Python
16
16
  Classifier: Programming Language :: Python :: 3
17
- Classifier: Programming Language :: Python :: 3.8
18
- Classifier: Programming Language :: Python :: 3.9
19
17
  Classifier: Programming Language :: Python :: 3.10
20
18
  Classifier: Programming Language :: Python :: 3.11
21
19
  Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Programming Language :: Python :: 3.14
22
+ Classifier: Programming Language :: Python :: 3.15
22
23
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
24
  Classifier: Typing :: Typed
25
+ Provides-Extra: aiohttp
26
+ Requires-Dist: aiohttp (>=3.14.1,<4) ; (python_version >= "3.10") and (extra == "aiohttp")
24
27
  Requires-Dist: httpx (>=0.21.2)
28
+ Requires-Dist: httpx-aiohttp (==0.1.8) ; (python_version >= "3.10") and (extra == "aiohttp")
25
29
  Requires-Dist: pydantic (>=1.9.2)
26
30
  Requires-Dist: pydantic-core (>=2.18.2,<3.0.0)
27
31
  Requires-Dist: typing_extensions (>=4.0.0)
32
+ Project-URL: Documentation, https://docs.speechify.ai/api-reference
33
+ Project-URL: Homepage, https://docs.speechify.ai
34
+ Project-URL: Repository, https://github.com/speechifyinc/speechify-api-sdk-python
28
35
  Description-Content-Type: text/markdown
29
36
 
30
37
  # Speechifyinc Python Library
@@ -40,9 +47,11 @@ The Speechifyinc Python library provides convenient access to the Speechifyinc A
40
47
  - [Installation](#installation)
41
48
  - [Reference](#reference)
42
49
  - [Usage](#usage)
50
+ - [Environments](#environments)
43
51
  - [Async Client](#async-client)
44
52
  - [Exception Handling](#exception-handling)
45
53
  - [Advanced](#advanced)
54
+ - [Access Raw Response Data](#access-raw-response-data)
46
55
  - [Retries](#retries)
47
56
  - [Timeouts](#timeouts)
48
57
  - [Custom Client](#custom-client)
@@ -70,17 +79,33 @@ Instantiate and use the client with the following:
70
79
  from speechify import Speechify
71
80
 
72
81
  client = Speechify(
73
- token="YOUR_TOKEN",
82
+ api_key="<token>",
74
83
  )
75
- client.tts.audio.speech(
76
- input="input",
77
- voice_id="voice_id",
84
+
85
+ client.audio.speech(
86
+ audio_format="mp3",
87
+ input="Hello! This is the Speechify text-to-speech API.",
88
+ model="simba-english",
89
+ voice_id="george",
90
+ )
91
+ ```
92
+
93
+ ## Environments
94
+
95
+ This SDK allows you to configure different environments for API requests.
96
+
97
+ ```python
98
+ from speechify import Speechify
99
+ from speechify.environment import SpeechifyEnvironment
100
+
101
+ client = Speechify(
102
+ environment=SpeechifyEnvironment.DEFAULT,
78
103
  )
79
104
  ```
80
105
 
81
106
  ## Async Client
82
107
 
83
- The SDK also exports an `async` client so that you can make non-blocking calls to our API.
108
+ The SDK also exports an `async` client so that you can make non-blocking calls to our API. Note that if you are constructing an Async httpx client class to pass into this client, use `httpx.AsyncClient()` instead of `httpx.Client()` (e.g. for the `httpx_client` parameter of this client).
84
109
 
85
110
  ```python
86
111
  import asyncio
@@ -88,14 +113,16 @@ import asyncio
88
113
  from speechify import AsyncSpeechify
89
114
 
90
115
  client = AsyncSpeechify(
91
- token="YOUR_TOKEN",
116
+ api_key="<token>",
92
117
  )
93
118
 
94
119
 
95
120
  async def main() -> None:
96
- await client.tts.audio.speech(
97
- input="input",
98
- voice_id="voice_id",
121
+ await client.audio.speech(
122
+ audio_format="mp3",
123
+ input="Hello! This is the Speechify text-to-speech API.",
124
+ model="simba-english",
125
+ voice_id="george",
99
126
  )
100
127
 
101
128
 
@@ -111,7 +138,7 @@ will be thrown.
111
138
  from speechify.core.api_error import ApiError
112
139
 
113
140
  try:
114
- client.tts.audio.speech(...)
141
+ client.audio.speech(...)
115
142
  except ApiError as e:
116
143
  print(e.status_code)
117
144
  print(e.body)
@@ -119,22 +146,47 @@ except ApiError as e:
119
146
 
120
147
  ## Advanced
121
148
 
149
+ ### Access Raw Response Data
150
+
151
+ The SDK provides access to raw response data, including headers, through the `.with_raw_response` property.
152
+ The `.with_raw_response` property returns a "raw" client that can be used to access the `.headers` and `.data` attributes.
153
+
154
+ ```python
155
+ from speechify import Speechify
156
+
157
+ client = Speechify(...)
158
+ response = client.audio.with_raw_response.speech(...)
159
+ print(response.headers) # access the response headers
160
+ print(response.status_code) # access the response status code
161
+ print(response.data) # access the underlying object
162
+ ```
163
+
122
164
  ### Retries
123
165
 
124
166
  The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
125
167
  as the request is deemed retryable and the number of retry attempts has not grown larger than the configured
126
168
  retry limit (default: 2).
127
169
 
128
- A request is deemed retryable when any of the following HTTP status codes is returned:
170
+ Which status codes are retried depends on the `retryStatusCodes` generator configuration:
171
+
172
+ **`legacy`** (current default): retries on
173
+ - [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
174
+ - [409](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409) (Conflict)
175
+ - [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
176
+ - [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#server_error_responses) (All server errors, including 500)
129
177
 
178
+ **`recommended`**: retries on
130
179
  - [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
180
+ - [409](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409) (Conflict)
131
181
  - [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
132
- - [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors)
182
+ - [502](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502) (Bad Gateway)
183
+ - [503](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/503) (Service Unavailable)
184
+ - [504](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/504) (Gateway Timeout)
133
185
 
134
186
  Use the `max_retries` request option to configure this behavior.
135
187
 
136
188
  ```python
137
- client.tts.audio.speech(..., request_options={
189
+ client.audio.speech(..., request_options={
138
190
  "max_retries": 1
139
191
  })
140
192
  ```
@@ -144,17 +196,12 @@ client.tts.audio.speech(..., request_options={
144
196
  The SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level.
145
197
 
146
198
  ```python
147
-
148
199
  from speechify import Speechify
149
200
 
150
- client = Speechify(
151
- ...,
152
- timeout=20.0,
153
- )
154
-
201
+ client = Speechify(..., timeout=20.0)
155
202
 
156
203
  # Override timeout for a specific method
157
- client.tts.audio.speech(..., request_options={
204
+ client.audio.speech(..., request_options={
158
205
  "timeout_in_seconds": 1
159
206
  })
160
207
  ```
@@ -163,6 +210,7 @@ client.tts.audio.speech(..., request_options={
163
210
 
164
211
  You can override the `httpx` client to customize it for your use-case. Some common use-cases include support for proxies
165
212
  and transports.
213
+
166
214
  ```python
167
215
  import httpx
168
216
  from speechify import Speechify
@@ -170,7 +218,7 @@ from speechify import Speechify
170
218
  client = Speechify(
171
219
  ...,
172
220
  httpx_client=httpx.Client(
173
- proxies="http://my.test.proxy.example.com",
221
+ proxy="http://my.test.proxy.example.com",
174
222
  transport=httpx.HTTPTransport(local_address="0.0.0.0"),
175
223
  ),
176
224
  )
@@ -11,9 +11,11 @@ The Speechifyinc Python library provides convenient access to the Speechifyinc A
11
11
  - [Installation](#installation)
12
12
  - [Reference](#reference)
13
13
  - [Usage](#usage)
14
+ - [Environments](#environments)
14
15
  - [Async Client](#async-client)
15
16
  - [Exception Handling](#exception-handling)
16
17
  - [Advanced](#advanced)
18
+ - [Access Raw Response Data](#access-raw-response-data)
17
19
  - [Retries](#retries)
18
20
  - [Timeouts](#timeouts)
19
21
  - [Custom Client](#custom-client)
@@ -41,17 +43,33 @@ Instantiate and use the client with the following:
41
43
  from speechify import Speechify
42
44
 
43
45
  client = Speechify(
44
- token="YOUR_TOKEN",
46
+ api_key="<token>",
45
47
  )
46
- client.tts.audio.speech(
47
- input="input",
48
- voice_id="voice_id",
48
+
49
+ client.audio.speech(
50
+ audio_format="mp3",
51
+ input="Hello! This is the Speechify text-to-speech API.",
52
+ model="simba-english",
53
+ voice_id="george",
54
+ )
55
+ ```
56
+
57
+ ## Environments
58
+
59
+ This SDK allows you to configure different environments for API requests.
60
+
61
+ ```python
62
+ from speechify import Speechify
63
+ from speechify.environment import SpeechifyEnvironment
64
+
65
+ client = Speechify(
66
+ environment=SpeechifyEnvironment.DEFAULT,
49
67
  )
50
68
  ```
51
69
 
52
70
  ## Async Client
53
71
 
54
- The SDK also exports an `async` client so that you can make non-blocking calls to our API.
72
+ The SDK also exports an `async` client so that you can make non-blocking calls to our API. Note that if you are constructing an Async httpx client class to pass into this client, use `httpx.AsyncClient()` instead of `httpx.Client()` (e.g. for the `httpx_client` parameter of this client).
55
73
 
56
74
  ```python
57
75
  import asyncio
@@ -59,14 +77,16 @@ import asyncio
59
77
  from speechify import AsyncSpeechify
60
78
 
61
79
  client = AsyncSpeechify(
62
- token="YOUR_TOKEN",
80
+ api_key="<token>",
63
81
  )
64
82
 
65
83
 
66
84
  async def main() -> None:
67
- await client.tts.audio.speech(
68
- input="input",
69
- voice_id="voice_id",
85
+ await client.audio.speech(
86
+ audio_format="mp3",
87
+ input="Hello! This is the Speechify text-to-speech API.",
88
+ model="simba-english",
89
+ voice_id="george",
70
90
  )
71
91
 
72
92
 
@@ -82,7 +102,7 @@ will be thrown.
82
102
  from speechify.core.api_error import ApiError
83
103
 
84
104
  try:
85
- client.tts.audio.speech(...)
105
+ client.audio.speech(...)
86
106
  except ApiError as e:
87
107
  print(e.status_code)
88
108
  print(e.body)
@@ -90,22 +110,47 @@ except ApiError as e:
90
110
 
91
111
  ## Advanced
92
112
 
113
+ ### Access Raw Response Data
114
+
115
+ The SDK provides access to raw response data, including headers, through the `.with_raw_response` property.
116
+ The `.with_raw_response` property returns a "raw" client that can be used to access the `.headers` and `.data` attributes.
117
+
118
+ ```python
119
+ from speechify import Speechify
120
+
121
+ client = Speechify(...)
122
+ response = client.audio.with_raw_response.speech(...)
123
+ print(response.headers) # access the response headers
124
+ print(response.status_code) # access the response status code
125
+ print(response.data) # access the underlying object
126
+ ```
127
+
93
128
  ### Retries
94
129
 
95
130
  The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
96
131
  as the request is deemed retryable and the number of retry attempts has not grown larger than the configured
97
132
  retry limit (default: 2).
98
133
 
99
- A request is deemed retryable when any of the following HTTP status codes is returned:
134
+ Which status codes are retried depends on the `retryStatusCodes` generator configuration:
135
+
136
+ **`legacy`** (current default): retries on
137
+ - [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
138
+ - [409](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409) (Conflict)
139
+ - [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
140
+ - [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#server_error_responses) (All server errors, including 500)
100
141
 
142
+ **`recommended`**: retries on
101
143
  - [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
144
+ - [409](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409) (Conflict)
102
145
  - [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
103
- - [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors)
146
+ - [502](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502) (Bad Gateway)
147
+ - [503](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/503) (Service Unavailable)
148
+ - [504](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/504) (Gateway Timeout)
104
149
 
105
150
  Use the `max_retries` request option to configure this behavior.
106
151
 
107
152
  ```python
108
- client.tts.audio.speech(..., request_options={
153
+ client.audio.speech(..., request_options={
109
154
  "max_retries": 1
110
155
  })
111
156
  ```
@@ -115,17 +160,12 @@ client.tts.audio.speech(..., request_options={
115
160
  The SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level.
116
161
 
117
162
  ```python
118
-
119
163
  from speechify import Speechify
120
164
 
121
- client = Speechify(
122
- ...,
123
- timeout=20.0,
124
- )
125
-
165
+ client = Speechify(..., timeout=20.0)
126
166
 
127
167
  # Override timeout for a specific method
128
- client.tts.audio.speech(..., request_options={
168
+ client.audio.speech(..., request_options={
129
169
  "timeout_in_seconds": 1
130
170
  })
131
171
  ```
@@ -134,6 +174,7 @@ client.tts.audio.speech(..., request_options={
134
174
 
135
175
  You can override the `httpx` client to customize it for your use-case. Some common use-cases include support for proxies
136
176
  and transports.
177
+
137
178
  ```python
138
179
  import httpx
139
180
  from speechify import Speechify
@@ -141,7 +182,7 @@ from speechify import Speechify
141
182
  client = Speechify(
142
183
  ...,
143
184
  httpx_client=httpx.Client(
144
- proxies="http://my.test.proxy.example.com",
185
+ proxy="http://my.test.proxy.example.com",
145
186
  transport=httpx.HTTPTransport(local_address="0.0.0.0"),
146
187
  ),
147
188
  )
@@ -1,9 +1,10 @@
1
1
  [project]
2
2
  name = "speechify-api"
3
+ dynamic = ["version"]
3
4
 
4
5
  [tool.poetry]
5
6
  name = "speechify-api"
6
- version = "1.2.3"
7
+ version = "1.2.4"
7
8
  description = "Official Speechify API SDK"
8
9
  readme = "README.md"
9
10
  authors = [
@@ -22,11 +23,12 @@ classifiers = [
22
23
  "Intended Audience :: Developers",
23
24
  "Programming Language :: Python",
24
25
  "Programming Language :: Python :: 3",
25
- "Programming Language :: Python :: 3.8",
26
- "Programming Language :: Python :: 3.9",
27
26
  "Programming Language :: Python :: 3.10",
28
27
  "Programming Language :: Python :: 3.11",
29
28
  "Programming Language :: Python :: 3.12",
29
+ "Programming Language :: Python :: 3.13",
30
+ "Programming Language :: Python :: 3.14",
31
+ "Programming Language :: Python :: 3.15",
30
32
  "Operating System :: OS Independent",
31
33
  "Operating System :: POSIX",
32
34
  "Operating System :: MacOS",
@@ -39,29 +41,37 @@ packages = [
39
41
  { include = "speechify", from = "src"}
40
42
  ]
41
43
 
42
- [project.urls]
44
+ [tool.poetry.urls]
43
45
  Documentation = 'https://docs.speechify.ai/api-reference'
44
46
  Homepage = 'https://docs.speechify.ai'
45
47
  Repository = 'https://github.com/speechifyinc/speechify-api-sdk-python'
46
48
 
47
49
  [tool.poetry.dependencies]
48
- python = "^3.8"
50
+ python = "^3.10"
51
+ aiohttp = { version = ">=3.14.1,<4", optional = true, python = ">=3.10"}
49
52
  httpx = ">=0.21.2"
53
+ httpx-aiohttp = { version = "0.1.8", optional = true, python = ">=3.10"}
50
54
  pydantic = ">= 1.9.2"
51
- pydantic-core = "^2.18.2"
55
+ pydantic-core = ">=2.18.2,<3.0.0"
52
56
  typing_extensions = ">= 4.0.0"
53
57
 
54
- [tool.poetry.dev-dependencies]
55
- mypy = "1.0.1"
56
- pytest = "^7.4.0"
57
- pytest-asyncio = "^0.23.5"
58
+ [tool.poetry.group.dev.dependencies]
59
+ mypy = "==1.13.0"
60
+ pytest = "^9.0.3"
61
+ pytest-asyncio = "^1.0.0"
62
+ pytest-xdist = "^3.6.1"
58
63
  python-dateutil = "^2.9.0"
59
64
  types-python-dateutil = "^2.9.0.20240316"
60
- ruff = "^0.5.6"
65
+ urllib3 = ">=2.6.3,<3.0.0"
66
+ ruff = "==0.11.5"
61
67
 
62
68
  [tool.pytest.ini_options]
63
69
  testpaths = [ "tests" ]
64
70
  asyncio_mode = "auto"
71
+ norecursedirs = [ "src" ]
72
+ markers = [
73
+ "aiohttp: tests that require httpx_aiohttp to be installed",
74
+ ]
65
75
 
66
76
  [tool.mypy]
67
77
  plugins = ["pydantic.mypy"]
@@ -69,7 +79,30 @@ plugins = ["pydantic.mypy"]
69
79
  [tool.ruff]
70
80
  line-length = 120
71
81
 
82
+ [tool.ruff.lint]
83
+ select = [
84
+ "E", # pycodestyle errors
85
+ "F", # pyflakes
86
+ "I", # isort
87
+ ]
88
+ ignore = [
89
+ "E402", # Module level import not at top of file
90
+ "E501", # Line too long
91
+ "E711", # Comparison to `None` should be `cond is not None`
92
+ "E712", # Avoid equality comparisons to `True`; use `if ...:` checks
93
+ "E721", # Use `is` and `is not` for type comparisons, or `isinstance()` for insinstance checks
94
+ "E722", # Do not use bare `except`
95
+ "E731", # Do not assign a `lambda` expression, use a `def`
96
+ "F821", # Undefined name
97
+ "F841" # Local variable ... is assigned to but never used
98
+ ]
99
+
100
+ [tool.ruff.lint.isort]
101
+ section-order = ["future", "standard-library", "third-party", "first-party"]
72
102
 
73
103
  [build-system]
74
104
  requires = ["poetry-core"]
75
105
  build-backend = "poetry.core.masonry.api"
106
+
107
+ [tool.poetry.extras]
108
+ aiohttp=["aiohttp", "httpx-aiohttp"]
@@ -0,0 +1,170 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ # isort: skip_file
4
+
5
+ import typing
6
+ from importlib import import_module
7
+
8
+ if typing.TYPE_CHECKING:
9
+ from .types import (
10
+ CreateVoiceLanguage,
11
+ CreateVoiceModel,
12
+ CreateVoiceModelName,
13
+ CreatedVoice,
14
+ CreatedVoiceGender,
15
+ CreatedVoiceType,
16
+ Error,
17
+ ErrorCode,
18
+ ErrorDetail,
19
+ GetSpeechOptionsRequest,
20
+ GetSpeechResponse,
21
+ GetSpeechResponseAudioFormat,
22
+ GetStreamOptionsRequest,
23
+ GetVoice,
24
+ GetVoiceGender,
25
+ GetVoiceLanguage,
26
+ GetVoiceType,
27
+ GetVoicesModel,
28
+ GetVoicesModelName,
29
+ NestedChunk,
30
+ SpeechMarks,
31
+ )
32
+ from .errors import (
33
+ BadGatewayError,
34
+ BadRequestError,
35
+ ForbiddenError,
36
+ InternalServerError,
37
+ NotFoundError,
38
+ PaymentRequiredError,
39
+ ServiceUnavailableError,
40
+ TooManyRequestsError,
41
+ UnauthorizedError,
42
+ UnprocessableEntityError,
43
+ )
44
+ from . import audio, voices
45
+ from ._default_clients import DefaultAioHttpClient, DefaultAsyncHttpxClient
46
+ from .audio import (
47
+ GetSpeechRequestAudioFormat,
48
+ GetSpeechRequestModel,
49
+ GetStreamRequestModel,
50
+ StreamAudioRequestAccept,
51
+ )
52
+ from .client import AsyncSpeechify, Speechify
53
+ from .environment import SpeechifyEnvironment
54
+ from .version import __version__
55
+ from .voices import CreateVoicesRequestGender
56
+ _dynamic_imports: typing.Dict[str, str] = {
57
+ "AsyncSpeechify": ".client",
58
+ "BadGatewayError": ".errors",
59
+ "BadRequestError": ".errors",
60
+ "CreateVoiceLanguage": ".types",
61
+ "CreateVoiceModel": ".types",
62
+ "CreateVoiceModelName": ".types",
63
+ "CreateVoicesRequestGender": ".voices",
64
+ "CreatedVoice": ".types",
65
+ "CreatedVoiceGender": ".types",
66
+ "CreatedVoiceType": ".types",
67
+ "DefaultAioHttpClient": "._default_clients",
68
+ "DefaultAsyncHttpxClient": "._default_clients",
69
+ "Error": ".types",
70
+ "ErrorCode": ".types",
71
+ "ErrorDetail": ".types",
72
+ "ForbiddenError": ".errors",
73
+ "GetSpeechOptionsRequest": ".types",
74
+ "GetSpeechRequestAudioFormat": ".audio",
75
+ "GetSpeechRequestModel": ".audio",
76
+ "GetSpeechResponse": ".types",
77
+ "GetSpeechResponseAudioFormat": ".types",
78
+ "GetStreamOptionsRequest": ".types",
79
+ "GetStreamRequestModel": ".audio",
80
+ "GetVoice": ".types",
81
+ "GetVoiceGender": ".types",
82
+ "GetVoiceLanguage": ".types",
83
+ "GetVoiceType": ".types",
84
+ "GetVoicesModel": ".types",
85
+ "GetVoicesModelName": ".types",
86
+ "InternalServerError": ".errors",
87
+ "NestedChunk": ".types",
88
+ "NotFoundError": ".errors",
89
+ "PaymentRequiredError": ".errors",
90
+ "ServiceUnavailableError": ".errors",
91
+ "SpeechMarks": ".types",
92
+ "Speechify": ".client",
93
+ "SpeechifyEnvironment": ".environment",
94
+ "StreamAudioRequestAccept": ".audio",
95
+ "TooManyRequestsError": ".errors",
96
+ "UnauthorizedError": ".errors",
97
+ "UnprocessableEntityError": ".errors",
98
+ "__version__": ".version",
99
+ "audio": ".audio",
100
+ "voices": ".voices",
101
+ }
102
+
103
+
104
+ def __getattr__(attr_name: str) -> typing.Any:
105
+ module_name = _dynamic_imports.get(attr_name)
106
+ if module_name is None:
107
+ raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}")
108
+ try:
109
+ module = import_module(module_name, __package__)
110
+ if module_name == f".{attr_name}":
111
+ return module
112
+ else:
113
+ return getattr(module, attr_name)
114
+ except ImportError as e:
115
+ raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e
116
+ except AttributeError as e:
117
+ raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e
118
+
119
+
120
+ def __dir__():
121
+ lazy_attrs = list(_dynamic_imports.keys())
122
+ return sorted(lazy_attrs)
123
+
124
+
125
+ __all__ = [
126
+ "AsyncSpeechify",
127
+ "BadGatewayError",
128
+ "BadRequestError",
129
+ "CreateVoiceLanguage",
130
+ "CreateVoiceModel",
131
+ "CreateVoiceModelName",
132
+ "CreateVoicesRequestGender",
133
+ "CreatedVoice",
134
+ "CreatedVoiceGender",
135
+ "CreatedVoiceType",
136
+ "DefaultAioHttpClient",
137
+ "DefaultAsyncHttpxClient",
138
+ "Error",
139
+ "ErrorCode",
140
+ "ErrorDetail",
141
+ "ForbiddenError",
142
+ "GetSpeechOptionsRequest",
143
+ "GetSpeechRequestAudioFormat",
144
+ "GetSpeechRequestModel",
145
+ "GetSpeechResponse",
146
+ "GetSpeechResponseAudioFormat",
147
+ "GetStreamOptionsRequest",
148
+ "GetStreamRequestModel",
149
+ "GetVoice",
150
+ "GetVoiceGender",
151
+ "GetVoiceLanguage",
152
+ "GetVoiceType",
153
+ "GetVoicesModel",
154
+ "GetVoicesModelName",
155
+ "InternalServerError",
156
+ "NestedChunk",
157
+ "NotFoundError",
158
+ "PaymentRequiredError",
159
+ "ServiceUnavailableError",
160
+ "SpeechMarks",
161
+ "Speechify",
162
+ "SpeechifyEnvironment",
163
+ "StreamAudioRequestAccept",
164
+ "TooManyRequestsError",
165
+ "UnauthorizedError",
166
+ "UnprocessableEntityError",
167
+ "__version__",
168
+ "audio",
169
+ "voices",
170
+ ]
@@ -0,0 +1,32 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ import httpx
6
+
7
+ SDK_DEFAULT_TIMEOUT = 60
8
+
9
+ try:
10
+ import httpx_aiohttp # type: ignore[import-not-found]
11
+ except ImportError:
12
+
13
+ class DefaultAioHttpClient(httpx.AsyncClient): # type: ignore
14
+ def __init__(self, **kwargs: typing.Any) -> None:
15
+ raise RuntimeError(
16
+ "To use the aiohttp client, install the aiohttp extra: pip install speechify-api[aiohttp]"
17
+ )
18
+
19
+ else:
20
+
21
+ class DefaultAioHttpClient(httpx_aiohttp.HttpxAiohttpClient): # type: ignore
22
+ def __init__(self, **kwargs: typing.Any) -> None:
23
+ kwargs.setdefault("timeout", SDK_DEFAULT_TIMEOUT)
24
+ kwargs.setdefault("follow_redirects", True)
25
+ super().__init__(**kwargs)
26
+
27
+
28
+ class DefaultAsyncHttpxClient(httpx.AsyncClient):
29
+ def __init__(self, **kwargs: typing.Any) -> None:
30
+ kwargs.setdefault("timeout", SDK_DEFAULT_TIMEOUT)
31
+ kwargs.setdefault("follow_redirects", True)
32
+ super().__init__(**kwargs)