Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .fern/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"cliVersion": "5.50.3",
"generatorName": "fernapi/fern-python-sdk",
"generatorVersion": "5.14.20",
"generatorConfig": {
"package_name": "speechify",
"client": {
"class_name": "Speechify"
},
"pyproject_python_version": ">=3.9"
},
"originGitCommit": "13f26db544c7ebda83d5d229fb387a34c8410ee0",
"originGitCommitIsDirty": true,
"invokedBy": "manual",
"sdkVersion": "1.2.4"
}
6 changes: 3 additions & 3 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Set up python
uses: actions/setup-python@v5
with:
python-version: "3.8"
python-version: "3.10"
- name: Bootstrap poetry
run: |
curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1
Expand All @@ -35,7 +35,7 @@ jobs:
- name: Set up python
uses: actions/setup-python@v5
with:
python-version: "3.8"
python-version: "3.10"
- name: Bootstrap poetry
run: |
curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1
Expand Down Expand Up @@ -73,7 +73,7 @@ jobs:
- name: Set up python
uses: actions/setup-python@v5
with:
python-version: "3.8"
python-version: "3.10"
- name: Bootstrap poetry
run: |
curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
dist/
.mypy_cache/
.ruff_cache/
__pycache__/
dist/
poetry.toml
.ruff_cache/
125 changes: 125 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# Contributing

Thanks for your interest in contributing to this SDK! This document provides guidelines for contributing to the project.

## Getting Started

### Prerequisites

- Python 3.9+
- pip
- poetry

### Installation

Install the project dependencies:

```bash
poetry install
```

### Building

Build the project:

```bash
poetry build
```

### Testing

Run the test suite:

```bash
poetry run pytest
```

### Linting and Formatting

Check code style:

```bash
poetry run ruff check .
poetry run ruff format .
```

### Type Checking

Run the type checker:

```bash
poetry run mypy .
```

## About Generated Code

