speechify-api 1.2.2__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 (117) hide show
  1. {speechify_api-1.2.2 → speechify_api-1.2.4}/PKG-INFO +88 -26
  2. {speechify_api-1.2.2 → speechify_api-1.2.4}/README.md +77 -22
  3. speechify_api-1.2.4/pyproject.toml +108 -0
  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.2/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.2 → 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.2 → speechify_api-1.2.4}/src/speechify/core/serialization.py +80 -5
  31. {speechify_api-1.2.2 → speechify_api-1.2.4}/src/speechify/environment.py +1 -1
  32. speechify_api-1.2.4/src/speechify/errors/__init__.py +65 -0
  33. speechify_api-1.2.4/src/speechify/errors/bad_gateway_error.py +11 -0
  34. speechify_api-1.2.4/src/speechify/errors/bad_request_error.py +10 -0
  35. speechify_api-1.2.4/src/speechify/errors/forbidden_error.py +11 -0
  36. speechify_api-1.2.4/src/speechify/errors/internal_server_error.py +11 -0
  37. speechify_api-1.2.4/src/speechify/errors/not_found_error.py +10 -0
  38. speechify_api-1.2.4/src/speechify/errors/payment_required_error.py +11 -0
  39. speechify_api-1.2.4/src/speechify/errors/service_unavailable_error.py +11 -0
  40. speechify_api-1.2.4/src/speechify/errors/too_many_requests_error.py +11 -0
  41. speechify_api-1.2.4/src/speechify/errors/unauthorized_error.py +10 -0
  42. speechify_api-1.2.4/src/speechify/errors/unprocessable_entity_error.py +11 -0
  43. speechify_api-1.2.4/src/speechify/types/__init__.py +98 -0
  44. {speechify_api-1.2.2/src/speechify/tts → speechify_api-1.2.4/src/speechify}/types/create_voice_language.py +2 -2
  45. {speechify_api-1.2.2/src/speechify/tts → speechify_api-1.2.4/src/speechify}/types/create_voice_model.py +3 -3
  46. speechify_api-1.2.4/src/speechify/types/create_voice_model_name.py +5 -0
  47. {speechify_api-1.2.2/src/speechify/tts → speechify_api-1.2.4/src/speechify}/types/created_voice.py +4 -4
  48. speechify_api-1.2.4/src/speechify/types/error.py +38 -0
  49. speechify_api-1.2.4/src/speechify/types/error_code.py +49 -0
  50. speechify_api-1.2.4/src/speechify/types/error_detail.py +37 -0
  51. {speechify_api-1.2.2/src/speechify/tts → speechify_api-1.2.4/src/speechify}/types/get_speech_options_request.py +2 -2
  52. {speechify_api-1.2.2/src/speechify/tts → speechify_api-1.2.4/src/speechify}/types/get_speech_response.py +3 -3
  53. {speechify_api-1.2.2/src/speechify/tts → speechify_api-1.2.4/src/speechify}/types/get_stream_options_request.py +2 -2
  54. {speechify_api-1.2.2/src/speechify/tts → speechify_api-1.2.4/src/speechify}/types/get_voice.py +4 -4
  55. {speechify_api-1.2.2/src/speechify/tts → speechify_api-1.2.4/src/speechify}/types/get_voice_language.py +2 -2
  56. {speechify_api-1.2.2/src/speechify/tts → speechify_api-1.2.4/src/speechify}/types/get_voices_model.py +3 -3
  57. speechify_api-1.2.4/src/speechify/types/get_voices_model_name.py +5 -0
  58. {speechify_api-1.2.2/src/speechify/tts → speechify_api-1.2.4/src/speechify}/types/nested_chunk.py +2 -2
  59. {speechify_api-1.2.2/src/speechify/tts → speechify_api-1.2.4/src/speechify}/types/speech_marks.py +3 -3
  60. speechify_api-1.2.4/src/speechify/voices/__init__.py +34 -0
  61. speechify_api-1.2.4/src/speechify/voices/client.py +399 -0
  62. speechify_api-1.2.4/src/speechify/voices/raw_client.py +1093 -0
  63. speechify_api-1.2.4/src/speechify/voices/types/__init__.py +34 -0
  64. speechify_api-1.2.2/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
  65. speechify_api-1.2.2/pyproject.toml +0 -75
  66. speechify_api-1.2.2/src/speechify/__init__.py +0 -17
  67. speechify_api-1.2.2/src/speechify/api/__init__.py +0 -5
  68. speechify_api-1.2.2/src/speechify/api/types/__init__.py +0 -5
  69. speechify_api-1.2.2/src/speechify/api/types/audio_stream_request_accept.py +0 -5
  70. speechify_api-1.2.2/src/speechify/client.py +0 -150
  71. speechify_api-1.2.2/src/speechify/core/__init__.py +0 -47
  72. speechify_api-1.2.2/src/speechify/core/api_error.py +0 -15
  73. speechify_api-1.2.2/src/speechify/core/client_wrapper.py +0 -76
  74. speechify_api-1.2.2/src/speechify/core/datetime_utils.py +0 -28
  75. speechify_api-1.2.2/src/speechify/core/http_client.py +0 -499
  76. speechify_api-1.2.2/src/speechify/core/pydantic_utilities.py +0 -296
  77. speechify_api-1.2.2/src/speechify/tts/__init__.py +0 -80
  78. speechify_api-1.2.2/src/speechify/tts/audio/__init__.py +0 -5
  79. speechify_api-1.2.2/src/speechify/tts/audio/client.py +0 -569
  80. speechify_api-1.2.2/src/speechify/tts/audio/types/__init__.py +0 -8
  81. speechify_api-1.2.2/src/speechify/tts/audio/types/get_speech_request_model.py +0 -7
  82. speechify_api-1.2.2/src/speechify/tts/audio/types/get_stream_request_model.py +0 -7
  83. speechify_api-1.2.2/src/speechify/tts/auth/__init__.py +0 -5
  84. speechify_api-1.2.2/src/speechify/tts/auth/client.py +0 -192
  85. speechify_api-1.2.2/src/speechify/tts/auth/types/__init__.py +0 -5
  86. speechify_api-1.2.2/src/speechify/tts/auth/types/create_access_token_request_scope.py +0 -10
  87. speechify_api-1.2.2/src/speechify/tts/client.py +0 -26
  88. speechify_api-1.2.2/src/speechify/tts/errors/__init__.py +0 -17
  89. speechify_api-1.2.2/src/speechify/tts/errors/bad_request_error.py +0 -9
  90. speechify_api-1.2.2/src/speechify/tts/errors/forbidden_error.py +0 -9
  91. speechify_api-1.2.2/src/speechify/tts/errors/internal_server_error.py +0 -9
  92. speechify_api-1.2.2/src/speechify/tts/errors/not_found_error.py +0 -9
  93. speechify_api-1.2.2/src/speechify/tts/errors/payment_required_error.py +0 -9
  94. speechify_api-1.2.2/src/speechify/tts/errors/unauthorized_error.py +0 -9
  95. speechify_api-1.2.2/src/speechify/tts/types/__init__.py +0 -51
  96. speechify_api-1.2.2/src/speechify/tts/types/access_token.py +0 -34
  97. speechify_api-1.2.2/src/speechify/tts/types/access_token_scope.py +0 -10
  98. speechify_api-1.2.2/src/speechify/tts/types/api_key.py +0 -47
  99. speechify_api-1.2.2/src/speechify/tts/types/create_voice_model_name.py +0 -7
  100. speechify_api-1.2.2/src/speechify/tts/types/get_voices_model_name.py +0 -7
  101. speechify_api-1.2.2/src/speechify/tts/types/o_auth_error.py +0 -21
  102. speechify_api-1.2.2/src/speechify/tts/types/o_auth_error_error.py +0 -10
  103. speechify_api-1.2.2/src/speechify/tts/voices/__init__.py +0 -5
  104. speechify_api-1.2.2/src/speechify/tts/voices/client.py +0 -772
  105. speechify_api-1.2.2/src/speechify/tts/voices/types/__init__.py +0 -5
  106. {speechify_api-1.2.2/src/speechify/tts → speechify_api-1.2.4/src/speechify}/audio/types/get_speech_request_audio_format.py +0 -0
  107. {speechify_api-1.2.2 → speechify_api-1.2.4}/src/speechify/core/file.py +0 -0
  108. {speechify_api-1.2.2 → speechify_api-1.2.4}/src/speechify/core/query_encoder.py +0 -0
  109. {speechify_api-1.2.2 → speechify_api-1.2.4}/src/speechify/core/remove_none_from_dict.py +0 -0
  110. {speechify_api-1.2.2 → speechify_api-1.2.4}/src/speechify/core/request_options.py +0 -0
  111. {speechify_api-1.2.2 → speechify_api-1.2.4}/src/speechify/py.typed +0 -0
  112. {speechify_api-1.2.2/src/speechify/tts → speechify_api-1.2.4/src/speechify}/types/created_voice_gender.py +0 -0
  113. {speechify_api-1.2.2/src/speechify/tts → speechify_api-1.2.4/src/speechify}/types/created_voice_type.py +0 -0
  114. {speechify_api-1.2.2/src/speechify/tts → speechify_api-1.2.4/src/speechify}/types/get_speech_response_audio_format.py +0 -0
  115. {speechify_api-1.2.2/src/speechify/tts → speechify_api-1.2.4/src/speechify}/types/get_voice_gender.py +0 -0
  116. {speechify_api-1.2.2/src/speechify/tts → speechify_api-1.2.4/src/speechify}/types/get_voice_type.py +0 -0
  117. {speechify_api-1.2.2 → 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.2
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
@@ -34,9 +41,25 @@ Description-Content-Type: text/markdown
34
41
 
35
42
  The Speechifyinc Python library provides convenient access to the Speechifyinc APIs from Python.
36
43
 
44
+ ## Table of Contents
45
+
46
+ - [Documentation](#documentation)
47
+ - [Installation](#installation)
48
+ - [Reference](#reference)
49
+ - [Usage](#usage)
50
+ - [Environments](#environments)
51
+ - [Async Client](#async-client)
52
+ - [Exception Handling](#exception-handling)
53
+ - [Advanced](#advanced)
54
+ - [Access Raw Response Data](#access-raw-response-data)
55
+ - [Retries](#retries)
56
+ - [Timeouts](#timeouts)
57
+ - [Custom Client](#custom-client)
58
+ - [Contributing](#contributing)
59
+
37
60
  ## Documentation
38
61
 
39
- API reference documentation is available [here](https://docs.sws.speechify.com/api-reference).
62
+ API reference documentation is available [here](https://docs.speechify.ai/api-reference).
40
63
 
41
64
  ## Installation
42
65
 
@@ -56,17 +79,33 @@ Instantiate and use the client with the following:
56
79
  from speechify import Speechify
57
80
 
58
81
  client = Speechify(
59
- token="YOUR_TOKEN",
82
+ api_key="<token>",
83
+ )
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",
60
90
  )
61
- client.tts.audio.speech(
62
- input="input",
63
- voice_id="voice_id",
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,
64
103
  )
65
104
  ```
66
105
 
67
106
  ## Async Client
68
107
 
69
- 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).
70
109
 
71
110
  ```python
72
111
  import asyncio
@@ -74,14 +113,16 @@ import asyncio
74
113
  from speechify import AsyncSpeechify
75
114
 
76
115
  client = AsyncSpeechify(
77
- token="YOUR_TOKEN",
116
+ api_key="<token>",
78
117
  )
79
118
 
80
119
 
81
120
  async def main() -> None:
82
- await client.tts.audio.speech(
83
- input="input",
84
- 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",
85
126
  )
86
127
 
87
128
 
@@ -97,7 +138,7 @@ will be thrown.
97
138
  from speechify.core.api_error import ApiError
98
139
 
99
140
  try:
100
- client.tts.audio.speech(...)
141
+ client.audio.speech(...)
101
142
  except ApiError as e:
102
143
  print(e.status_code)
103
144
  print(e.body)
@@ -105,22 +146,47 @@ except ApiError as e:
105
146
 
106
147
  ## Advanced
107
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
+
108
164
  ### Retries
109
165
 
110
166
  The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
111
167
  as the request is deemed retryable and the number of retry attempts has not grown larger than the configured
112
168
  retry limit (default: 2).
113
169
 
114
- 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)
115
177
 
178
+ **`recommended`**: retries on
116
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)
117
181
  - [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
118
- - [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)
119
185
 
120
186
  Use the `max_retries` request option to configure this behavior.
121
187
 
122
188
  ```python
123
- client.tts.audio.speech(..., request_options={
189
+ client.audio.speech(..., request_options={
124
190
  "max_retries": 1
125
191
  })
126
192
  ```
@@ -130,17 +196,12 @@ client.tts.audio.speech(..., request_options={
130
196
  The SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level.
131
197
 
132
198
  ```python
133
-
134
199
  from speechify import Speechify
135
200
 
136
- client = Speechify(
137
- ...,
138
- timeout=20.0,
139
- )
140
-
201
+ client = Speechify(..., timeout=20.0)
141
202
 
142
203
  # Override timeout for a specific method
143
- client.tts.audio.speech(..., request_options={
204
+ client.audio.speech(..., request_options={
144
205
  "timeout_in_seconds": 1
145
206
  })
146
207
  ```
@@ -149,6 +210,7 @@ client.tts.audio.speech(..., request_options={
149
210
 
150
211
  You can override the `httpx` client to customize it for your use-case. Some common use-cases include support for proxies
151
212
  and transports.
213
+
152
214
  ```python
153
215
  import httpx
154
216
  from speechify import Speechify
@@ -156,7 +218,7 @@ from speechify import Speechify
156
218
  client = Speechify(
157
219
  ...,
158
220
  httpx_client=httpx.Client(
159
- proxies="http://my.test.proxy.example.com",
221
+ proxy="http://my.test.proxy.example.com",
160
222
  transport=httpx.HTTPTransport(local_address="0.0.0.0"),
161
223
  ),
162
224
  )
@@ -5,9 +5,25 @@
5
5
 
6
6
  The Speechifyinc Python library provides convenient access to the Speechifyinc APIs from Python.
7
7
 
8
+ ## Table of Contents
9
+
10
+ - [Documentation](#documentation)
11
+ - [Installation](#installation)
12
+ - [Reference](#reference)
13
+ - [Usage](#usage)
14
+ - [Environments](#environments)
15
+ - [Async Client](#async-client)
16
+ - [Exception Handling](#exception-handling)
17
+ - [Advanced](#advanced)
18
+ - [Access Raw Response Data](#access-raw-response-data)
19
+ - [Retries](#retries)
20
+ - [Timeouts](#timeouts)
21
+ - [Custom Client](#custom-client)
22
+ - [Contributing](#contributing)
23
+
8
24
  ## Documentation
9
25
 
10
- API reference documentation is available [here](https://docs.sws.speechify.com/api-reference).
26
+ API reference documentation is available [here](https://docs.speechify.ai/api-reference).
11
27
 
12
28
  ## Installation
13
29
 
@@ -27,17 +43,33 @@ Instantiate and use the client with the following:
27
43
  from speechify import Speechify
28
44
 
29
45
  client = Speechify(
30
- token="YOUR_TOKEN",
46
+ api_key="<token>",
47
+ )
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",
31
54
  )
32
- client.tts.audio.speech(
33
- input="input",
34
- voice_id="voice_id",
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,
35
67
  )
36
68
  ```
37
69
 
38
70
  ## Async Client
39
71
 
40
- 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).
41
73
 
42
74
  ```python
43
75
  import asyncio
@@ -45,14 +77,16 @@ import asyncio
45
77
  from speechify import AsyncSpeechify
46
78
 
47
79
  client = AsyncSpeechify(
48
- token="YOUR_TOKEN",
80
+ api_key="<token>",
49
81
  )
50
82
 
51
83
 
52
84
  async def main() -> None:
53
- await client.tts.audio.speech(
54
- input="input",
55
- 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",
56
90
  )
57
91
 
58
92
 
@@ -68,7 +102,7 @@ will be thrown.
68
102
  from speechify.core.api_error import ApiError
69
103
 
70
104
  try:
71
- client.tts.audio.speech(...)
105
+ client.audio.speech(...)
72
106
  except ApiError as e:
73
107
  print(e.status_code)
74
108
  print(e.body)
@@ -76,22 +110,47 @@ except ApiError as e:
76
110
 
77
111
  ## Advanced
78
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
+
79
128
  ### Retries
80
129
 
81
130
  The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
82
131
  as the request is deemed retryable and the number of retry attempts has not grown larger than the configured
83
132
  retry limit (default: 2).
84
133
 
85
- 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)
86
141
 
142
+ **`recommended`**: retries on
87
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)
88
145
  - [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
89
- - [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)
90
149
 
91
150
  Use the `max_retries` request option to configure this behavior.
92
151
 
93
152
  ```python
94
- client.tts.audio.speech(..., request_options={
153
+ client.audio.speech(..., request_options={
95
154
  "max_retries": 1
96
155
  })
97
156
  ```
@@ -101,17 +160,12 @@ client.tts.audio.speech(..., request_options={
101
160
  The SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level.
102
161
 
103
162
  ```python
104
-
105
163
  from speechify import Speechify
106
164
 
107
- client = Speechify(
108
- ...,
109
- timeout=20.0,
110
- )
111
-
165
+ client = Speechify(..., timeout=20.0)
112
166
 
113
167
  # Override timeout for a specific method
114
- client.tts.audio.speech(..., request_options={
168
+ client.audio.speech(..., request_options={
115
169
  "timeout_in_seconds": 1
116
170
  })
117
171
  ```
@@ -120,6 +174,7 @@ client.tts.audio.speech(..., request_options={
120
174
 
121
175
  You can override the `httpx` client to customize it for your use-case. Some common use-cases include support for proxies
122
176
  and transports.
177
+
123
178
  ```python
124
179
  import httpx
125
180
  from speechify import Speechify
@@ -127,7 +182,7 @@ from speechify import Speechify
127
182
  client = Speechify(
128
183
  ...,
129
184
  httpx_client=httpx.Client(
130
- proxies="http://my.test.proxy.example.com",
185
+ proxy="http://my.test.proxy.example.com",
131
186
  transport=httpx.HTTPTransport(local_address="0.0.0.0"),
132
187
  ),
133
188
  )
@@ -0,0 +1,108 @@
1
+ [project]
2
+ name = "speechify-api"
3
+ dynamic = ["version"]
4
+
5
+ [tool.poetry]
6
+ name = "speechify-api"
7
+ version = "1.2.4"
8
+ description = "Official Speechify API SDK"
9
+ readme = "README.md"
10
+ authors = [
11
+ "Speechify <support@speechify.com>"
12
+ ]
13
+ keywords = [
14
+ "speechify",
15
+ "ai",
16
+ "api",
17
+ "sdk",
18
+ "text-to-speech",
19
+ "tts"
20
+ ]
21
+
22
+ classifiers = [
23
+ "Intended Audience :: Developers",
24
+ "Programming Language :: Python",
25
+ "Programming Language :: Python :: 3",
26
+ "Programming Language :: Python :: 3.10",
27
+ "Programming Language :: Python :: 3.11",
28
+ "Programming Language :: Python :: 3.12",
29
+ "Programming Language :: Python :: 3.13",
30
+ "Programming Language :: Python :: 3.14",
31
+ "Programming Language :: Python :: 3.15",
32
+ "Operating System :: OS Independent",
33
+ "Operating System :: POSIX",
34
+ "Operating System :: MacOS",
35
+ "Operating System :: POSIX :: Linux",
36
+ "Operating System :: Microsoft :: Windows",
37
+ "Topic :: Software Development :: Libraries :: Python Modules",
38
+ "Typing :: Typed"
39
+ ]
40
+ packages = [
41
+ { include = "speechify", from = "src"}
42
+ ]
43
+
44
+ [tool.poetry.urls]
45
+ Documentation = 'https://docs.speechify.ai/api-reference'
46
+ Homepage = 'https://docs.speechify.ai'
47
+ Repository = 'https://github.com/speechifyinc/speechify-api-sdk-python'
48
+
49
+ [tool.poetry.dependencies]
50
+ python = "^3.10"
51
+ aiohttp = { version = ">=3.14.1,<4", optional = true, python = ">=3.10"}
52
+ httpx = ">=0.21.2"
53
+ httpx-aiohttp = { version = "0.1.8", optional = true, python = ">=3.10"}
54
+ pydantic = ">= 1.9.2"
55
+ pydantic-core = ">=2.18.2,<3.0.0"
56
+ typing_extensions = ">= 4.0.0"
57
+
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"
63
+ python-dateutil = "^2.9.0"
64
+ types-python-dateutil = "^2.9.0.20240316"
65
+ urllib3 = ">=2.6.3,<3.0.0"
66
+ ruff = "==0.11.5"
67
+
68
+ [tool.pytest.ini_options]
69
+ testpaths = [ "tests" ]
70
+ asyncio_mode = "auto"
71
+ norecursedirs = [ "src" ]
72
+ markers = [
73
+ "aiohttp: tests that require httpx_aiohttp to be installed",
74
+ ]
75
+
76
+ [tool.mypy]
77
+ plugins = ["pydantic.mypy"]
78
+
79
+ [tool.ruff]
80
+ line-length = 120
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"]
102
+
103
+ [build-system]
104
+ requires = ["poetry-core"]
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
+ ]