**Important**: Most files in this SDK are automatically generated by [Fern](https://buildwithfern.com) from the API definition. Direct modifications to generated files will be overwritten the next time the SDK is generated.

### Generated Files

The following directories contain generated code:
- `src/` - API client classes and types
- Most Python files in the project

### How to Customize

If you need to customize the SDK, you have two options:

#### Option 1: Use `.fernignore`

For custom code that should persist across SDK regenerations:

1. Create a `.fernignore` file in the project root
2. Add file patterns for files you want to preserve (similar to `.gitignore` syntax)
3. Add your custom code to those files

Files listed in `.fernignore` will not be overwritten when the SDK is regenerated.

For more information, see the [Fern documentation on custom code](https://buildwithfern.com/learn/sdks/overview/custom-code).

#### Option 2: Contribute to the Generator

If you want to change how code is generated for all users of this SDK:

1. The Python SDK generator lives in the [Fern repository](https://github.com/fern-api/fern)
2. Generator code is located at `generators/python-v2/`
3. Follow the [Fern contributing guidelines](https://github.com/fern-api/fern/blob/main/CONTRIBUTING.md)
4. Submit a pull request with your changes to the generator

This approach is best for:
- Bug fixes in generated code
- New features that would benefit all users
- Improvements to code generation patterns

## Making Changes

### Workflow

1. Create a new branch for your changes
2. Make your modifications
3. Run tests to ensure nothing breaks: `poetry run pytest`
4. Run linting and formatting: `poetry run ruff check .` and `poetry run ruff format .`
5. Run type checking: `poetry run mypy .`
6. Build the project: `poetry build`
7. Commit your changes with a clear commit message
8. Push your branch and create a pull request

### Commit Messages

Write clear, descriptive commit messages that explain what changed and why.

### Code Style

This project uses automated code formatting and linting. Run `poetry run ruff format .` and `poetry run ruff check .` before committing to ensure your code meets the project's style guidelines.

## Questions or Issues?

If you have questions or run into issues:

1. Check the [Fern documentation](https://buildwithfern.com)
2. Search existing [GitHub issues](https://github.com/fern-api/fern/issues)
3. Open a new issue if your question hasn't been addressed

## License

By contributing to this project, you agree that your contributions will be licensed under the same license as the project.
83 changes: 62 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ The Speechifyinc Python library provides convenient access to the Speechifyinc A
- [Installation](#installation)
- [Reference](#reference)
- [Usage](#usage)
- [Environments](#environments)
- [Async Client](#async-client)
- [Exception Handling](#exception-handling)
- [Advanced](#advanced)
- [Access Raw Response Data](#access-raw-response-data)
- [Retries](#retries)
- [Timeouts](#timeouts)
- [Custom Client](#custom-client)
Expand Down Expand Up @@ -41,32 +43,50 @@ Instantiate and use the client with the following:
from speechify import Speechify

client = Speechify(
token="YOUR_TOKEN",
api_key="<token>",
)
client.tts.audio.speech(
input="input",
voice_id="voice_id",

client.audio.speech(
audio_format="mp3",
input="Hello! This is the Speechify text-to-speech API.",
model="simba-english",
voice_id="george",
)
```

## Environments

This SDK allows you to configure different environments for API requests.

```python
from speechify import Speechify
from speechify.environment import SpeechifyEnvironment

client = Speechify(
environment=SpeechifyEnvironment.DEFAULT,
)
```

## Async Client

The SDK also exports an `async` client so that you can make non-blocking calls to our API.
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).

```python
import asyncio

from speechify import AsyncSpeechify

client = AsyncSpeechify(
token="YOUR_TOKEN",
api_key="<token>",
)


async def main() -> None:
await client.tts.audio.speech(
input="input",
voice_id="voice_id",
await client.audio.speech(
audio_format="mp3",
input="Hello! This is the Speechify text-to-speech API.",
model="simba-english",
voice_id="george",
)


Expand All @@ -82,30 +102,55 @@ will be thrown.
from speechify.core.api_error import ApiError

try:
client.tts.audio.speech(...)
client.audio.speech(...)
except ApiError as e:
print(e.status_code)
print(e.body)
```

## Advanced

### Access Raw Response Data

The SDK provides access to raw response data, including headers, through the `.with_raw_response` property.
The `.with_raw_response` property returns a "raw" client that can be used to access the `.headers` and `.data` attributes.

```python
from speechify import Speechify

client = Speechify(...)
response = client.audio.with_raw_response.speech(...)
print(response.headers) # access the response headers
print(response.status_code) # access the response status code
print(response.data) # access the underlying object
```

### Retries

The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
as the request is deemed retryable and the number of retry attempts has not grown larger than the configured
retry limit (default: 2).

A request is deemed retryable when any of the following HTTP status codes is returned:
Which status codes are retried depends on the `retryStatusCodes` generator configuration:

**`legacy`** (current default): retries on
- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
- [409](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409) (Conflict)
- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#server_error_responses) (All server errors, including 500)

**`recommended`**: retries on
- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
- [409](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409) (Conflict)
- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors)
- [502](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502) (Bad Gateway)
- [503](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/503) (Service Unavailable)
- [504](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/504) (Gateway Timeout)

Use the `max_retries` request option to configure this behavior.

```python
client.tts.audio.speech(..., request_options={
client.audio.speech(..., request_options={
"max_retries": 1
})
```
Expand All @@ -115,17 +160,12 @@ client.tts.audio.speech(..., request_options={
The SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level.

```python

from speechify import Speechify

client = Speechify(
...,
timeout=20.0,
)

client = Speechify(..., timeout=20.0)

# Override timeout for a specific method
client.tts.audio.speech(..., request_options={
client.audio.speech(..., request_options={
"timeout_in_seconds": 1
})
```
Expand All @@ -134,14 +174,15 @@ client.tts.audio.speech(..., request_options={

You can override the `httpx` client to customize it for your use-case. Some common use-cases include support for proxies
and transports.

```python
import httpx
from speechify import Speechify

client = Speechify(
...,
httpx_client=httpx.Client(
proxies="http://my.test.proxy.example.com",
proxy="http://my.test.proxy.example.com",
transport=httpx.HTTPTransport(local_address="0.0.0.0"),
),
)
Expand Down
4 changes: 0 additions & 4 deletions context7.json

This file was deleted.

Loading
Loading