From 8110b5cd3f4b3c411f664dd3f54257375d9c4bf2 Mon Sep 17 00:00:00 2001 From: "fern-api[bot]" <115122769+fern-api[bot]@users.noreply.github.com> Date: Sat, 14 Sep 2024 09:40:12 -0400 Subject: [PATCH] (chore): misc improvements such as ruff formatting, pydantic warnings and tests (#359) --- .gitignore | 1 + poetry.lock | 44 +- pyproject.toml | 6 +- reference.md | 147 ++--- src/elevenlabs/__init__.py | 3 + src/elevenlabs/audio_isolation/client.py | 66 +- src/elevenlabs/audio_native/client.py | 58 +- src/elevenlabs/base_client.py | 68 +- src/elevenlabs/chapters/client.py | 246 ++++++-- src/elevenlabs/core/__init__.py | 5 +- src/elevenlabs/core/client_wrapper.py | 11 +- src/elevenlabs/core/file.py | 9 +- src/elevenlabs/core/http_client.py | 6 +- src/elevenlabs/core/jsonable_encoder.py | 8 +- src/elevenlabs/core/pydantic_utilities.py | 139 ++-- src/elevenlabs/core/query_encoder.py | 45 +- src/elevenlabs/core/serialization.py | 170 +++++ src/elevenlabs/core/unchecked_base_model.py | 17 +- src/elevenlabs/dubbing/client.py | 226 +++++-- src/elevenlabs/history/client.py | 204 ++++-- src/elevenlabs/models/client.py | 54 +- src/elevenlabs/projects/client.py | 444 ++++++++++--- .../pronunciation_dictionary/client.py | 294 +++++++-- .../types/pronunciation_dictionary_rule.py | 12 +- src/elevenlabs/samples/client.py | 74 ++- src/elevenlabs/speech_to_speech/client.py | 96 ++- .../text_to_sound_effects/client.py | 46 +- src/elevenlabs/text_to_speech/client.py | 128 ++-- .../text_to_speech/types/send_message.py | 3 +- .../types/add_project_response_model.py | 8 +- ...pronunciation_dictionary_response_model.py | 6 +- ...ciation_dictionary_rules_response_model.py | 6 +- .../types/add_voice_response_model.py | 6 +- ...io_native_create_project_response_model.py | 6 +- ...io_native_get_embed_code_response_model.py | 2 +- src/elevenlabs/types/audio_output.py | 6 +- src/elevenlabs/types/chapter_response.py | 8 +- .../types/chapter_snapshot_response.py | 6 +- .../types/chapter_snapshots_response.py | 8 +- .../types/chapter_statistics_response.py | 6 +- src/elevenlabs/types/close_connection.py | 4 +- src/elevenlabs/types/do_dubbing_response.py | 6 +- .../types/dubbing_metadata_response.py | 6 +- .../types/edit_project_response_model.py | 8 +- src/elevenlabs/types/feedback_item.py | 6 +- src/elevenlabs/types/fine_tuning_response.py | 12 +- src/elevenlabs/types/generation_config.py | 4 +- src/elevenlabs/types/get_chapters_response.py | 8 +- .../types/get_library_voices_response.py | 8 +- src/elevenlabs/types/get_projects_response.py | 8 +- ...on_dictionaries_metadata_response_model.py | 8 +- ...nunciation_dictionary_metadata_response.py | 6 +- .../types/get_speech_history_response.py | 8 +- src/elevenlabs/types/get_voices_response.py | 8 +- src/elevenlabs/types/history.py | 2 +- .../types/history_alignment_response_model.py | 6 +- .../history_alignments_response_model.py | 8 +- src/elevenlabs/types/history_item.py | 10 +- src/elevenlabs/types/http_validation_error.py | 8 +- src/elevenlabs/types/initialize_connection.py | 8 +- src/elevenlabs/types/invoice.py | 6 +- src/elevenlabs/types/language_response.py | 6 +- .../types/library_voice_response.py | 6 +- .../manual_verification_file_response.py | 6 +- .../types/manual_verification_response.py | 8 +- src/elevenlabs/types/model.py | 8 +- src/elevenlabs/types/normalized_alignment.py | 4 +- .../types/profile_page_response_model.py | 6 +- .../types/project_extended_response_model.py | 10 +- src/elevenlabs/types/project_response.py | 8 +- .../types/project_snapshot_response.py | 8 +- .../project_snapshot_upload_response_model.py | 8 +- .../types/project_snapshots_response.py | 8 +- ...ion_dictionary_alias_rule_request_model.py | 6 +- ...n_dictionary_phoneme_rule_request_model.py | 6 +- ...ronunciation_dictionary_version_locator.py | 6 +- .../types/realtime_voice_settings.py | 6 +- src/elevenlabs/types/recording_response.py | 6 +- ...ciation_dictionary_rules_response_model.py | 6 +- src/elevenlabs/types/send_text.py | 4 +- .../types/speech_history_item_response.py | 16 +- .../types/sso_provider_response_model.py | 8 +- src/elevenlabs/types/subscription.py | 10 +- src/elevenlabs/types/subscription_response.py | 10 +- .../types/text_to_speech_as_stream_request.py | 2 +- .../types/usage_characters_response_model.py | 6 +- src/elevenlabs/types/user.py | 8 +- src/elevenlabs/types/validation_error.py | 8 +- .../types/verification_attempt_response.py | 8 +- src/elevenlabs/types/voice.py | 12 +- ...ce_generation_parameter_option_response.py | 6 +- .../voice_generation_parameter_response.py | 8 +- src/elevenlabs/types/voice_sample.py | 6 +- src/elevenlabs/types/voice_settings.py | 6 +- .../types/voice_sharing_response.py | 10 +- .../types/voice_verification_response.py | 8 +- src/elevenlabs/usage/client.py | 56 +- src/elevenlabs/user/client.py | 100 ++- src/elevenlabs/version.py | 1 - src/elevenlabs/voice_generation/client.py | 122 +++- src/elevenlabs/voices/client.py | 594 ++++++++++++++---- src/elevenlabs/workspace/client.py | 192 ++++-- 102 files changed, 3000 insertions(+), 1169 deletions(-) create mode 100644 src/elevenlabs/core/serialization.py diff --git a/.gitignore b/.gitignore index 42cb863..0da665f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ dist/ .mypy_cache/ __pycache__/ poetry.toml +.ruff_cache/ diff --git a/poetry.lock b/poetry.lock index 1c1a690..4fda0cd 100644 --- a/poetry.lock +++ b/poetry.lock @@ -230,15 +230,18 @@ zstd = ["zstandard (>=0.18.0)"] [[package]] name = "idna" -version = "3.8" +version = "3.9" description = "Internationalized Domain Names in Applications (IDNA)" optional = false python-versions = ">=3.6" files = [ - {file = "idna-3.8-py3-none-any.whl", hash = "sha256:050b4e5baadcd44d760cedbd2b8e639f2ff89bbc7a5730fcc662954303377aac"}, - {file = "idna-3.8.tar.gz", hash = "sha256:d838c2c0ed6fced7693d5e8ab8e734d5f8fda53a039c0164afb0b82e771e3603"}, + {file = "idna-3.9-py3-none-any.whl", hash = "sha256:69297d5da0cc9281c77efffb4e730254dd45943f45bbfb461de5991713989b1e"}, + {file = "idna-3.9.tar.gz", hash = "sha256:e5c5dafde284f26e9e0f28f6ea2d6400abd5ca099864a67f576f3981c6476124"}, ] +[package.extras] +all = ["flake8 (>=7.1.1)", "mypy (>=1.11.2)", "pytest (>=8.3.2)", "ruff (>=0.6.2)"] + [[package]] name = "iniconfig" version = "2.0.0" @@ -532,6 +535,33 @@ urllib3 = ">=1.21.1,<3" socks = ["PySocks (>=1.5.6,!=1.5.7)"] use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"] +[[package]] +name = "ruff" +version = "0.5.7" +description = "An extremely fast Python linter and code formatter, written in Rust." +optional = false +python-versions = ">=3.7" +files = [ + {file = "ruff-0.5.7-py3-none-linux_armv6l.whl", hash = "sha256:548992d342fc404ee2e15a242cdbea4f8e39a52f2e7752d0e4cbe88d2d2f416a"}, + {file = "ruff-0.5.7-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:00cc8872331055ee017c4f1071a8a31ca0809ccc0657da1d154a1d2abac5c0be"}, + {file = "ruff-0.5.7-py3-none-macosx_11_0_arm64.whl", hash = "sha256:eaf3d86a1fdac1aec8a3417a63587d93f906c678bb9ed0b796da7b59c1114a1e"}, + {file = "ruff-0.5.7-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a01c34400097b06cf8a6e61b35d6d456d5bd1ae6961542de18ec81eaf33b4cb8"}, + {file = "ruff-0.5.7-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:fcc8054f1a717e2213500edaddcf1dbb0abad40d98e1bd9d0ad364f75c763eea"}, + {file = "ruff-0.5.7-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7f70284e73f36558ef51602254451e50dd6cc479f8b6f8413a95fcb5db4a55fc"}, + {file = "ruff-0.5.7-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:a78ad870ae3c460394fc95437d43deb5c04b5c29297815a2a1de028903f19692"}, + {file = "ruff-0.5.7-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:9ccd078c66a8e419475174bfe60a69adb36ce04f8d4e91b006f1329d5cd44bcf"}, + {file = "ruff-0.5.7-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:7e31c9bad4ebf8fdb77b59cae75814440731060a09a0e0077d559a556453acbb"}, + {file = "ruff-0.5.7-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8d796327eed8e168164346b769dd9a27a70e0298d667b4ecee6877ce8095ec8e"}, + {file = "ruff-0.5.7-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:4a09ea2c3f7778cc635e7f6edf57d566a8ee8f485f3c4454db7771efb692c499"}, + {file = "ruff-0.5.7-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:a36d8dcf55b3a3bc353270d544fb170d75d2dff41eba5df57b4e0b67a95bb64e"}, + {file = "ruff-0.5.7-py3-none-musllinux_1_2_i686.whl", hash = "sha256:9369c218f789eefbd1b8d82a8cf25017b523ac47d96b2f531eba73770971c9e5"}, + {file = "ruff-0.5.7-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:b88ca3db7eb377eb24fb7c82840546fb7acef75af4a74bd36e9ceb37a890257e"}, + {file = "ruff-0.5.7-py3-none-win32.whl", hash = "sha256:33d61fc0e902198a3e55719f4be6b375b28f860b09c281e4bdbf783c0566576a"}, + {file = "ruff-0.5.7-py3-none-win_amd64.whl", hash = "sha256:083bbcbe6fadb93cd86709037acc510f86eed5a314203079df174c40bbbca6b3"}, + {file = "ruff-0.5.7-py3-none-win_arm64.whl", hash = "sha256:2dca26154ff9571995107221d0aeaad0e75a77b5a682d6236cf89a58c70b76f4"}, + {file = "ruff-0.5.7.tar.gz", hash = "sha256:8dfc0a458797f5d9fb622dd0efc52d796f23f0a1493a9527f4e49a550ae9a7e5"}, +] + [[package]] name = "six" version = "1.16.0" @@ -589,13 +619,13 @@ files = [ [[package]] name = "urllib3" -version = "2.2.2" +version = "2.2.3" description = "HTTP library with thread-safe connection pooling, file post, and more." optional = false python-versions = ">=3.8" files = [ - {file = "urllib3-2.2.2-py3-none-any.whl", hash = "sha256:a448b2f64d686155468037e1ace9f2d2199776e17f0a46610480d311f73e3472"}, - {file = "urllib3-2.2.2.tar.gz", hash = "sha256:dd505485549a7a552833da5e6063639d0d177c04f23bc3864e41e5dc5f612168"}, + {file = "urllib3-2.2.3-py3-none-any.whl", hash = "sha256:ca899ca043dcb1bafa3e262d73aa25c465bfb49e0bd9dd5d59f1d0acba2f8fac"}, + {file = "urllib3-2.2.3.tar.gz", hash = "sha256:e7d814a81dad81e6caf2ec9fdedb284ecc9c73076b62654547cc64ccdcae26e9"}, ] [package.extras] @@ -702,4 +732,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = "^3.8" -content-hash = "b52747053e83d1cb95b7a58f605f5ce3e8320833a2f11b9d1d9342c338712a8f" +content-hash = "a53420244251981fe047bbb97d6005fffb6b63447718cc640562750fffcc8c75" diff --git a/pyproject.toml b/pyproject.toml index 1868aa7..d9d6119 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "elevenlabs" -version = "1.8.0" +version = "1.8.1" description = "" readme = "README.md" authors = [] @@ -46,6 +46,7 @@ pytest = "^7.4.0" pytest-asyncio = "^0.23.5" python-dateutil = "^2.9.0" types-python-dateutil = "^2.9.0.20240316" +ruff = "^0.5.6" [tool.pytest.ini_options] testpaths = [ "tests" ] @@ -54,6 +55,9 @@ asyncio_mode = "auto" [tool.mypy] plugins = ["pydantic.mypy"] +[tool.ruff] +line-length = 120 + [build-system] requires = ["poetry-core"] diff --git a/reference.md b/reference.md index e215586..d5a0de0 100644 --- a/reference.md +++ b/reference.md @@ -27,7 +27,7 @@ Returns metadata about all your generated audio.
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -114,7 +114,7 @@ Returns information about an history item by its ID.
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -184,7 +184,7 @@ Delete a history item by its ID
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -254,7 +254,7 @@ Returns the audio of an history item.
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -324,7 +324,7 @@ Download one or more history items. If one history item ID is provided, we will
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -403,7 +403,7 @@ Converts a text of your choice into sound
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -492,7 +492,7 @@ Removes background noise from audio
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -562,7 +562,7 @@ Removes background noise from audio and streams the result
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -633,7 +633,7 @@ Removes a sample by its ID.
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -712,7 +712,7 @@ Returns the audio corresponding to a sample attached to a voice.
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -792,8 +792,7 @@ Converts text into speech using a voice of your choice and returns audio.
```python -from elevenlabs import VoiceSettings -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs, VoiceSettings client = ElevenLabs( api_key="YOUR_API_KEY", @@ -975,7 +974,7 @@ Converts text into speech using a voice of your choice and returns JSON containi
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -1150,8 +1149,7 @@ Converts text into speech using a voice of your choice and returns audio as an a
```python -from elevenlabs import VoiceSettings -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs, VoiceSettings client = ElevenLabs( api_key="YOUR_API_KEY", @@ -1333,7 +1331,7 @@ Converts text into speech using a voice of your choice and returns a stream of J
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -1509,7 +1507,7 @@ Create speech by combining the content and emotion of the uploaded audio with a
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -1640,7 +1638,7 @@ Create speech by combining the content and emotion of the uploaded audio with a
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -1785,7 +1783,7 @@ Get possible parameters for the /v1/voice-generation/generate-voice endpoint.
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -1845,7 +1843,7 @@ Generate a random voice based on parameters. This method returns a generated_voi
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -1951,7 +1949,7 @@ Create a previously generated voice. This endpoint should be called after you fe
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -2048,7 +2046,7 @@ Gets extended information about the users subscription
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -2108,7 +2106,7 @@ Gets information about the user
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -2169,7 +2167,7 @@ Gets a list of all available voices for a user.
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -2237,7 +2235,7 @@ Gets the default settings for voices. "similarity_boost" corresponds to"Clarity
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -2297,7 +2295,7 @@ Returns the settings for a specific voice. "similarity_boost" corresponds to"Cla
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -2367,7 +2365,7 @@ Returns metadata about a specific voice.
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -2445,7 +2443,7 @@ Deletes a voice by its ID.
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -2515,8 +2513,7 @@ Edit your settings for a specific voice. "similarity_boost" corresponds to"Clari
```python -from elevenlabs import VoiceSettings -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs, VoiceSettings client = ElevenLabs( api_key="YOUR_API_KEY", @@ -2599,7 +2596,7 @@ Add a new voice to your collection of voices in VoiceLab.
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -2695,7 +2692,7 @@ Edit a voice created by you.
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -2800,7 +2797,7 @@ Add a sharing voice to your collection of voices in VoiceLab.
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -2896,7 +2893,7 @@ Gets a list of shared voices.
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -3072,7 +3069,7 @@ Returns a list of shared voices similar to the provided audio sample. If neither
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -3158,7 +3155,7 @@ Gets a profile page based on a handle
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -3229,7 +3226,7 @@ Returns a list of your projects together and its metadata.
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -3289,7 +3286,7 @@ Creates a new project, it can be either initialized as blank, from a document or
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -3467,7 +3464,7 @@ Returns information about a specific project. This endpoint returns more detaile
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -3537,7 +3534,7 @@ Edits basic project info.
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -3666,7 +3663,7 @@ Delete a project by its project_id.
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -3736,7 +3733,7 @@ Starts conversion of a project and all of its chapters.
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -3806,7 +3803,7 @@ Gets the snapshots of a project.
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -3876,7 +3873,7 @@ Stream the audio from a project snapshot.
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -3964,7 +3961,7 @@ Streams archive with project audio.
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -4043,8 +4040,7 @@ Updates the set of pronunciation dictionaries acting on a project. This will aut
```python -from elevenlabs import PronunciationDictionaryVersionLocator -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs, PronunciationDictionaryVersionLocator client = ElevenLabs( api_key="YOUR_API_KEY", @@ -4129,7 +4125,7 @@ Returns a list of your chapters for a project together and its metadata.
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -4199,7 +4195,7 @@ Returns information about a specific chapter.
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -4278,7 +4274,7 @@ Delete a chapter by its chapter_id.
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -4357,7 +4353,7 @@ Starts conversion of a specific chapter.
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -4436,7 +4432,7 @@ Gets information about all the snapshots of a chapter, each snapshot corresponds
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -4515,7 +4511,7 @@ Stream the audio from a chapter snapshot. Use `GET /v1/projects/{project_id}/cha
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -4612,7 +4608,7 @@ Dubs provided audio or video file into given language.
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -4756,7 +4752,7 @@ Returns metadata about a dubbing project, including whether it's still in progre
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -4826,7 +4822,7 @@ Deletes a dubbing project.
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -4896,7 +4892,7 @@ Returns dubbed file as a streamed file. Videos will be returned in MP4 format an
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -4975,7 +4971,7 @@ Returns transcript for the dub as an SRT file.
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -5065,7 +5061,7 @@ Gets a list of available models.
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -5126,7 +5122,7 @@ Creates AudioNative enabled project, optionally starts conversion and returns pr
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -5287,7 +5283,7 @@ Returns the characters usage metrics for the current user or the entire workspac
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -5383,7 +5379,7 @@ Creates a new pronunciation dictionary from a lexicon .PLS file
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -5479,14 +5475,23 @@ Add rules to the pronunciation dictionary
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs +from elevenlabs.pronunciation_dictionary import ( + PronunciationDictionaryRule_Phoneme, +) client = ElevenLabs( api_key="YOUR_API_KEY", ) client.pronunciation_dictionary.add_rules_to_the_pronunciation_dictionary( pronunciation_dictionary_id="21m00Tcm4TlvDq8ikWAM", - rules=[], + rules=[ + PronunciationDictionaryRule_Phoneme( + string_to_replace="rules", + phoneme="rules", + alphabet="rules", + ) + ], ) ``` @@ -5562,7 +5567,7 @@ Remove rules from the pronunciation dictionary
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -5641,7 +5646,7 @@ Get PLS file with a pronunciation dictionary version rules
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -5720,7 +5725,7 @@ Get metadata for a pronunciation dictionary
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -5790,7 +5795,7 @@ Get a list of the pronunciation dictionaries you have access to and their metada
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -5869,7 +5874,7 @@ Sends an email invitation to join your workspace to the provided email. If the u
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -5939,7 +5944,7 @@ Invalidates an existing email invitation. The invitation will still show up in t
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -6009,7 +6014,7 @@ Updates attributes of a workspace member. Apart from the email identifier, all p
```python -from elevenlabs.client import ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", diff --git a/src/elevenlabs/__init__.py b/src/elevenlabs/__init__.py index 85dc445..8ca7e4e 100644 --- a/src/elevenlabs/__init__.py +++ b/src/elevenlabs/__init__.py @@ -112,6 +112,7 @@ voices, workspace, ) +from .client import AsyncElevenLabs, ElevenLabs from .dubbing import GetTranscriptForDubV1DubbingDubbingIdTranscriptLanguageCodeGetRequestFormatType from .environment import ElevenLabsEnvironment from .play import play, save, stream @@ -133,6 +134,7 @@ "AddPronunciationDictionaryRulesResponseModel", "AddVoiceResponseModel", "Age", + "AsyncElevenLabs", "AudioNativeCreateProjectResponseModel", "AudioNativeGetEmbedCodeResponseModel", "AudioOutput", @@ -148,6 +150,7 @@ "DoDubbingResponse", "DubbingMetadataResponse", "EditProjectResponseModel", + "ElevenLabs", "ElevenLabsEnvironment", "ExtendedSubscriptionResponseModelBillingPeriod", "ExtendedSubscriptionResponseModelCharacterRefreshPeriod", diff --git a/src/elevenlabs/audio_isolation/client.py b/src/elevenlabs/audio_isolation/client.py index d853c80..2e83110 100644 --- a/src/elevenlabs/audio_isolation/client.py +++ b/src/elevenlabs/audio_isolation/client.py @@ -1,15 +1,15 @@ # This file was auto-generated by Fern from our API Definition. import typing -from json.decoder import JSONDecodeError - +from ..core.client_wrapper import SyncClientWrapper from .. import core -from ..core.api_error import ApiError -from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.request_options import RequestOptions -from ..core.unchecked_base_model import construct_type from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.http_validation_error import HttpValidationError +from ..core.unchecked_base_model import construct_type +from json.decoder import JSONDecodeError +from ..core.api_error import ApiError +from ..core.client_wrapper import AsyncClientWrapper # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -40,7 +40,7 @@ def audio_isolation( Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -51,7 +51,9 @@ def audio_isolation( "v1/audio-isolation", method="POST", data={}, - files={"audio": audio}, + files={ + "audio": audio, + }, request_options=request_options, omit=OMIT, ) as _response: @@ -63,7 +65,13 @@ def audio_isolation( _response.read() if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -91,7 +99,7 @@ def audio_isolation_stream( Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -102,7 +110,9 @@ def audio_isolation_stream( "v1/audio-isolation/stream", method="POST", data={}, - files={"audio": audio}, + files={ + "audio": audio, + }, request_options=request_options, omit=OMIT, ) as _response: @@ -114,7 +124,13 @@ def audio_isolation_stream( _response.read() if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -149,7 +165,7 @@ async def audio_isolation( -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -166,7 +182,9 @@ async def main() -> None: "v1/audio-isolation", method="POST", data={}, - files={"audio": audio}, + files={ + "audio": audio, + }, request_options=request_options, omit=OMIT, ) as _response: @@ -178,7 +196,13 @@ async def main() -> None: await _response.aread() if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -208,7 +232,7 @@ async def audio_isolation_stream( -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -225,7 +249,9 @@ async def main() -> None: "v1/audio-isolation/stream", method="POST", data={}, - files={"audio": audio}, + files={ + "audio": audio, + }, request_options=request_options, omit=OMIT, ) as _response: @@ -237,7 +263,13 @@ async def main() -> None: await _response.aread() if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: diff --git a/src/elevenlabs/audio_native/client.py b/src/elevenlabs/audio_native/client.py index bfb9830..e0f7768 100644 --- a/src/elevenlabs/audio_native/client.py +++ b/src/elevenlabs/audio_native/client.py @@ -1,16 +1,16 @@ # This file was auto-generated by Fern from our API Definition. import typing -from json.decoder import JSONDecodeError - +from ..core.client_wrapper import SyncClientWrapper from .. import core -from ..core.api_error import ApiError -from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.request_options import RequestOptions +from ..types.audio_native_create_project_response_model import AudioNativeCreateProjectResponseModel from ..core.unchecked_base_model import construct_type from ..errors.unprocessable_entity_error import UnprocessableEntityError -from ..types.audio_native_create_project_response_model import AudioNativeCreateProjectResponseModel from ..types.http_validation_error import HttpValidationError +from json.decoder import JSONDecodeError +from ..core.api_error import ApiError +from ..core.client_wrapper import AsyncClientWrapper # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -35,7 +35,7 @@ def create( model_id: typing.Optional[str] = None, file: typing.Optional[core.File] = None, auto_convert: typing.Optional[bool] = None, - request_options: typing.Optional[RequestOptions] = None + request_options: typing.Optional[RequestOptions] = None, ) -> AudioNativeCreateProjectResponseModel: """ Creates AudioNative enabled project, optionally starts conversion and returns project id and embeddable html snippet. @@ -88,7 +88,7 @@ def create( Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -113,16 +113,30 @@ def create( "model_id": model_id, "auto_convert": auto_convert, }, - files={"file": file}, + files={ + "file": file, + }, request_options=request_options, omit=OMIT, ) try: if 200 <= _response.status_code < 300: - return typing.cast(AudioNativeCreateProjectResponseModel, construct_type(type_=AudioNativeCreateProjectResponseModel, object_=_response.json())) # type: ignore + return typing.cast( + AudioNativeCreateProjectResponseModel, + construct_type( + type_=AudioNativeCreateProjectResponseModel, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -149,7 +163,7 @@ async def create( model_id: typing.Optional[str] = None, file: typing.Optional[core.File] = None, auto_convert: typing.Optional[bool] = None, - request_options: typing.Optional[RequestOptions] = None + request_options: typing.Optional[RequestOptions] = None, ) -> AudioNativeCreateProjectResponseModel: """ Creates AudioNative enabled project, optionally starts conversion and returns project id and embeddable html snippet. @@ -204,7 +218,7 @@ async def create( -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -235,16 +249,30 @@ async def main() -> None: "model_id": model_id, "auto_convert": auto_convert, }, - files={"file": file}, + files={ + "file": file, + }, request_options=request_options, omit=OMIT, ) try: if 200 <= _response.status_code < 300: - return typing.cast(AudioNativeCreateProjectResponseModel, construct_type(type_=AudioNativeCreateProjectResponseModel, object_=_response.json())) # type: ignore + return typing.cast( + AudioNativeCreateProjectResponseModel, + construct_type( + type_=AudioNativeCreateProjectResponseModel, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: diff --git a/src/elevenlabs/base_client.py b/src/elevenlabs/base_client.py index f6185be..977ed58 100644 --- a/src/elevenlabs/base_client.py +++ b/src/elevenlabs/base_client.py @@ -1,29 +1,45 @@ # This file was auto-generated by Fern from our API Definition. -import os import typing - -import httpx - -from .audio_isolation.client import AsyncAudioIsolationClient, AudioIsolationClient -from .audio_native.client import AsyncAudioNativeClient, AudioNativeClient -from .chapters.client import AsyncChaptersClient, ChaptersClient -from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper -from .dubbing.client import AsyncDubbingClient, DubbingClient from .environment import ElevenLabsEnvironment -from .history.client import AsyncHistoryClient, HistoryClient -from .models.client import AsyncModelsClient, ModelsClient -from .projects.client import AsyncProjectsClient, ProjectsClient -from .pronunciation_dictionary.client import AsyncPronunciationDictionaryClient, PronunciationDictionaryClient -from .samples.client import AsyncSamplesClient, SamplesClient -from .speech_to_speech.client import AsyncSpeechToSpeechClient, SpeechToSpeechClient -from .text_to_sound_effects.client import AsyncTextToSoundEffectsClient, TextToSoundEffectsClient -from .text_to_speech.client import AsyncTextToSpeechClient, TextToSpeechClient -from .usage.client import AsyncUsageClient, UsageClient -from .user.client import AsyncUserClient, UserClient -from .voice_generation.client import AsyncVoiceGenerationClient, VoiceGenerationClient -from .voices.client import AsyncVoicesClient, VoicesClient -from .workspace.client import AsyncWorkspaceClient, WorkspaceClient +import os +import httpx +from .core.client_wrapper import SyncClientWrapper +from .history.client import HistoryClient +from .text_to_sound_effects.client import TextToSoundEffectsClient +from .audio_isolation.client import AudioIsolationClient +from .samples.client import SamplesClient +from .text_to_speech.client import TextToSpeechClient +from .speech_to_speech.client import SpeechToSpeechClient +from .voice_generation.client import VoiceGenerationClient +from .user.client import UserClient +from .voices.client import VoicesClient +from .projects.client import ProjectsClient +from .chapters.client import ChaptersClient +from .dubbing.client import DubbingClient +from .models.client import ModelsClient +from .audio_native.client import AudioNativeClient +from .usage.client import UsageClient +from .pronunciation_dictionary.client import PronunciationDictionaryClient +from .workspace.client import WorkspaceClient +from .core.client_wrapper import AsyncClientWrapper +from .history.client import AsyncHistoryClient +from .text_to_sound_effects.client import AsyncTextToSoundEffectsClient +from .audio_isolation.client import AsyncAudioIsolationClient +from .samples.client import AsyncSamplesClient +from .text_to_speech.client import AsyncTextToSpeechClient +from .speech_to_speech.client import AsyncSpeechToSpeechClient +from .voice_generation.client import AsyncVoiceGenerationClient +from .user.client import AsyncUserClient +from .voices.client import AsyncVoicesClient +from .projects.client import AsyncProjectsClient +from .chapters.client import AsyncChaptersClient +from .dubbing.client import AsyncDubbingClient +from .models.client import AsyncModelsClient +from .audio_native.client import AsyncAudioNativeClient +from .usage.client import AsyncUsageClient +from .pronunciation_dictionary.client import AsyncPronunciationDictionaryClient +from .workspace.client import AsyncWorkspaceClient class BaseElevenLabs: @@ -56,7 +72,7 @@ class BaseElevenLabs: Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -71,7 +87,7 @@ def __init__( api_key: typing.Optional[str] = os.getenv("ELEVEN_API_KEY"), timeout: typing.Optional[float] = None, follow_redirects: typing.Optional[bool] = True, - httpx_client: typing.Optional[httpx.Client] = None + httpx_client: typing.Optional[httpx.Client] = None, ): _defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None self._client_wrapper = SyncClientWrapper( @@ -133,7 +149,7 @@ class AsyncBaseElevenLabs: Examples -------- - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -148,7 +164,7 @@ def __init__( api_key: typing.Optional[str] = os.getenv("ELEVEN_API_KEY"), timeout: typing.Optional[float] = None, follow_redirects: typing.Optional[bool] = True, - httpx_client: typing.Optional[httpx.AsyncClient] = None + httpx_client: typing.Optional[httpx.AsyncClient] = None, ): _defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None self._client_wrapper = AsyncClientWrapper( diff --git a/src/elevenlabs/chapters/client.py b/src/elevenlabs/chapters/client.py index 486ef55..af4de41 100644 --- a/src/elevenlabs/chapters/client.py +++ b/src/elevenlabs/chapters/client.py @@ -1,18 +1,18 @@ # This file was auto-generated by Fern from our API Definition. import typing -from json.decoder import JSONDecodeError - -from ..core.api_error import ApiError -from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper -from ..core.jsonable_encoder import jsonable_encoder +from ..core.client_wrapper import SyncClientWrapper from ..core.request_options import RequestOptions +from ..types.get_chapters_response import GetChaptersResponse +from ..core.jsonable_encoder import jsonable_encoder from ..core.unchecked_base_model import construct_type from ..errors.unprocessable_entity_error import UnprocessableEntityError +from ..types.http_validation_error import HttpValidationError +from json.decoder import JSONDecodeError +from ..core.api_error import ApiError from ..types.chapter_response import ChapterResponse from ..types.chapter_snapshots_response import ChapterSnapshotsResponse -from ..types.get_chapters_response import GetChaptersResponse -from ..types.http_validation_error import HttpValidationError +from ..core.client_wrapper import AsyncClientWrapper # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -43,7 +43,7 @@ def get_all( Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -53,14 +53,28 @@ def get_all( ) """ _response = self._client_wrapper.httpx_client.request( - f"v1/projects/{jsonable_encoder(project_id)}/chapters", method="GET", request_options=request_options + f"v1/projects/{jsonable_encoder(project_id)}/chapters", + method="GET", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: - return typing.cast(GetChaptersResponse, construct_type(type_=GetChaptersResponse, object_=_response.json())) # type: ignore + return typing.cast( + GetChaptersResponse, + construct_type( + type_=GetChaptersResponse, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -91,7 +105,7 @@ def get( Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -108,10 +122,22 @@ def get( ) try: if 200 <= _response.status_code < 300: - return typing.cast(ChapterResponse, construct_type(type_=ChapterResponse, object_=_response.json())) # type: ignore + return typing.cast( + ChapterResponse, + construct_type( + type_=ChapterResponse, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -120,7 +146,7 @@ def get( def delete( self, project_id: str, chapter_id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> typing.Any: + ) -> typing.Optional[typing.Any]: """ Delete a chapter by its chapter_id. @@ -137,12 +163,12 @@ def delete( Returns ------- - typing.Any + typing.Optional[typing.Any] Successful Response Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -159,10 +185,22 @@ def delete( ) try: if 200 <= _response.status_code < 300: - return typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + return typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -171,7 +209,7 @@ def delete( def convert( self, project_id: str, chapter_id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> typing.Any: + ) -> typing.Optional[typing.Any]: """ Starts conversion of a specific chapter. @@ -188,12 +226,12 @@ def convert( Returns ------- - typing.Any + typing.Optional[typing.Any] Successful Response Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -210,10 +248,22 @@ def convert( ) try: if 200 <= _response.status_code < 300: - return typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + return typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -244,7 +294,7 @@ def get_all_snapshots( Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -261,10 +311,22 @@ def get_all_snapshots( ) try: if 200 <= _response.status_code < 300: - return typing.cast(ChapterSnapshotsResponse, construct_type(type_=ChapterSnapshotsResponse, object_=_response.json())) # type: ignore + return typing.cast( + ChapterSnapshotsResponse, + construct_type( + type_=ChapterSnapshotsResponse, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -306,7 +368,7 @@ def stream_snapshot( Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -320,7 +382,9 @@ def stream_snapshot( _response = self._client_wrapper.httpx_client.request( f"v1/projects/{jsonable_encoder(project_id)}/chapters/{jsonable_encoder(chapter_id)}/snapshots/{jsonable_encoder(chapter_snapshot_id)}/stream", method="POST", - json={"convert_to_mpeg": convert_to_mpeg}, + json={ + "convert_to_mpeg": convert_to_mpeg, + }, request_options=request_options, omit=OMIT, ) @@ -329,7 +393,13 @@ def stream_snapshot( return if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -364,7 +434,7 @@ async def get_all( -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -380,14 +450,28 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - f"v1/projects/{jsonable_encoder(project_id)}/chapters", method="GET", request_options=request_options + f"v1/projects/{jsonable_encoder(project_id)}/chapters", + method="GET", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: - return typing.cast(GetChaptersResponse, construct_type(type_=GetChaptersResponse, object_=_response.json())) # type: ignore + return typing.cast( + GetChaptersResponse, + construct_type( + type_=GetChaptersResponse, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -420,7 +504,7 @@ async def get( -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -443,10 +527,22 @@ async def main() -> None: ) try: if 200 <= _response.status_code < 300: - return typing.cast(ChapterResponse, construct_type(type_=ChapterResponse, object_=_response.json())) # type: ignore + return typing.cast( + ChapterResponse, + construct_type( + type_=ChapterResponse, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -455,7 +551,7 @@ async def main() -> None: async def delete( self, project_id: str, chapter_id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> typing.Any: + ) -> typing.Optional[typing.Any]: """ Delete a chapter by its chapter_id. @@ -472,14 +568,14 @@ async def delete( Returns ------- - typing.Any + typing.Optional[typing.Any] Successful Response Examples -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -502,10 +598,22 @@ async def main() -> None: ) try: if 200 <= _response.status_code < 300: - return typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + return typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -514,7 +622,7 @@ async def main() -> None: async def convert( self, project_id: str, chapter_id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> typing.Any: + ) -> typing.Optional[typing.Any]: """ Starts conversion of a specific chapter. @@ -531,14 +639,14 @@ async def convert( Returns ------- - typing.Any + typing.Optional[typing.Any] Successful Response Examples -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -561,10 +669,22 @@ async def main() -> None: ) try: if 200 <= _response.status_code < 300: - return typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + return typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -597,7 +717,7 @@ async def get_all_snapshots( -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -620,10 +740,22 @@ async def main() -> None: ) try: if 200 <= _response.status_code < 300: - return typing.cast(ChapterSnapshotsResponse, construct_type(type_=ChapterSnapshotsResponse, object_=_response.json())) # type: ignore + return typing.cast( + ChapterSnapshotsResponse, + construct_type( + type_=ChapterSnapshotsResponse, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -667,7 +799,7 @@ async def stream_snapshot( -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -687,7 +819,9 @@ async def main() -> None: _response = await self._client_wrapper.httpx_client.request( f"v1/projects/{jsonable_encoder(project_id)}/chapters/{jsonable_encoder(chapter_id)}/snapshots/{jsonable_encoder(chapter_snapshot_id)}/stream", method="POST", - json={"convert_to_mpeg": convert_to_mpeg}, + json={ + "convert_to_mpeg": convert_to_mpeg, + }, request_options=request_options, omit=OMIT, ) @@ -696,7 +830,13 @@ async def main() -> None: return if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: diff --git a/src/elevenlabs/core/__init__.py b/src/elevenlabs/core/__init__.py index 1a86ed1..226d7d5 100644 --- a/src/elevenlabs/core/__init__.py +++ b/src/elevenlabs/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -19,6 +18,7 @@ from .query_encoder import encode_query from .remove_none_from_dict import remove_none_from_dict from .request_options import RequestOptions +from .serialization import FieldMetadata, convert_and_respect_annotation_metadata from .unchecked_base_model import UncheckedBaseModel, UnionMetadata, construct_type __all__ = [ @@ -26,6 +26,7 @@ "AsyncClientWrapper", "AsyncHttpClient", "BaseClientWrapper", + "FieldMetadata", "File", "HttpClient", "IS_PYDANTIC_V2", @@ -36,8 +37,8 @@ "UniversalBaseModel", "UniversalRootModel", "construct_type", + "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/src/elevenlabs/core/client_wrapper.py b/src/elevenlabs/core/client_wrapper.py index 855c55a..898e1ba 100644 --- a/src/elevenlabs/core/client_wrapper.py +++ b/src/elevenlabs/core/client_wrapper.py @@ -1,10 +1,9 @@ # This file was auto-generated by Fern from our API Definition. import typing - import httpx - -from .http_client import AsyncHttpClient, HttpClient +from .http_client import HttpClient +from .http_client import AsyncHttpClient class BaseClientWrapper: @@ -17,7 +16,7 @@ def get_headers(self) -> typing.Dict[str, str]: headers: typing.Dict[str, str] = { "X-Fern-Language": "Python", "X-Fern-SDK-Name": "elevenlabs", - "X-Fern-SDK-Version": "1.8.0", + "X-Fern-SDK-Version": "1.8.1", } if self._api_key is not None: headers["xi-api-key"] = self._api_key @@ -37,7 +36,7 @@ def __init__( api_key: typing.Optional[str] = None, base_url: str, timeout: typing.Optional[float] = None, - httpx_client: httpx.Client + httpx_client: httpx.Client, ): super().__init__(api_key=api_key, base_url=base_url, timeout=timeout) self.httpx_client = HttpClient( @@ -55,7 +54,7 @@ def __init__( api_key: typing.Optional[str] = None, base_url: str, timeout: typing.Optional[float] = None, - httpx_client: httpx.AsyncClient + httpx_client: httpx.AsyncClient, ): super().__init__(api_key=api_key, base_url=base_url, timeout=timeout) self.httpx_client = AsyncHttpClient( diff --git a/src/elevenlabs/core/file.py b/src/elevenlabs/core/file.py index cb0d40b..6e0f92b 100644 --- a/src/elevenlabs/core/file.py +++ b/src/elevenlabs/core/file.py @@ -13,12 +13,17 @@ # (filename, file (or bytes), content_type) typing.Tuple[typing.Optional[str], FileContent, typing.Optional[str]], # (filename, file (or bytes), content_type, headers) - typing.Tuple[typing.Optional[str], FileContent, typing.Optional[str], typing.Mapping[str, str]], + typing.Tuple[ + typing.Optional[str], + FileContent, + typing.Optional[str], + typing.Mapping[str, str], + ], ] def convert_file_dict_to_httpx_tuples( - d: typing.Dict[str, typing.Union[File, typing.List[File]]] + d: typing.Dict[str, typing.Union[File, typing.List[File]]], ) -> typing.List[typing.Tuple[str, File]]: """ The format we use is a list of tuples, where the first element is the diff --git a/src/elevenlabs/core/http_client.py b/src/elevenlabs/core/http_client.py index 9333d8a..b07401b 100644 --- a/src/elevenlabs/core/http_client.py +++ b/src/elevenlabs/core/http_client.py @@ -90,7 +90,8 @@ def _should_retry(response: httpx.Response) -> bool: def remove_omit_from_dict( - original: typing.Dict[str, typing.Optional[typing.Any]], omit: typing.Optional[typing.Any] + original: typing.Dict[str, typing.Optional[typing.Any]], + omit: typing.Optional[typing.Any], ) -> typing.Dict[str, typing.Any]: if omit is None: return original @@ -142,7 +143,8 @@ def get_request_body( # If both data and json are None, we send json data in the event extra properties are specified json_body = maybe_filter_request_body(json, request_options, omit) - return json_body, data_body + # If you have an empty JSON body, you should just send None + return (json_body if json_body != {} else None), data_body if data_body != {} else None class HttpClient: diff --git a/src/elevenlabs/core/jsonable_encoder.py b/src/elevenlabs/core/jsonable_encoder.py index 9251cd5..1b631e9 100644 --- a/src/elevenlabs/core/jsonable_encoder.py +++ b/src/elevenlabs/core/jsonable_encoder.py @@ -19,7 +19,11 @@ import pydantic from .datetime_utils import serialize_datetime -from .pydantic_utilities import IS_PYDANTIC_V2, encode_by_type, to_jsonable_with_fallback +from .pydantic_utilities import ( + IS_PYDANTIC_V2, + encode_by_type, + to_jsonable_with_fallback, +) SetIntStr = Set[Union[int, str]] DictIntStrAny = Dict[Union[int, str], Any] @@ -48,7 +52,7 @@ def jsonable_encoder(obj: Any, custom_encoder: Optional[Dict[Any, Callable[[Any] obj_dict = obj_dict["root"] return jsonable_encoder(obj_dict, custom_encoder=encoder) if dataclasses.is_dataclass(obj): - obj_dict = dataclasses.asdict(obj) + obj_dict = dataclasses.asdict(obj) # type: ignore return jsonable_encoder(obj_dict, custom_encoder=custom_encoder) if isinstance(obj, bytes): return base64.b64encode(obj).decode("utf-8") diff --git a/src/elevenlabs/core/pydantic_utilities.py b/src/elevenlabs/core/pydantic_utilities.py index 0f24b0e..e2ef134 100644 --- a/src/elevenlabs/core/pydantic_utilities.py +++ b/src/elevenlabs/core/pydantic_utilities.py @@ -4,7 +4,8 @@ import datetime as dt import typing from collections import defaultdict -from functools import wraps + +import typing_extensions import pydantic @@ -27,11 +28,15 @@ from pydantic.v1.typing import ( # type: ignore # pyright: ignore[reportMissingImports] # Pydantic v2 get_args as get_args, ) - from pydantic.v1.typing import get_origin as get_origin # pyright: ignore[reportMissingImports] # Pydantic v2 + from pydantic.v1.typing import ( # pyright: ignore[reportMissingImports] # Pydantic v2 + get_origin as get_origin, + ) from pydantic.v1.typing import ( # pyright: ignore[reportMissingImports] # Pydantic v2 is_literal_type as is_literal_type, ) - from pydantic.v1.typing import is_union as is_union # pyright: ignore[reportMissingImports] # Pydantic v2 + from pydantic.v1.typing import ( # pyright: ignore[reportMissingImports] # Pydantic v2 + is_union as is_union, + ) from pydantic.v1.fields import ModelField as ModelField # type: ignore # pyright: ignore[reportMissingImports] # Pydantic v2 else: from pydantic.datetime_parse import parse_date as parse_date # type: ignore # Pydantic v1 @@ -50,19 +55,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -88,44 +80,65 @@ class Config: smart_union = True allow_population_by_field_name = True json_encoders = {dt.datetime: serialize_datetime} + # Allow fields begining with `model_` to be used in the model + protected_namespaces = () def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } if IS_PYDANTIC_V2: return super().model_dump_json(**kwargs_with_defaults) # type: ignore # Pydantic v2 else: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + _fields_set = self.__fields_set__ + + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if name not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + "include": _fields_set, + **kwargs, + } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) - ) + return super().dict(**kwargs_with_defaults_exclude_unset) -UniversalRootModel: typing.Type[typing.Any] if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 pass - UniversalRootModel = V2RootModel + UniversalRootModel: typing_extensions.TypeAlias = V2RootModel # type: ignore else: - UniversalRootModel = UniversalBaseModel + UniversalRootModel: typing_extensions.TypeAlias = UniversalBaseModel # type: ignore def encode_by_type(o: typing.Any) -> typing.Any: - encoders_by_class_tuples: typing.Dict[ - typing.Callable[[typing.Any], typing.Any], typing.Tuple[typing.Any, ...] - ] = defaultdict(tuple) + encoders_by_class_tuples: typing.Dict[typing.Callable[[typing.Any], typing.Any], typing.Tuple[typing.Any, ...]] = ( + defaultdict(tuple) + ) for type_, encoder in encoders_by_type.items(): encoders_by_class_tuples[encoder] += (type_,) @@ -136,44 +149,60 @@ def encode_by_type(o: typing.Any) -> typing.Any: return encoder(o) -def update_forward_refs(model: typing.Type["Model"], **localns: typing.Any) -> None: +def update_forward_refs(model: typing.Type["Model"]) -> None: if IS_PYDANTIC_V2: - model.model_rebuild(force=True) # type: ignore # Pydantic v2 + model.model_rebuild(raise_errors=False) # type: ignore # Pydantic v2 else: - model.update_forward_refs(**localns) + model.update_forward_refs() # Mirrors Pydantic's internal typing AnyCallable = typing.Callable[..., typing.Any] -def universal_root_validator(pre: bool = False) -> typing.Callable[[AnyCallable], AnyCallable]: +def universal_root_validator( + pre: bool = False, +) -> typing.Callable[[AnyCallable], AnyCallable]: def decorator(func: AnyCallable) -> AnyCallable: - @wraps(func) - def validate(*args: typing.Any, **kwargs: typing.Any) -> AnyCallable: - if IS_PYDANTIC_V2: - wrapped_func = pydantic.model_validator("before" if pre else "after")(func) # type: ignore # Pydantic v2 - else: - wrapped_func = pydantic.root_validator(pre=pre)(func) # type: ignore # Pydantic v1 - - return wrapped_func(*args, **kwargs) - - return validate + if IS_PYDANTIC_V2: + return pydantic.model_validator(mode="before" if pre else "after")(func) # type: ignore # Pydantic v2 + else: + return pydantic.root_validator(pre=pre)(func) # type: ignore # Pydantic v1 return decorator def universal_field_validator(field_name: str, pre: bool = False) -> typing.Callable[[AnyCallable], AnyCallable]: def decorator(func: AnyCallable) -> AnyCallable: - @wraps(func) - def validate(*args: typing.Any, **kwargs: typing.Any) -> AnyCallable: - if IS_PYDANTIC_V2: - wrapped_func = pydantic.field_validator(field_name, mode="before" if pre else "after")(func) # type: ignore # Pydantic v2 - else: - wrapped_func = pydantic.validator(field_name, pre=pre)(func) + if IS_PYDANTIC_V2: + return pydantic.field_validator(field_name, mode="before" if pre else "after")(func) # type: ignore # Pydantic v2 + else: + return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 - return wrapped_func(*args, **kwargs) + return decorator - return validate - return decorator +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/src/elevenlabs/core/query_encoder.py b/src/elevenlabs/core/query_encoder.py index 24076d7..3183001 100644 --- a/src/elevenlabs/core/query_encoder.py +++ b/src/elevenlabs/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/src/elevenlabs/core/serialization.py b/src/elevenlabs/core/serialization.py new file mode 100644 index 0000000..36180ac --- /dev/null +++ b/src/elevenlabs/core/serialization.py @@ -0,0 +1,170 @@ +# This file was auto-generated by Fern from our API Definition. + +import collections +import typing + +import typing_extensions + + +class FieldMetadata: + """ + Metadata class used to annotate fields to provide additional information. + + Example: + class MyDict(TypedDict): + field: typing.Annotated[str, FieldMetadata(alias="field_name")] + + Will serialize: `{"field": "value"}` + To: `{"field_name": "value"}` + """ + + alias: str + + def __init__(self, *, alias: str) -> None: + self.alias = alias + + +def convert_and_respect_annotation_metadata( + *, + object_: typing.Any, + annotation: typing.Any, + inner_type: typing.Optional[typing.Any] = None, +) -> typing.Any: + """ + Respect the metadata annotations on a field, such as aliasing. This function effectively + manipulates the dict-form of an object to respect the metadata annotations. This is primarily used for + TypedDicts, which cannot support aliasing out of the box, and can be extended for additional + utilities, such as defaults. + + Parameters + ---------- + object_ : typing.Any + + annotation : type + The type we're looking to apply typing annotations from + + inner_type : typing.Optional[type] + + Returns + ------- + typing.Any + """ + + if object_ is None: + return None + if inner_type is None: + inner_type = annotation + + clean_type = _remove_annotations(inner_type) + if typing_extensions.is_typeddict(clean_type) and isinstance(object_, typing.Mapping): + return _convert_typeddict(object_, clean_type) + + if ( + # If you're iterating on a string, do not bother to coerce it to a sequence. + (not isinstance(object_, str)) + and ( + ( + ( + typing_extensions.get_origin(clean_type) == typing.List + or typing_extensions.get_origin(clean_type) == list + or clean_type == typing.List + ) + and isinstance(object_, typing.List) + ) + or ( + ( + typing_extensions.get_origin(clean_type) == typing.Set + or typing_extensions.get_origin(clean_type) == set + or clean_type == typing.Set + ) + and isinstance(object_, typing.Set) + ) + or ( + ( + typing_extensions.get_origin(clean_type) == typing.Sequence + or typing_extensions.get_origin(clean_type) == collections.abc.Sequence + or clean_type == typing.Sequence + ) + and isinstance(object_, typing.Sequence) + ) + ) + ): + inner_type = typing_extensions.get_args(clean_type)[0] + return [ + convert_and_respect_annotation_metadata(object_=item, annotation=annotation, inner_type=inner_type) + for item in object_ + ] + + if typing_extensions.get_origin(clean_type) == typing.Union: + # We should be able to ~relatively~ safely try to convert keys against all + # member types in the union, the edge case here is if one member aliases a field + # of the same name to a different name from another member + # Or if another member aliases a field of the same name that another member does not. + for member in typing_extensions.get_args(clean_type): + object_ = convert_and_respect_annotation_metadata(object_=object_, annotation=annotation, inner_type=member) + return object_ + + annotated_type = _get_annotation(annotation) + if annotated_type is None: + return object_ + + # If the object is not a TypedDict, a Union, or other container (list, set, sequence, etc.) + # Then we can safely call it on the recursive conversion. + return object_ + + +def _convert_typeddict(object_: typing.Mapping[str, object], expected_type: typing.Any) -> typing.Mapping[str, object]: + converted_object: typing.Dict[str, object] = {} + annotations = typing_extensions.get_type_hints(expected_type, include_extras=True) + for key, value in object_.items(): + type_ = annotations.get(key) + if type_ is None: + converted_object[key] = value + else: + converted_object[_alias_key(key, type_)] = convert_and_respect_annotation_metadata( + object_=value, annotation=type_ + ) + return converted_object + + +def _get_annotation(type_: typing.Any) -> typing.Optional[typing.Any]: + maybe_annotated_type = typing_extensions.get_origin(type_) + if maybe_annotated_type is None: + return None + + if maybe_annotated_type == typing_extensions.NotRequired: + type_ = typing_extensions.get_args(type_)[0] + maybe_annotated_type = typing_extensions.get_origin(type_) + + if maybe_annotated_type == typing_extensions.Annotated: + return type_ + + return None + + +def _remove_annotations(type_: typing.Any) -> typing.Any: + maybe_annotated_type = typing_extensions.get_origin(type_) + if maybe_annotated_type is None: + return type_ + + if maybe_annotated_type == typing_extensions.NotRequired: + return _remove_annotations(typing_extensions.get_args(type_)[0]) + + if maybe_annotated_type == typing_extensions.Annotated: + return _remove_annotations(typing_extensions.get_args(type_)[0]) + + return type_ + + +def _alias_key(key: str, type_: typing.Any) -> str: + maybe_annotated_type = _get_annotation(type_) + + if maybe_annotated_type is not None: + # The actual annotations are 1 onward, the first is the annotated type + annotations = typing_extensions.get_args(maybe_annotated_type)[1:] + + for annotation in annotations: + if isinstance(annotation, FieldMetadata) and annotation.alias is not None: + return annotation.alias + + return key diff --git a/src/elevenlabs/core/unchecked_base_model.py b/src/elevenlabs/core/unchecked_base_model.py index 7a832d0..b3f9dfe 100644 --- a/src/elevenlabs/core/unchecked_base_model.py +++ b/src/elevenlabs/core/unchecked_base_model.py @@ -5,10 +5,11 @@ import typing import uuid -import pydantic import typing_extensions from pydantic_core import PydanticUndefined +import pydantic + from .pydantic_utilities import ( IS_PYDANTIC_V2, ModelField, @@ -43,7 +44,9 @@ class Config: @classmethod def model_construct( - cls: typing.Type["Model"], _fields_set: typing.Optional[typing.Set[str]] = None, **values: typing.Any + cls: typing.Type["Model"], + _fields_set: typing.Optional[typing.Set[str]] = None, + **values: typing.Any, ) -> "Model": # Fallback construct function to the specified override below. return cls.construct(_fields_set=_fields_set, **values) @@ -52,7 +55,9 @@ def model_construct( # Implementation taken from: https://github.com/pydantic/pydantic/issues/1168#issuecomment-817742836 @classmethod def construct( - cls: typing.Type["Model"], _fields_set: typing.Optional[typing.Set[str]] = None, **values: typing.Any + cls: typing.Type["Model"], + _fields_set: typing.Optional[typing.Set[str]] = None, + **values: typing.Any, ) -> "Model": m = cls.__new__(cls) fields_values = {} @@ -263,11 +268,13 @@ def _get_is_populate_by_name(model: typing.Type["Model"]) -> bool: # Pydantic V1 swapped the typing of __fields__'s values from ModelField to FieldInfo # And so we try to handle both V1 cases, as well as V2 (FieldInfo from model.model_fields) -def _get_model_fields(model: typing.Type["Model"]) -> typing.Mapping[str, PydanticField]: +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: if IS_PYDANTIC_V2: return model.model_fields # type: ignore # Pydantic v2 else: - return model.__fields__ + return model.__fields__ # type: ignore # Pydantic v1 def _get_field_default(field: PydanticField) -> typing.Any: diff --git a/src/elevenlabs/dubbing/client.py b/src/elevenlabs/dubbing/client.py index b6dfef6..3226750 100644 --- a/src/elevenlabs/dubbing/client.py +++ b/src/elevenlabs/dubbing/client.py @@ -1,21 +1,21 @@ # This file was auto-generated by Fern from our API Definition. import typing -from json.decoder import JSONDecodeError - +from ..core.client_wrapper import SyncClientWrapper from .. import core -from ..core.api_error import ApiError -from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper -from ..core.jsonable_encoder import jsonable_encoder from ..core.request_options import RequestOptions +from ..types.do_dubbing_response import DoDubbingResponse from ..core.unchecked_base_model import construct_type from ..errors.unprocessable_entity_error import UnprocessableEntityError -from ..types.do_dubbing_response import DoDubbingResponse -from ..types.dubbing_metadata_response import DubbingMetadataResponse from ..types.http_validation_error import HttpValidationError +from json.decoder import JSONDecodeError +from ..core.api_error import ApiError +from ..types.dubbing_metadata_response import DubbingMetadataResponse +from ..core.jsonable_encoder import jsonable_encoder from .types.get_transcript_for_dub_v_1_dubbing_dubbing_id_transcript_language_code_get_request_format_type import ( GetTranscriptForDubV1DubbingDubbingIdTranscriptLanguageCodeGetRequestFormatType, ) +from ..core.client_wrapper import AsyncClientWrapper # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -85,7 +85,7 @@ def dub_a_video_or_an_audio_file( Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -108,16 +108,30 @@ def dub_a_video_or_an_audio_file( "end_time": end_time, "highest_resolution": highest_resolution, }, - files={"file": file}, + files={ + "file": file, + }, request_options=request_options, omit=OMIT, ) try: if 200 <= _response.status_code < 300: - return typing.cast(DoDubbingResponse, construct_type(type_=DoDubbingResponse, object_=_response.json())) # type: ignore + return typing.cast( + DoDubbingResponse, + construct_type( + type_=DoDubbingResponse, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -145,7 +159,7 @@ def get_dubbing_project_metadata( Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -155,14 +169,28 @@ def get_dubbing_project_metadata( ) """ _response = self._client_wrapper.httpx_client.request( - f"v1/dubbing/{jsonable_encoder(dubbing_id)}", method="GET", request_options=request_options + f"v1/dubbing/{jsonable_encoder(dubbing_id)}", + method="GET", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: - return typing.cast(DubbingMetadataResponse, construct_type(type_=DubbingMetadataResponse, object_=_response.json())) # type: ignore + return typing.cast( + DubbingMetadataResponse, + construct_type( + type_=DubbingMetadataResponse, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -171,7 +199,7 @@ def get_dubbing_project_metadata( def delete_dubbing_project( self, dubbing_id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> typing.Any: + ) -> typing.Optional[typing.Any]: """ Deletes a dubbing project. @@ -185,12 +213,12 @@ def delete_dubbing_project( Returns ------- - typing.Any + typing.Optional[typing.Any] Successful Response Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -200,14 +228,28 @@ def delete_dubbing_project( ) """ _response = self._client_wrapper.httpx_client.request( - f"v1/dubbing/{jsonable_encoder(dubbing_id)}", method="DELETE", request_options=request_options + f"v1/dubbing/{jsonable_encoder(dubbing_id)}", + method="DELETE", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: - return typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + return typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -238,7 +280,7 @@ def get_dubbed_file( Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -261,7 +303,13 @@ def get_dubbed_file( _response.read() if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -277,7 +325,7 @@ def get_transcript_for_dub( GetTranscriptForDubV1DubbingDubbingIdTranscriptLanguageCodeGetRequestFormatType ] = None, request_options: typing.Optional[RequestOptions] = None, - ) -> typing.Any: + ) -> typing.Optional[typing.Any]: """ Returns transcript for the dub as an SRT file. @@ -297,12 +345,12 @@ def get_transcript_for_dub( Returns ------- - typing.Any + typing.Optional[typing.Any] Successful Response Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -315,15 +363,29 @@ def get_transcript_for_dub( _response = self._client_wrapper.httpx_client.request( f"v1/dubbing/{jsonable_encoder(dubbing_id)}/transcript/{jsonable_encoder(language_code)}", method="GET", - params={"format_type": format_type}, + params={ + "format_type": format_type, + }, request_options=request_options, ) try: if 200 <= _response.status_code < 300: - return typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + return typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -397,7 +459,7 @@ async def dub_a_video_or_an_audio_file( -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -426,16 +488,30 @@ async def main() -> None: "end_time": end_time, "highest_resolution": highest_resolution, }, - files={"file": file}, + files={ + "file": file, + }, request_options=request_options, omit=OMIT, ) try: if 200 <= _response.status_code < 300: - return typing.cast(DoDubbingResponse, construct_type(type_=DoDubbingResponse, object_=_response.json())) # type: ignore + return typing.cast( + DoDubbingResponse, + construct_type( + type_=DoDubbingResponse, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -465,7 +541,7 @@ async def get_dubbing_project_metadata( -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -481,14 +557,28 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - f"v1/dubbing/{jsonable_encoder(dubbing_id)}", method="GET", request_options=request_options + f"v1/dubbing/{jsonable_encoder(dubbing_id)}", + method="GET", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: - return typing.cast(DubbingMetadataResponse, construct_type(type_=DubbingMetadataResponse, object_=_response.json())) # type: ignore + return typing.cast( + DubbingMetadataResponse, + construct_type( + type_=DubbingMetadataResponse, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -497,7 +587,7 @@ async def main() -> None: async def delete_dubbing_project( self, dubbing_id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> typing.Any: + ) -> typing.Optional[typing.Any]: """ Deletes a dubbing project. @@ -511,14 +601,14 @@ async def delete_dubbing_project( Returns ------- - typing.Any + typing.Optional[typing.Any] Successful Response Examples -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -534,14 +624,28 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - f"v1/dubbing/{jsonable_encoder(dubbing_id)}", method="DELETE", request_options=request_options + f"v1/dubbing/{jsonable_encoder(dubbing_id)}", + method="DELETE", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: - return typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + return typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -574,7 +678,7 @@ async def get_dubbed_file( -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -603,7 +707,13 @@ async def main() -> None: await _response.aread() if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -619,7 +729,7 @@ async def get_transcript_for_dub( GetTranscriptForDubV1DubbingDubbingIdTranscriptLanguageCodeGetRequestFormatType ] = None, request_options: typing.Optional[RequestOptions] = None, - ) -> typing.Any: + ) -> typing.Optional[typing.Any]: """ Returns transcript for the dub as an SRT file. @@ -639,14 +749,14 @@ async def get_transcript_for_dub( Returns ------- - typing.Any + typing.Optional[typing.Any] Successful Response Examples -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -665,15 +775,29 @@ async def main() -> None: _response = await self._client_wrapper.httpx_client.request( f"v1/dubbing/{jsonable_encoder(dubbing_id)}/transcript/{jsonable_encoder(language_code)}", method="GET", - params={"format_type": format_type}, + params={ + "format_type": format_type, + }, request_options=request_options, ) try: if 200 <= _response.status_code < 300: - return typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + return typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: diff --git a/src/elevenlabs/history/client.py b/src/elevenlabs/history/client.py index 390475f..ce259e3 100644 --- a/src/elevenlabs/history/client.py +++ b/src/elevenlabs/history/client.py @@ -1,17 +1,17 @@ # This file was auto-generated by Fern from our API Definition. import typing -from json.decoder import JSONDecodeError - -from ..core.api_error import ApiError -from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper -from ..core.jsonable_encoder import jsonable_encoder +from ..core.client_wrapper import SyncClientWrapper from ..core.request_options import RequestOptions +from ..types.get_speech_history_response import GetSpeechHistoryResponse from ..core.unchecked_base_model import construct_type from ..errors.unprocessable_entity_error import UnprocessableEntityError -from ..types.get_speech_history_response import GetSpeechHistoryResponse from ..types.http_validation_error import HttpValidationError +from json.decoder import JSONDecodeError +from ..core.api_error import ApiError from ..types.speech_history_item_response import SpeechHistoryItemResponse +from ..core.jsonable_encoder import jsonable_encoder +from ..core.client_wrapper import AsyncClientWrapper # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -53,7 +53,7 @@ def get_all( Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -75,10 +75,22 @@ def get_all( ) try: if 200 <= _response.status_code < 300: - return typing.cast(GetSpeechHistoryResponse, construct_type(type_=GetSpeechHistoryResponse, object_=_response.json())) # type: ignore + return typing.cast( + GetSpeechHistoryResponse, + construct_type( + type_=GetSpeechHistoryResponse, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -106,7 +118,7 @@ def get( Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -116,21 +128,37 @@ def get( ) """ _response = self._client_wrapper.httpx_client.request( - f"v1/history/{jsonable_encoder(history_item_id)}", method="GET", request_options=request_options + f"v1/history/{jsonable_encoder(history_item_id)}", + method="GET", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: - return typing.cast(SpeechHistoryItemResponse, construct_type(type_=SpeechHistoryItemResponse, object_=_response.json())) # type: ignore + return typing.cast( + SpeechHistoryItemResponse, + construct_type( + type_=SpeechHistoryItemResponse, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - def delete(self, history_item_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> typing.Any: + def delete( + self, history_item_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> typing.Optional[typing.Any]: """ Delete a history item by its ID @@ -144,12 +172,12 @@ def delete(self, history_item_id: str, *, request_options: typing.Optional[Reque Returns ------- - typing.Any + typing.Optional[typing.Any] Successful Response Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -159,14 +187,28 @@ def delete(self, history_item_id: str, *, request_options: typing.Optional[Reque ) """ _response = self._client_wrapper.httpx_client.request( - f"v1/history/{jsonable_encoder(history_item_id)}", method="DELETE", request_options=request_options + f"v1/history/{jsonable_encoder(history_item_id)}", + method="DELETE", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: - return typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + return typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -194,7 +236,7 @@ def get_audio( Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -204,7 +246,9 @@ def get_audio( ) """ with self._client_wrapper.httpx_client.stream( - f"v1/history/{jsonable_encoder(history_item_id)}/audio", method="GET", request_options=request_options + f"v1/history/{jsonable_encoder(history_item_id)}/audio", + method="GET", + request_options=request_options, ) as _response: try: if 200 <= _response.status_code < 300: @@ -214,7 +258,13 @@ def get_audio( _response.read() if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -248,7 +298,7 @@ def download( Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -260,7 +310,10 @@ def download( _response = self._client_wrapper.httpx_client.request( "v1/history/download", method="POST", - json={"history_item_ids": history_item_ids, "output_format": output_format}, + json={ + "history_item_ids": history_item_ids, + "output_format": output_format, + }, request_options=request_options, omit=OMIT, ) @@ -269,7 +322,13 @@ def download( return if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -315,7 +374,7 @@ async def get_all( -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -343,10 +402,22 @@ async def main() -> None: ) try: if 200 <= _response.status_code < 300: - return typing.cast(GetSpeechHistoryResponse, construct_type(type_=GetSpeechHistoryResponse, object_=_response.json())) # type: ignore + return typing.cast( + GetSpeechHistoryResponse, + construct_type( + type_=GetSpeechHistoryResponse, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -376,7 +447,7 @@ async def get( -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -392,14 +463,28 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - f"v1/history/{jsonable_encoder(history_item_id)}", method="GET", request_options=request_options + f"v1/history/{jsonable_encoder(history_item_id)}", + method="GET", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: - return typing.cast(SpeechHistoryItemResponse, construct_type(type_=SpeechHistoryItemResponse, object_=_response.json())) # type: ignore + return typing.cast( + SpeechHistoryItemResponse, + construct_type( + type_=SpeechHistoryItemResponse, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -408,7 +493,7 @@ async def main() -> None: async def delete( self, history_item_id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> typing.Any: + ) -> typing.Optional[typing.Any]: """ Delete a history item by its ID @@ -422,14 +507,14 @@ async def delete( Returns ------- - typing.Any + typing.Optional[typing.Any] Successful Response Examples -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -445,14 +530,28 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - f"v1/history/{jsonable_encoder(history_item_id)}", method="DELETE", request_options=request_options + f"v1/history/{jsonable_encoder(history_item_id)}", + method="DELETE", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: - return typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + return typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -482,7 +581,7 @@ async def get_audio( -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -498,7 +597,9 @@ async def main() -> None: asyncio.run(main()) """ async with self._client_wrapper.httpx_client.stream( - f"v1/history/{jsonable_encoder(history_item_id)}/audio", method="GET", request_options=request_options + f"v1/history/{jsonable_encoder(history_item_id)}/audio", + method="GET", + request_options=request_options, ) as _response: try: if 200 <= _response.status_code < 300: @@ -508,7 +609,13 @@ async def main() -> None: await _response.aread() if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -544,7 +651,7 @@ async def download( -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -562,7 +669,10 @@ async def main() -> None: _response = await self._client_wrapper.httpx_client.request( "v1/history/download", method="POST", - json={"history_item_ids": history_item_ids, "output_format": output_format}, + json={ + "history_item_ids": history_item_ids, + "output_format": output_format, + }, request_options=request_options, omit=OMIT, ) @@ -571,7 +681,13 @@ async def main() -> None: return if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: diff --git a/src/elevenlabs/models/client.py b/src/elevenlabs/models/client.py index 4727ebc..1ba247d 100644 --- a/src/elevenlabs/models/client.py +++ b/src/elevenlabs/models/client.py @@ -1,15 +1,15 @@ # This file was auto-generated by Fern from our API Definition. +from ..core.client_wrapper import SyncClientWrapper import typing -from json.decoder import JSONDecodeError - -from ..core.api_error import ApiError -from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.request_options import RequestOptions +from ..types.model import Model from ..core.unchecked_base_model import construct_type from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.http_validation_error import HttpValidationError -from ..types.model import Model +from json.decoder import JSONDecodeError +from ..core.api_error import ApiError +from ..core.client_wrapper import AsyncClientWrapper class ModelsClient: @@ -32,7 +32,7 @@ def get_all(self, *, request_options: typing.Optional[RequestOptions] = None) -> Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -40,14 +40,28 @@ def get_all(self, *, request_options: typing.Optional[RequestOptions] = None) -> client.models.get_all() """ _response = self._client_wrapper.httpx_client.request( - "v1/models", method="GET", request_options=request_options + "v1/models", + method="GET", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: - return typing.cast(typing.List[Model], construct_type(type_=typing.List[Model], object_=_response.json())) # type: ignore + return typing.cast( + typing.List[Model], + construct_type( + type_=typing.List[Model], # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -77,7 +91,7 @@ async def get_all(self, *, request_options: typing.Optional[RequestOptions] = No -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -91,14 +105,28 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - "v1/models", method="GET", request_options=request_options + "v1/models", + method="GET", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: - return typing.cast(typing.List[Model], construct_type(type_=typing.List[Model], object_=_response.json())) # type: ignore + return typing.cast( + typing.List[Model], + construct_type( + type_=typing.List[Model], # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: diff --git a/src/elevenlabs/projects/client.py b/src/elevenlabs/projects/client.py index 9980530..8ed3f28 100644 --- a/src/elevenlabs/projects/client.py +++ b/src/elevenlabs/projects/client.py @@ -1,22 +1,22 @@ # This file was auto-generated by Fern from our API Definition. import typing -from json.decoder import JSONDecodeError - -from .. import core -from ..core.api_error import ApiError -from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper -from ..core.jsonable_encoder import jsonable_encoder +from ..core.client_wrapper import SyncClientWrapper from ..core.request_options import RequestOptions +from ..types.get_projects_response import GetProjectsResponse from ..core.unchecked_base_model import construct_type from ..errors.unprocessable_entity_error import UnprocessableEntityError -from ..types.add_project_response_model import AddProjectResponseModel -from ..types.edit_project_response_model import EditProjectResponseModel -from ..types.get_projects_response import GetProjectsResponse from ..types.http_validation_error import HttpValidationError +from json.decoder import JSONDecodeError +from ..core.api_error import ApiError +from .. import core +from ..types.add_project_response_model import AddProjectResponseModel from ..types.project_extended_response_model import ProjectExtendedResponseModel +from ..core.jsonable_encoder import jsonable_encoder +from ..types.edit_project_response_model import EditProjectResponseModel from ..types.project_snapshots_response import ProjectSnapshotsResponse from ..types.pronunciation_dictionary_version_locator import PronunciationDictionaryVersionLocator +from ..core.client_wrapper import AsyncClientWrapper # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -42,7 +42,7 @@ def get_all(self, *, request_options: typing.Optional[RequestOptions] = None) -> Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -50,14 +50,28 @@ def get_all(self, *, request_options: typing.Optional[RequestOptions] = None) -> client.projects.get_all() """ _response = self._client_wrapper.httpx_client.request( - "v1/projects", method="GET", request_options=request_options + "v1/projects", + method="GET", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: - return typing.cast(GetProjectsResponse, construct_type(type_=GetProjectsResponse, object_=_response.json())) # type: ignore + return typing.cast( + GetProjectsResponse, + construct_type( + type_=GetProjectsResponse, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -141,7 +155,7 @@ def add( Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -170,16 +184,30 @@ def add( "volume_normalization": volume_normalization, "pronunciation_dictionary_locators": pronunciation_dictionary_locators, }, - files={"from_document": from_document}, + files={ + "from_document": from_document, + }, request_options=request_options, omit=OMIT, ) try: if 200 <= _response.status_code < 300: - return typing.cast(AddProjectResponseModel, construct_type(type_=AddProjectResponseModel, object_=_response.json())) # type: ignore + return typing.cast( + AddProjectResponseModel, + construct_type( + type_=AddProjectResponseModel, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -207,7 +235,7 @@ def get( Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -217,14 +245,28 @@ def get( ) """ _response = self._client_wrapper.httpx_client.request( - f"v1/projects/{jsonable_encoder(project_id)}", method="GET", request_options=request_options + f"v1/projects/{jsonable_encoder(project_id)}", + method="GET", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: - return typing.cast(ProjectExtendedResponseModel, construct_type(type_=ProjectExtendedResponseModel, object_=_response.json())) # type: ignore + return typing.cast( + ProjectExtendedResponseModel, + construct_type( + type_=ProjectExtendedResponseModel, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -283,7 +325,7 @@ def edit_basic_project_info( Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -312,17 +354,31 @@ def edit_basic_project_info( ) try: if 200 <= _response.status_code < 300: - return typing.cast(EditProjectResponseModel, construct_type(type_=EditProjectResponseModel, object_=_response.json())) # type: ignore + return typing.cast( + EditProjectResponseModel, + construct_type( + type_=EditProjectResponseModel, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - def delete(self, project_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> typing.Any: + def delete( + self, project_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> typing.Optional[typing.Any]: """ Delete a project by its project_id. @@ -336,12 +392,12 @@ def delete(self, project_id: str, *, request_options: typing.Optional[RequestOpt Returns ------- - typing.Any + typing.Optional[typing.Any] Successful Response Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -351,21 +407,37 @@ def delete(self, project_id: str, *, request_options: typing.Optional[RequestOpt ) """ _response = self._client_wrapper.httpx_client.request( - f"v1/projects/{jsonable_encoder(project_id)}", method="DELETE", request_options=request_options + f"v1/projects/{jsonable_encoder(project_id)}", + method="DELETE", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: - return typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + return typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - def convert(self, project_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> typing.Any: + def convert( + self, project_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> typing.Optional[typing.Any]: """ Starts conversion of a project and all of its chapters. @@ -379,12 +451,12 @@ def convert(self, project_id: str, *, request_options: typing.Optional[RequestOp Returns ------- - typing.Any + typing.Optional[typing.Any] Successful Response Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -394,14 +466,28 @@ def convert(self, project_id: str, *, request_options: typing.Optional[RequestOp ) """ _response = self._client_wrapper.httpx_client.request( - f"v1/projects/{jsonable_encoder(project_id)}/convert", method="POST", request_options=request_options + f"v1/projects/{jsonable_encoder(project_id)}/convert", + method="POST", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: - return typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + return typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -429,7 +515,7 @@ def get_snapshots( Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -439,14 +525,28 @@ def get_snapshots( ) """ _response = self._client_wrapper.httpx_client.request( - f"v1/projects/{jsonable_encoder(project_id)}/snapshots", method="GET", request_options=request_options + f"v1/projects/{jsonable_encoder(project_id)}/snapshots", + method="GET", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: - return typing.cast(ProjectSnapshotsResponse, construct_type(type_=ProjectSnapshotsResponse, object_=_response.json())) # type: ignore + return typing.cast( + ProjectSnapshotsResponse, + construct_type( + type_=ProjectSnapshotsResponse, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -485,7 +585,7 @@ def stream_audio( Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -499,7 +599,9 @@ def stream_audio( with self._client_wrapper.httpx_client.stream( f"v1/projects/{jsonable_encoder(project_id)}/snapshots/{jsonable_encoder(project_snapshot_id)}/stream", method="POST", - json={"convert_to_mpeg": convert_to_mpeg}, + json={ + "convert_to_mpeg": convert_to_mpeg, + }, request_options=request_options, omit=OMIT, ) as _response: @@ -511,7 +613,13 @@ def stream_audio( _response.read() if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -541,7 +649,7 @@ def stream_archive( Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -561,7 +669,13 @@ def stream_archive( return if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -574,7 +688,7 @@ def update_pronunciation_dictionaries( *, pronunciation_dictionary_locators: typing.Sequence[PronunciationDictionaryVersionLocator], request_options: typing.Optional[RequestOptions] = None, - ) -> typing.Any: + ) -> typing.Optional[typing.Any]: """ Updates the set of pronunciation dictionaries acting on a project. This will automatically mark text within this project as requiring reconverting where the new dictionary would apply or the old one no longer does. @@ -591,13 +705,12 @@ def update_pronunciation_dictionaries( Returns ------- - typing.Any + typing.Optional[typing.Any] Successful Response Examples -------- - from elevenlabs import PronunciationDictionaryVersionLocator - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs, PronunciationDictionaryVersionLocator client = ElevenLabs( api_key="YOUR_API_KEY", @@ -615,16 +728,30 @@ def update_pronunciation_dictionaries( _response = self._client_wrapper.httpx_client.request( f"v1/projects/{jsonable_encoder(project_id)}/update-pronunciation-dictionaries", method="POST", - json={"pronunciation_dictionary_locators": pronunciation_dictionary_locators}, + json={ + "pronunciation_dictionary_locators": pronunciation_dictionary_locators, + }, request_options=request_options, omit=OMIT, ) try: if 200 <= _response.status_code < 300: - return typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + return typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -654,7 +781,7 @@ async def get_all(self, *, request_options: typing.Optional[RequestOptions] = No -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -668,14 +795,28 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - "v1/projects", method="GET", request_options=request_options + "v1/projects", + method="GET", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: - return typing.cast(GetProjectsResponse, construct_type(type_=GetProjectsResponse, object_=_response.json())) # type: ignore + return typing.cast( + GetProjectsResponse, + construct_type( + type_=GetProjectsResponse, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -761,7 +902,7 @@ async def add( -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -796,16 +937,30 @@ async def main() -> None: "volume_normalization": volume_normalization, "pronunciation_dictionary_locators": pronunciation_dictionary_locators, }, - files={"from_document": from_document}, + files={ + "from_document": from_document, + }, request_options=request_options, omit=OMIT, ) try: if 200 <= _response.status_code < 300: - return typing.cast(AddProjectResponseModel, construct_type(type_=AddProjectResponseModel, object_=_response.json())) # type: ignore + return typing.cast( + AddProjectResponseModel, + construct_type( + type_=AddProjectResponseModel, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -835,7 +990,7 @@ async def get( -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -851,14 +1006,28 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - f"v1/projects/{jsonable_encoder(project_id)}", method="GET", request_options=request_options + f"v1/projects/{jsonable_encoder(project_id)}", + method="GET", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: - return typing.cast(ProjectExtendedResponseModel, construct_type(type_=ProjectExtendedResponseModel, object_=_response.json())) # type: ignore + return typing.cast( + ProjectExtendedResponseModel, + construct_type( + type_=ProjectExtendedResponseModel, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -919,7 +1088,7 @@ async def edit_basic_project_info( -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -954,17 +1123,31 @@ async def main() -> None: ) try: if 200 <= _response.status_code < 300: - return typing.cast(EditProjectResponseModel, construct_type(type_=EditProjectResponseModel, object_=_response.json())) # type: ignore + return typing.cast( + EditProjectResponseModel, + construct_type( + type_=EditProjectResponseModel, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - async def delete(self, project_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> typing.Any: + async def delete( + self, project_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> typing.Optional[typing.Any]: """ Delete a project by its project_id. @@ -978,14 +1161,14 @@ async def delete(self, project_id: str, *, request_options: typing.Optional[Requ Returns ------- - typing.Any + typing.Optional[typing.Any] Successful Response Examples -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -1001,21 +1184,37 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - f"v1/projects/{jsonable_encoder(project_id)}", method="DELETE", request_options=request_options + f"v1/projects/{jsonable_encoder(project_id)}", + method="DELETE", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: - return typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + return typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - async def convert(self, project_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> typing.Any: + async def convert( + self, project_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> typing.Optional[typing.Any]: """ Starts conversion of a project and all of its chapters. @@ -1029,14 +1228,14 @@ async def convert(self, project_id: str, *, request_options: typing.Optional[Req Returns ------- - typing.Any + typing.Optional[typing.Any] Successful Response Examples -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -1052,14 +1251,28 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - f"v1/projects/{jsonable_encoder(project_id)}/convert", method="POST", request_options=request_options + f"v1/projects/{jsonable_encoder(project_id)}/convert", + method="POST", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: - return typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + return typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -1089,7 +1302,7 @@ async def get_snapshots( -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -1105,14 +1318,28 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - f"v1/projects/{jsonable_encoder(project_id)}/snapshots", method="GET", request_options=request_options + f"v1/projects/{jsonable_encoder(project_id)}/snapshots", + method="GET", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: - return typing.cast(ProjectSnapshotsResponse, construct_type(type_=ProjectSnapshotsResponse, object_=_response.json())) # type: ignore + return typing.cast( + ProjectSnapshotsResponse, + construct_type( + type_=ProjectSnapshotsResponse, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -1153,7 +1380,7 @@ async def stream_audio( -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -1173,7 +1400,9 @@ async def main() -> None: async with self._client_wrapper.httpx_client.stream( f"v1/projects/{jsonable_encoder(project_id)}/snapshots/{jsonable_encoder(project_snapshot_id)}/stream", method="POST", - json={"convert_to_mpeg": convert_to_mpeg}, + json={ + "convert_to_mpeg": convert_to_mpeg, + }, request_options=request_options, omit=OMIT, ) as _response: @@ -1185,7 +1414,13 @@ async def main() -> None: await _response.aread() if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -1217,7 +1452,7 @@ async def stream_archive( -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -1243,7 +1478,13 @@ async def main() -> None: return if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -1256,7 +1497,7 @@ async def update_pronunciation_dictionaries( *, pronunciation_dictionary_locators: typing.Sequence[PronunciationDictionaryVersionLocator], request_options: typing.Optional[RequestOptions] = None, - ) -> typing.Any: + ) -> typing.Optional[typing.Any]: """ Updates the set of pronunciation dictionaries acting on a project. This will automatically mark text within this project as requiring reconverting where the new dictionary would apply or the old one no longer does. @@ -1273,15 +1514,14 @@ async def update_pronunciation_dictionaries( Returns ------- - typing.Any + typing.Optional[typing.Any] Successful Response Examples -------- import asyncio - from elevenlabs import PronunciationDictionaryVersionLocator - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs, PronunciationDictionaryVersionLocator client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -1305,16 +1545,30 @@ async def main() -> None: _response = await self._client_wrapper.httpx_client.request( f"v1/projects/{jsonable_encoder(project_id)}/update-pronunciation-dictionaries", method="POST", - json={"pronunciation_dictionary_locators": pronunciation_dictionary_locators}, + json={ + "pronunciation_dictionary_locators": pronunciation_dictionary_locators, + }, request_options=request_options, omit=OMIT, ) try: if 200 <= _response.status_code < 300: - return typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + return typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: diff --git a/src/elevenlabs/pronunciation_dictionary/client.py b/src/elevenlabs/pronunciation_dictionary/client.py index 799c513..bae8a5d 100644 --- a/src/elevenlabs/pronunciation_dictionary/client.py +++ b/src/elevenlabs/pronunciation_dictionary/client.py @@ -1,27 +1,27 @@ # This file was auto-generated by Fern from our API Definition. import typing -from json.decoder import JSONDecodeError - +from ..core.client_wrapper import SyncClientWrapper from .. import core -from ..core.api_error import ApiError -from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper -from ..core.jsonable_encoder import jsonable_encoder +from .types.pronunciation_dictionary_add_from_file_request_workspace_access import ( + PronunciationDictionaryAddFromFileRequestWorkspaceAccess, +) from ..core.request_options import RequestOptions +from ..types.add_pronunciation_dictionary_response_model import AddPronunciationDictionaryResponseModel from ..core.unchecked_base_model import construct_type from ..errors.unprocessable_entity_error import UnprocessableEntityError -from ..types.add_pronunciation_dictionary_response_model import AddPronunciationDictionaryResponseModel +from ..types.http_validation_error import HttpValidationError +from json.decoder import JSONDecodeError +from ..core.api_error import ApiError +from .types.pronunciation_dictionary_rule import PronunciationDictionaryRule from ..types.add_pronunciation_dictionary_rules_response_model import AddPronunciationDictionaryRulesResponseModel +from ..core.jsonable_encoder import jsonable_encoder +from ..types.remove_pronunciation_dictionary_rules_response_model import RemovePronunciationDictionaryRulesResponseModel +from ..types.get_pronunciation_dictionary_metadata_response import GetPronunciationDictionaryMetadataResponse from ..types.get_pronunciation_dictionaries_metadata_response_model import ( GetPronunciationDictionariesMetadataResponseModel, ) -from ..types.get_pronunciation_dictionary_metadata_response import GetPronunciationDictionaryMetadataResponse -from ..types.http_validation_error import HttpValidationError -from ..types.remove_pronunciation_dictionary_rules_response_model import RemovePronunciationDictionaryRulesResponseModel -from .types.pronunciation_dictionary_add_from_file_request_workspace_access import ( - PronunciationDictionaryAddFromFileRequestWorkspaceAccess, -) -from .types.pronunciation_dictionary_rule import PronunciationDictionaryRule +from ..core.client_wrapper import AsyncClientWrapper # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -67,7 +67,7 @@ def add_from_file( Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -79,17 +79,35 @@ def add_from_file( _response = self._client_wrapper.httpx_client.request( "v1/pronunciation-dictionaries/add-from-file", method="POST", - data={"name": name, "description": description, "workspace_access": workspace_access}, - files={"file": file}, + data={ + "name": name, + "description": description, + "workspace_access": workspace_access, + }, + files={ + "file": file, + }, request_options=request_options, omit=OMIT, ) try: if 200 <= _response.status_code < 300: - return typing.cast(AddPronunciationDictionaryResponseModel, construct_type(type_=AddPronunciationDictionaryResponseModel, object_=_response.json())) # type: ignore + return typing.cast( + AddPronunciationDictionaryResponseModel, + construct_type( + type_=AddPronunciationDictionaryResponseModel, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -126,29 +144,52 @@ def add_rules_to_the_pronunciation_dictionary( Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs + from elevenlabs.pronunciation_dictionary import ( + PronunciationDictionaryRule_Phoneme, + ) client = ElevenLabs( api_key="YOUR_API_KEY", ) client.pronunciation_dictionary.add_rules_to_the_pronunciation_dictionary( pronunciation_dictionary_id="21m00Tcm4TlvDq8ikWAM", - rules=[], + rules=[ + PronunciationDictionaryRule_Phoneme( + string_to_replace="rules", + phoneme="rules", + alphabet="rules", + ) + ], ) """ _response = self._client_wrapper.httpx_client.request( f"v1/pronunciation-dictionaries/{jsonable_encoder(pronunciation_dictionary_id)}/add-rules", method="POST", - json={"rules": rules}, + json={ + "rules": rules, + }, request_options=request_options, omit=OMIT, ) try: if 200 <= _response.status_code < 300: - return typing.cast(AddPronunciationDictionaryRulesResponseModel, construct_type(type_=AddPronunciationDictionaryRulesResponseModel, object_=_response.json())) # type: ignore + return typing.cast( + AddPronunciationDictionaryRulesResponseModel, + construct_type( + type_=AddPronunciationDictionaryRulesResponseModel, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -183,7 +224,7 @@ def remove_rules_from_the_pronunciation_dictionary( Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -196,16 +237,30 @@ def remove_rules_from_the_pronunciation_dictionary( _response = self._client_wrapper.httpx_client.request( f"v1/pronunciation-dictionaries/{jsonable_encoder(pronunciation_dictionary_id)}/remove-rules", method="POST", - json={"rule_strings": rule_strings}, + json={ + "rule_strings": rule_strings, + }, request_options=request_options, omit=OMIT, ) try: if 200 <= _response.status_code < 300: - return typing.cast(RemovePronunciationDictionaryRulesResponseModel, construct_type(type_=RemovePronunciationDictionaryRulesResponseModel, object_=_response.json())) # type: ignore + return typing.cast( + RemovePronunciationDictionaryRulesResponseModel, + construct_type( + type_=RemovePronunciationDictionaryRulesResponseModel, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -236,7 +291,7 @@ def download( Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -256,7 +311,13 @@ def download( return _response.text # type: ignore if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -284,7 +345,7 @@ def get( Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -300,10 +361,22 @@ def get( ) try: if 200 <= _response.status_code < 300: - return typing.cast(GetPronunciationDictionaryMetadataResponse, construct_type(type_=GetPronunciationDictionaryMetadataResponse, object_=_response.json())) # type: ignore + return typing.cast( + GetPronunciationDictionaryMetadataResponse, + construct_type( + type_=GetPronunciationDictionaryMetadataResponse, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -338,7 +411,7 @@ def get_all( Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -350,15 +423,30 @@ def get_all( _response = self._client_wrapper.httpx_client.request( "v1/pronunciation-dictionaries/", method="GET", - params={"cursor": cursor, "page_size": page_size}, + params={ + "cursor": cursor, + "page_size": page_size, + }, request_options=request_options, ) try: if 200 <= _response.status_code < 300: - return typing.cast(GetPronunciationDictionariesMetadataResponseModel, construct_type(type_=GetPronunciationDictionariesMetadataResponseModel, object_=_response.json())) # type: ignore + return typing.cast( + GetPronunciationDictionariesMetadataResponseModel, + construct_type( + type_=GetPronunciationDictionariesMetadataResponseModel, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -408,7 +496,7 @@ async def add_from_file( -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -426,17 +514,35 @@ async def main() -> None: _response = await self._client_wrapper.httpx_client.request( "v1/pronunciation-dictionaries/add-from-file", method="POST", - data={"name": name, "description": description, "workspace_access": workspace_access}, - files={"file": file}, + data={ + "name": name, + "description": description, + "workspace_access": workspace_access, + }, + files={ + "file": file, + }, request_options=request_options, omit=OMIT, ) try: if 200 <= _response.status_code < 300: - return typing.cast(AddPronunciationDictionaryResponseModel, construct_type(type_=AddPronunciationDictionaryResponseModel, object_=_response.json())) # type: ignore + return typing.cast( + AddPronunciationDictionaryResponseModel, + construct_type( + type_=AddPronunciationDictionaryResponseModel, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -475,7 +581,10 @@ async def add_rules_to_the_pronunciation_dictionary( -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs + from elevenlabs.pronunciation_dictionary import ( + PronunciationDictionaryRule_Phoneme, + ) client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -485,7 +594,13 @@ async def add_rules_to_the_pronunciation_dictionary( async def main() -> None: await client.pronunciation_dictionary.add_rules_to_the_pronunciation_dictionary( pronunciation_dictionary_id="21m00Tcm4TlvDq8ikWAM", - rules=[], + rules=[ + PronunciationDictionaryRule_Phoneme( + string_to_replace="rules", + phoneme="rules", + alphabet="rules", + ) + ], ) @@ -494,16 +609,30 @@ async def main() -> None: _response = await self._client_wrapper.httpx_client.request( f"v1/pronunciation-dictionaries/{jsonable_encoder(pronunciation_dictionary_id)}/add-rules", method="POST", - json={"rules": rules}, + json={ + "rules": rules, + }, request_options=request_options, omit=OMIT, ) try: if 200 <= _response.status_code < 300: - return typing.cast(AddPronunciationDictionaryRulesResponseModel, construct_type(type_=AddPronunciationDictionaryRulesResponseModel, object_=_response.json())) # type: ignore + return typing.cast( + AddPronunciationDictionaryRulesResponseModel, + construct_type( + type_=AddPronunciationDictionaryRulesResponseModel, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -540,7 +669,7 @@ async def remove_rules_from_the_pronunciation_dictionary( -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -559,16 +688,30 @@ async def main() -> None: _response = await self._client_wrapper.httpx_client.request( f"v1/pronunciation-dictionaries/{jsonable_encoder(pronunciation_dictionary_id)}/remove-rules", method="POST", - json={"rule_strings": rule_strings}, + json={ + "rule_strings": rule_strings, + }, request_options=request_options, omit=OMIT, ) try: if 200 <= _response.status_code < 300: - return typing.cast(RemovePronunciationDictionaryRulesResponseModel, construct_type(type_=RemovePronunciationDictionaryRulesResponseModel, object_=_response.json())) # type: ignore + return typing.cast( + RemovePronunciationDictionaryRulesResponseModel, + construct_type( + type_=RemovePronunciationDictionaryRulesResponseModel, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -601,7 +744,7 @@ async def download( -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -627,7 +770,13 @@ async def main() -> None: return _response.text # type: ignore if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -657,7 +806,7 @@ async def get( -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -679,10 +828,22 @@ async def main() -> None: ) try: if 200 <= _response.status_code < 300: - return typing.cast(GetPronunciationDictionaryMetadataResponse, construct_type(type_=GetPronunciationDictionaryMetadataResponse, object_=_response.json())) # type: ignore + return typing.cast( + GetPronunciationDictionaryMetadataResponse, + construct_type( + type_=GetPronunciationDictionaryMetadataResponse, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -719,7 +880,7 @@ async def get_all( -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -737,15 +898,30 @@ async def main() -> None: _response = await self._client_wrapper.httpx_client.request( "v1/pronunciation-dictionaries/", method="GET", - params={"cursor": cursor, "page_size": page_size}, + params={ + "cursor": cursor, + "page_size": page_size, + }, request_options=request_options, ) try: if 200 <= _response.status_code < 300: - return typing.cast(GetPronunciationDictionariesMetadataResponseModel, construct_type(type_=GetPronunciationDictionariesMetadataResponseModel, object_=_response.json())) # type: ignore + return typing.cast( + GetPronunciationDictionariesMetadataResponseModel, + construct_type( + type_=GetPronunciationDictionariesMetadataResponseModel, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: diff --git a/src/elevenlabs/pronunciation_dictionary/types/pronunciation_dictionary_rule.py b/src/elevenlabs/pronunciation_dictionary/types/pronunciation_dictionary_rule.py index 4d83d9e..7d78ebf 100644 --- a/src/elevenlabs/pronunciation_dictionary/types/pronunciation_dictionary_rule.py +++ b/src/elevenlabs/pronunciation_dictionary/types/pronunciation_dictionary_rule.py @@ -1,20 +1,18 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - +from ...core.unchecked_base_model import UncheckedBaseModel import typing - +from ...core.pydantic_utilities import IS_PYDANTIC_V2 import pydantic import typing_extensions - -from ...core.pydantic_utilities import IS_PYDANTIC_V2 -from ...core.unchecked_base_model import UncheckedBaseModel, UnionMetadata +from ...core.unchecked_base_model import UnionMetadata class PronunciationDictionaryRule_Alias(UncheckedBaseModel): + type: typing.Literal["alias"] = "alias" string_to_replace: str alias: str - type: typing.Literal["alias"] = "alias" if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 @@ -27,10 +25,10 @@ class Config: class PronunciationDictionaryRule_Phoneme(UncheckedBaseModel): + type: typing.Literal["phoneme"] = "phoneme" string_to_replace: str phoneme: str alphabet: str - type: typing.Literal["phoneme"] = "phoneme" if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/src/elevenlabs/samples/client.py b/src/elevenlabs/samples/client.py index c5bd4f7..37a3598 100644 --- a/src/elevenlabs/samples/client.py +++ b/src/elevenlabs/samples/client.py @@ -1,15 +1,15 @@ # This file was auto-generated by Fern from our API Definition. +from ..core.client_wrapper import SyncClientWrapper import typing -from json.decoder import JSONDecodeError - -from ..core.api_error import ApiError -from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper -from ..core.jsonable_encoder import jsonable_encoder from ..core.request_options import RequestOptions +from ..core.jsonable_encoder import jsonable_encoder from ..core.unchecked_base_model import construct_type from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.http_validation_error import HttpValidationError +from json.decoder import JSONDecodeError +from ..core.api_error import ApiError +from ..core.client_wrapper import AsyncClientWrapper class SamplesClient: @@ -18,7 +18,7 @@ def __init__(self, *, client_wrapper: SyncClientWrapper): def delete( self, voice_id: str, sample_id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> typing.Any: + ) -> typing.Optional[typing.Any]: """ Removes a sample by its ID. @@ -35,12 +35,12 @@ def delete( Returns ------- - typing.Any + typing.Optional[typing.Any] Successful Response Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -57,10 +57,22 @@ def delete( ) try: if 200 <= _response.status_code < 300: - return typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + return typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -91,7 +103,7 @@ def get_audio( Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -114,7 +126,13 @@ def get_audio( _response.read() if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -128,7 +146,7 @@ def __init__(self, *, client_wrapper: AsyncClientWrapper): async def delete( self, voice_id: str, sample_id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> typing.Any: + ) -> typing.Optional[typing.Any]: """ Removes a sample by its ID. @@ -145,14 +163,14 @@ async def delete( Returns ------- - typing.Any + typing.Optional[typing.Any] Successful Response Examples -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -175,10 +193,22 @@ async def main() -> None: ) try: if 200 <= _response.status_code < 300: - return typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + return typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -211,7 +241,7 @@ async def get_audio( -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -240,7 +270,13 @@ async def main() -> None: await _response.aread() if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: diff --git a/src/elevenlabs/speech_to_speech/client.py b/src/elevenlabs/speech_to_speech/client.py index e6dbfff..ecd7cd4 100644 --- a/src/elevenlabs/speech_to_speech/client.py +++ b/src/elevenlabs/speech_to_speech/client.py @@ -1,18 +1,18 @@ # This file was auto-generated by Fern from our API Definition. import typing -from json.decoder import JSONDecodeError - +from ..core.client_wrapper import SyncClientWrapper from .. import core -from ..core.api_error import ApiError -from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper -from ..core.jsonable_encoder import jsonable_encoder +from ..types.optimize_streaming_latency import OptimizeStreamingLatency +from ..types.output_format import OutputFormat from ..core.request_options import RequestOptions -from ..core.unchecked_base_model import construct_type +from ..core.jsonable_encoder import jsonable_encoder from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.http_validation_error import HttpValidationError -from ..types.optimize_streaming_latency import OptimizeStreamingLatency -from ..types.output_format import OutputFormat +from ..core.unchecked_base_model import construct_type +from json.decoder import JSONDecodeError +from ..core.api_error import ApiError +from ..core.client_wrapper import AsyncClientWrapper # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -74,7 +74,7 @@ def convert( Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -94,8 +94,14 @@ def convert( "optimize_streaming_latency": optimize_streaming_latency, "output_format": output_format, }, - data={"model_id": model_id, "voice_settings": voice_settings, "seed": seed}, - files={"audio": audio}, + data={ + "model_id": model_id, + "voice_settings": voice_settings, + "seed": seed, + }, + files={ + "audio": audio, + }, request_options=request_options, omit=OMIT, ) as _response: @@ -107,7 +113,13 @@ def convert( _response.read() if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -177,7 +189,7 @@ def convert_as_stream( Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -197,8 +209,14 @@ def convert_as_stream( "optimize_streaming_latency": optimize_streaming_latency, "output_format": output_format, }, - data={"model_id": model_id, "voice_settings": voice_settings, "seed": seed}, - files={"audio": audio}, + data={ + "model_id": model_id, + "voice_settings": voice_settings, + "seed": seed, + }, + files={ + "audio": audio, + }, request_options=request_options, omit=OMIT, ) as _response: @@ -210,7 +228,13 @@ def convert_as_stream( _response.read() if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -276,7 +300,7 @@ async def convert( -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -302,8 +326,14 @@ async def main() -> None: "optimize_streaming_latency": optimize_streaming_latency, "output_format": output_format, }, - data={"model_id": model_id, "voice_settings": voice_settings, "seed": seed}, - files={"audio": audio}, + data={ + "model_id": model_id, + "voice_settings": voice_settings, + "seed": seed, + }, + files={ + "audio": audio, + }, request_options=request_options, omit=OMIT, ) as _response: @@ -315,7 +345,13 @@ async def main() -> None: await _response.aread() if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -387,7 +423,7 @@ async def convert_as_stream( -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -413,8 +449,14 @@ async def main() -> None: "optimize_streaming_latency": optimize_streaming_latency, "output_format": output_format, }, - data={"model_id": model_id, "voice_settings": voice_settings, "seed": seed}, - files={"audio": audio}, + data={ + "model_id": model_id, + "voice_settings": voice_settings, + "seed": seed, + }, + files={ + "audio": audio, + }, request_options=request_options, omit=OMIT, ) as _response: @@ -426,7 +468,13 @@ async def main() -> None: await _response.aread() if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: diff --git a/src/elevenlabs/text_to_sound_effects/client.py b/src/elevenlabs/text_to_sound_effects/client.py index 0c7e0ea..b9eb26d 100644 --- a/src/elevenlabs/text_to_sound_effects/client.py +++ b/src/elevenlabs/text_to_sound_effects/client.py @@ -1,14 +1,14 @@ # This file was auto-generated by Fern from our API Definition. import typing -from json.decoder import JSONDecodeError - -from ..core.api_error import ApiError -from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.client_wrapper import SyncClientWrapper from ..core.request_options import RequestOptions -from ..core.unchecked_base_model import construct_type from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.http_validation_error import HttpValidationError +from ..core.unchecked_base_model import construct_type +from json.decoder import JSONDecodeError +from ..core.api_error import ApiError +from ..core.client_wrapper import AsyncClientWrapper # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -24,7 +24,7 @@ def convert( text: str, duration_seconds: typing.Optional[float] = OMIT, prompt_influence: typing.Optional[float] = OMIT, - request_options: typing.Optional[RequestOptions] = None + request_options: typing.Optional[RequestOptions] = None, ) -> typing.Iterator[bytes]: """ Converts a text of your choice into sound @@ -50,7 +50,7 @@ def convert( Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -64,7 +64,11 @@ def convert( with self._client_wrapper.httpx_client.stream( "v1/sound-generation", method="POST", - json={"text": text, "duration_seconds": duration_seconds, "prompt_influence": prompt_influence}, + json={ + "text": text, + "duration_seconds": duration_seconds, + "prompt_influence": prompt_influence, + }, request_options=request_options, omit=OMIT, ) as _response: @@ -76,7 +80,13 @@ def convert( _response.read() if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -94,7 +104,7 @@ async def convert( text: str, duration_seconds: typing.Optional[float] = OMIT, prompt_influence: typing.Optional[float] = OMIT, - request_options: typing.Optional[RequestOptions] = None + request_options: typing.Optional[RequestOptions] = None, ) -> typing.AsyncIterator[bytes]: """ Converts a text of your choice into sound @@ -122,7 +132,7 @@ async def convert( -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -142,7 +152,11 @@ async def main() -> None: async with self._client_wrapper.httpx_client.stream( "v1/sound-generation", method="POST", - json={"text": text, "duration_seconds": duration_seconds, "prompt_influence": prompt_influence}, + json={ + "text": text, + "duration_seconds": duration_seconds, + "prompt_influence": prompt_influence, + }, request_options=request_options, omit=OMIT, ) as _response: @@ -154,7 +168,13 @@ async def main() -> None: await _response.aread() if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: diff --git a/src/elevenlabs/text_to_speech/client.py b/src/elevenlabs/text_to_speech/client.py index 3896b7e..e99fcf8 100644 --- a/src/elevenlabs/text_to_speech/client.py +++ b/src/elevenlabs/text_to_speech/client.py @@ -1,19 +1,19 @@ # This file was auto-generated by Fern from our API Definition. import typing -from json.decoder import JSONDecodeError - -from ..core.api_error import ApiError -from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper -from ..core.jsonable_encoder import jsonable_encoder -from ..core.request_options import RequestOptions -from ..core.unchecked_base_model import construct_type -from ..errors.unprocessable_entity_error import UnprocessableEntityError -from ..types.http_validation_error import HttpValidationError +from ..core.client_wrapper import SyncClientWrapper from ..types.optimize_streaming_latency import OptimizeStreamingLatency from ..types.output_format import OutputFormat -from ..types.pronunciation_dictionary_version_locator import PronunciationDictionaryVersionLocator from ..types.voice_settings import VoiceSettings +from ..types.pronunciation_dictionary_version_locator import PronunciationDictionaryVersionLocator +from ..core.request_options import RequestOptions +from ..core.jsonable_encoder import jsonable_encoder +from ..errors.unprocessable_entity_error import UnprocessableEntityError +from ..types.http_validation_error import HttpValidationError +from ..core.unchecked_base_model import construct_type +from json.decoder import JSONDecodeError +from ..core.api_error import ApiError +from ..core.client_wrapper import AsyncClientWrapper # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -101,8 +101,7 @@ def convert( Examples -------- - from elevenlabs import VoiceSettings - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs, VoiceSettings client = ElevenLabs( api_key="YOUR_API_KEY", @@ -150,7 +149,13 @@ def convert( _response.read() if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -177,7 +182,7 @@ def convert_with_timestamps( previous_request_ids: typing.Optional[typing.Sequence[str]] = OMIT, next_request_ids: typing.Optional[typing.Sequence[str]] = OMIT, request_options: typing.Optional[RequestOptions] = None, - ) -> typing.Any: + ) -> typing.Optional[typing.Any]: """ Converts text into speech using a voice of your choice and returns JSON containing audio as a base64 encoded string together with information on when which character was spoken. @@ -230,12 +235,12 @@ def convert_with_timestamps( Returns ------- - typing.Any + typing.Optional[typing.Any] Successful Response Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -270,10 +275,22 @@ def convert_with_timestamps( ) try: if 200 <= _response.status_code < 300: - return typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + return typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -358,8 +375,7 @@ def convert_as_stream( Examples -------- - from elevenlabs import VoiceSettings - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs, VoiceSettings client = ElevenLabs( api_key="YOUR_API_KEY", @@ -407,7 +423,13 @@ def convert_as_stream( _response.read() if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -491,7 +513,7 @@ def stream_with_timestamps( Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -529,7 +551,13 @@ def stream_with_timestamps( return if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -621,8 +649,7 @@ async def convert( -------- import asyncio - from elevenlabs import VoiceSettings - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs, VoiceSettings client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -676,7 +703,13 @@ async def main() -> None: await _response.aread() if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -703,7 +736,7 @@ async def convert_with_timestamps( previous_request_ids: typing.Optional[typing.Sequence[str]] = OMIT, next_request_ids: typing.Optional[typing.Sequence[str]] = OMIT, request_options: typing.Optional[RequestOptions] = None, - ) -> typing.Any: + ) -> typing.Optional[typing.Any]: """ Converts text into speech using a voice of your choice and returns JSON containing audio as a base64 encoded string together with information on when which character was spoken. @@ -756,14 +789,14 @@ async def convert_with_timestamps( Returns ------- - typing.Any + typing.Optional[typing.Any] Successful Response Examples -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -804,10 +837,22 @@ async def main() -> None: ) try: if 200 <= _response.status_code < 300: - return typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + return typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -894,8 +939,7 @@ async def convert_as_stream( -------- import asyncio - from elevenlabs import VoiceSettings - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs, VoiceSettings client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -949,7 +993,13 @@ async def main() -> None: await _response.aread() if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -1035,7 +1085,7 @@ async def stream_with_timestamps( -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -1079,7 +1129,13 @@ async def main() -> None: return if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: diff --git a/src/elevenlabs/text_to_speech/types/send_message.py b/src/elevenlabs/text_to_speech/types/send_message.py index 8ae3c83..d4d0d40 100644 --- a/src/elevenlabs/text_to_speech/types/send_message.py +++ b/src/elevenlabs/text_to_speech/types/send_message.py @@ -1,9 +1,8 @@ # This file was auto-generated by Fern from our API Definition. import typing - -from ...types.close_connection import CloseConnection from ...types.initialize_connection import InitializeConnection from ...types.send_text import SendText +from ...types.close_connection import CloseConnection SendMessage = typing.Union[InitializeConnection, SendText, CloseConnection] diff --git a/src/elevenlabs/types/add_project_response_model.py b/src/elevenlabs/types/add_project_response_model.py index b70dc3d..5e69fc8 100644 --- a/src/elevenlabs/types/add_project_response_model.py +++ b/src/elevenlabs/types/add_project_response_model.py @@ -1,12 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -import typing - -import pydantic - -from ..core.pydantic_utilities import IS_PYDANTIC_V2 from ..core.unchecked_base_model import UncheckedBaseModel from .project_response import ProjectResponse +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import typing +import pydantic class AddProjectResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/add_pronunciation_dictionary_response_model.py b/src/elevenlabs/types/add_pronunciation_dictionary_response_model.py index 5fd2ef1..ef0d7f0 100644 --- a/src/elevenlabs/types/add_pronunciation_dictionary_response_model.py +++ b/src/elevenlabs/types/add_pronunciation_dictionary_response_model.py @@ -1,11 +1,9 @@ # This file was auto-generated by Fern from our API Definition. +from ..core.unchecked_base_model import UncheckedBaseModel import typing - -import pydantic - from ..core.pydantic_utilities import IS_PYDANTIC_V2 -from ..core.unchecked_base_model import UncheckedBaseModel +import pydantic class AddPronunciationDictionaryResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/add_pronunciation_dictionary_rules_response_model.py b/src/elevenlabs/types/add_pronunciation_dictionary_rules_response_model.py index 1285916..bcd7ce8 100644 --- a/src/elevenlabs/types/add_pronunciation_dictionary_rules_response_model.py +++ b/src/elevenlabs/types/add_pronunciation_dictionary_rules_response_model.py @@ -1,12 +1,10 @@ # This file was auto-generated by Fern from our API Definition. +from ..core.unchecked_base_model import UncheckedBaseModel +from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing - import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -from ..core.unchecked_base_model import UncheckedBaseModel - class AddPronunciationDictionaryRulesResponseModel(UncheckedBaseModel): id: str diff --git a/src/elevenlabs/types/add_voice_response_model.py b/src/elevenlabs/types/add_voice_response_model.py index 918b36f..8a28541 100644 --- a/src/elevenlabs/types/add_voice_response_model.py +++ b/src/elevenlabs/types/add_voice_response_model.py @@ -1,12 +1,10 @@ # This file was auto-generated by Fern from our API Definition. +from ..core.unchecked_base_model import UncheckedBaseModel +from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing - import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -from ..core.unchecked_base_model import UncheckedBaseModel - class AddVoiceResponseModel(UncheckedBaseModel): voice_id: str diff --git a/src/elevenlabs/types/audio_native_create_project_response_model.py b/src/elevenlabs/types/audio_native_create_project_response_model.py index d47740b..5919e3b 100644 --- a/src/elevenlabs/types/audio_native_create_project_response_model.py +++ b/src/elevenlabs/types/audio_native_create_project_response_model.py @@ -1,12 +1,10 @@ # This file was auto-generated by Fern from our API Definition. +from ..core.unchecked_base_model import UncheckedBaseModel +from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing - import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -from ..core.unchecked_base_model import UncheckedBaseModel - class AudioNativeCreateProjectResponseModel(UncheckedBaseModel): project_id: str diff --git a/src/elevenlabs/types/audio_native_get_embed_code_response_model.py b/src/elevenlabs/types/audio_native_get_embed_code_response_model.py index e34ebe0..12c7038 100644 --- a/src/elevenlabs/types/audio_native_get_embed_code_response_model.py +++ b/src/elevenlabs/types/audio_native_get_embed_code_response_model.py @@ -2,4 +2,4 @@ import typing -AudioNativeGetEmbedCodeResponseModel = typing.Any +AudioNativeGetEmbedCodeResponseModel = typing.Optional[typing.Any] diff --git a/src/elevenlabs/types/audio_output.py b/src/elevenlabs/types/audio_output.py index 8a0fe69..96b96df 100644 --- a/src/elevenlabs/types/audio_output.py +++ b/src/elevenlabs/types/audio_output.py @@ -1,12 +1,10 @@ # This file was auto-generated by Fern from our API Definition. +from ..core.unchecked_base_model import UncheckedBaseModel import typing - import pydantic - -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -from ..core.unchecked_base_model import UncheckedBaseModel from .normalized_alignment import NormalizedAlignment +from ..core.pydantic_utilities import IS_PYDANTIC_V2 class AudioOutput(UncheckedBaseModel): diff --git a/src/elevenlabs/types/chapter_response.py b/src/elevenlabs/types/chapter_response.py index c33a479..1d3b652 100644 --- a/src/elevenlabs/types/chapter_response.py +++ b/src/elevenlabs/types/chapter_response.py @@ -1,13 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -import typing - -import pydantic - -from ..core.pydantic_utilities import IS_PYDANTIC_V2 from ..core.unchecked_base_model import UncheckedBaseModel from .chapter_state import ChapterState from .chapter_statistics_response import ChapterStatisticsResponse +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import typing +import pydantic class ChapterResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/chapter_snapshot_response.py b/src/elevenlabs/types/chapter_snapshot_response.py index b431e6c..c316c2e 100644 --- a/src/elevenlabs/types/chapter_snapshot_response.py +++ b/src/elevenlabs/types/chapter_snapshot_response.py @@ -1,12 +1,10 @@ # This file was auto-generated by Fern from our API Definition. +from ..core.unchecked_base_model import UncheckedBaseModel +from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing - import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -from ..core.unchecked_base_model import UncheckedBaseModel - class ChapterSnapshotResponse(UncheckedBaseModel): chapter_snapshot_id: str diff --git a/src/elevenlabs/types/chapter_snapshots_response.py b/src/elevenlabs/types/chapter_snapshots_response.py index dba4087..a40294c 100644 --- a/src/elevenlabs/types/chapter_snapshots_response.py +++ b/src/elevenlabs/types/chapter_snapshots_response.py @@ -1,12 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -import typing - -import pydantic - -from ..core.pydantic_utilities import IS_PYDANTIC_V2 from ..core.unchecked_base_model import UncheckedBaseModel +import typing from .chapter_snapshot_response import ChapterSnapshotResponse +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic class ChapterSnapshotsResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/chapter_statistics_response.py b/src/elevenlabs/types/chapter_statistics_response.py index 585b592..15f5f12 100644 --- a/src/elevenlabs/types/chapter_statistics_response.py +++ b/src/elevenlabs/types/chapter_statistics_response.py @@ -1,12 +1,10 @@ # This file was auto-generated by Fern from our API Definition. +from ..core.unchecked_base_model import UncheckedBaseModel +from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing - import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -from ..core.unchecked_base_model import UncheckedBaseModel - class ChapterStatisticsResponse(UncheckedBaseModel): characters_unconverted: int diff --git a/src/elevenlabs/types/close_connection.py b/src/elevenlabs/types/close_connection.py index 1d84fff..42a428f 100644 --- a/src/elevenlabs/types/close_connection.py +++ b/src/elevenlabs/types/close_connection.py @@ -1,11 +1,9 @@ # This file was auto-generated by Fern from our API Definition. +from ..core.unchecked_base_model import UncheckedBaseModel import typing - import pydantic - from ..core.pydantic_utilities import IS_PYDANTIC_V2 -from ..core.unchecked_base_model import UncheckedBaseModel class CloseConnection(UncheckedBaseModel): diff --git a/src/elevenlabs/types/do_dubbing_response.py b/src/elevenlabs/types/do_dubbing_response.py index 70e5834..3cc8e52 100644 --- a/src/elevenlabs/types/do_dubbing_response.py +++ b/src/elevenlabs/types/do_dubbing_response.py @@ -1,12 +1,10 @@ # This file was auto-generated by Fern from our API Definition. +from ..core.unchecked_base_model import UncheckedBaseModel +from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing - import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -from ..core.unchecked_base_model import UncheckedBaseModel - class DoDubbingResponse(UncheckedBaseModel): dubbing_id: str diff --git a/src/elevenlabs/types/dubbing_metadata_response.py b/src/elevenlabs/types/dubbing_metadata_response.py index 0ec21eb..d4652fb 100644 --- a/src/elevenlabs/types/dubbing_metadata_response.py +++ b/src/elevenlabs/types/dubbing_metadata_response.py @@ -1,11 +1,9 @@ # This file was auto-generated by Fern from our API Definition. +from ..core.unchecked_base_model import UncheckedBaseModel import typing - -import pydantic - from ..core.pydantic_utilities import IS_PYDANTIC_V2 -from ..core.unchecked_base_model import UncheckedBaseModel +import pydantic class DubbingMetadataResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/edit_project_response_model.py b/src/elevenlabs/types/edit_project_response_model.py index 21ab98b..62d0f6d 100644 --- a/src/elevenlabs/types/edit_project_response_model.py +++ b/src/elevenlabs/types/edit_project_response_model.py @@ -1,12 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -import typing - -import pydantic - -from ..core.pydantic_utilities import IS_PYDANTIC_V2 from ..core.unchecked_base_model import UncheckedBaseModel from .project_response import ProjectResponse +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import typing +import pydantic class EditProjectResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/feedback_item.py b/src/elevenlabs/types/feedback_item.py index 68b6307..ce85716 100644 --- a/src/elevenlabs/types/feedback_item.py +++ b/src/elevenlabs/types/feedback_item.py @@ -1,11 +1,9 @@ # This file was auto-generated by Fern from our API Definition. +from ..core.unchecked_base_model import UncheckedBaseModel import typing - -import pydantic - from ..core.pydantic_utilities import IS_PYDANTIC_V2 -from ..core.unchecked_base_model import UncheckedBaseModel +import pydantic class FeedbackItem(UncheckedBaseModel): diff --git a/src/elevenlabs/types/fine_tuning_response.py b/src/elevenlabs/types/fine_tuning_response.py index 9335a49..4bb159b 100644 --- a/src/elevenlabs/types/fine_tuning_response.py +++ b/src/elevenlabs/types/fine_tuning_response.py @@ -1,14 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -import typing - -import pydantic - -from ..core.pydantic_utilities import IS_PYDANTIC_V2 from ..core.unchecked_base_model import UncheckedBaseModel +import typing from .fine_tuning_response_model_state_value import FineTuningResponseModelStateValue -from .manual_verification_response import ManualVerificationResponse from .verification_attempt_response import VerificationAttemptResponse +from .manual_verification_response import ManualVerificationResponse +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic class FineTuningResponse(UncheckedBaseModel): @@ -24,7 +22,7 @@ class FineTuningResponse(UncheckedBaseModel): verification_attempts: typing.Optional[typing.List[VerificationAttemptResponse]] = None slice_ids: typing.Optional[typing.List[str]] = None manual_verification: typing.Optional[ManualVerificationResponse] = None - finetuning_state: typing.Optional[typing.Any] = None + finetuning_state: typing.Optional[typing.Optional[typing.Any]] = None if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/src/elevenlabs/types/generation_config.py b/src/elevenlabs/types/generation_config.py index f502fdb..8d5491a 100644 --- a/src/elevenlabs/types/generation_config.py +++ b/src/elevenlabs/types/generation_config.py @@ -1,11 +1,9 @@ # This file was auto-generated by Fern from our API Definition. +from ..core.unchecked_base_model import UncheckedBaseModel import typing - import pydantic - from ..core.pydantic_utilities import IS_PYDANTIC_V2 -from ..core.unchecked_base_model import UncheckedBaseModel class GenerationConfig(UncheckedBaseModel): diff --git a/src/elevenlabs/types/get_chapters_response.py b/src/elevenlabs/types/get_chapters_response.py index 9879418..f172dc0 100644 --- a/src/elevenlabs/types/get_chapters_response.py +++ b/src/elevenlabs/types/get_chapters_response.py @@ -1,12 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -import typing - -import pydantic - -from ..core.pydantic_utilities import IS_PYDANTIC_V2 from ..core.unchecked_base_model import UncheckedBaseModel +import typing from .chapter_response import ChapterResponse +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic class GetChaptersResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/get_library_voices_response.py b/src/elevenlabs/types/get_library_voices_response.py index fc6f107..7d2da37 100644 --- a/src/elevenlabs/types/get_library_voices_response.py +++ b/src/elevenlabs/types/get_library_voices_response.py @@ -1,12 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -import typing - -import pydantic - -from ..core.pydantic_utilities import IS_PYDANTIC_V2 from ..core.unchecked_base_model import UncheckedBaseModel +import typing from .library_voice_response import LibraryVoiceResponse +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic class GetLibraryVoicesResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/get_projects_response.py b/src/elevenlabs/types/get_projects_response.py index 584ec1b..d57558a 100644 --- a/src/elevenlabs/types/get_projects_response.py +++ b/src/elevenlabs/types/get_projects_response.py @@ -1,12 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -import typing - -import pydantic - -from ..core.pydantic_utilities import IS_PYDANTIC_V2 from ..core.unchecked_base_model import UncheckedBaseModel +import typing from .project_response import ProjectResponse +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic class GetProjectsResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/get_pronunciation_dictionaries_metadata_response_model.py b/src/elevenlabs/types/get_pronunciation_dictionaries_metadata_response_model.py index 7b7ebe7..2ed54ef 100644 --- a/src/elevenlabs/types/get_pronunciation_dictionaries_metadata_response_model.py +++ b/src/elevenlabs/types/get_pronunciation_dictionaries_metadata_response_model.py @@ -1,12 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -import typing - -import pydantic - -from ..core.pydantic_utilities import IS_PYDANTIC_V2 from ..core.unchecked_base_model import UncheckedBaseModel +import typing from .get_pronunciation_dictionary_metadata_response import GetPronunciationDictionaryMetadataResponse +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic class GetPronunciationDictionariesMetadataResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/get_pronunciation_dictionary_metadata_response.py b/src/elevenlabs/types/get_pronunciation_dictionary_metadata_response.py index 96d6368..c6fd50f 100644 --- a/src/elevenlabs/types/get_pronunciation_dictionary_metadata_response.py +++ b/src/elevenlabs/types/get_pronunciation_dictionary_metadata_response.py @@ -1,11 +1,9 @@ # This file was auto-generated by Fern from our API Definition. +from ..core.unchecked_base_model import UncheckedBaseModel import typing - -import pydantic - from ..core.pydantic_utilities import IS_PYDANTIC_V2 -from ..core.unchecked_base_model import UncheckedBaseModel +import pydantic class GetPronunciationDictionaryMetadataResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/get_speech_history_response.py b/src/elevenlabs/types/get_speech_history_response.py index ac5ec5d..2abe50b 100644 --- a/src/elevenlabs/types/get_speech_history_response.py +++ b/src/elevenlabs/types/get_speech_history_response.py @@ -1,12 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -import typing - -import pydantic - -from ..core.pydantic_utilities import IS_PYDANTIC_V2 from ..core.unchecked_base_model import UncheckedBaseModel +import typing from .speech_history_item_response import SpeechHistoryItemResponse +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic class GetSpeechHistoryResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/get_voices_response.py b/src/elevenlabs/types/get_voices_response.py index 40386f3..8a636c3 100644 --- a/src/elevenlabs/types/get_voices_response.py +++ b/src/elevenlabs/types/get_voices_response.py @@ -1,12 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -import typing - -import pydantic - -from ..core.pydantic_utilities import IS_PYDANTIC_V2 from ..core.unchecked_base_model import UncheckedBaseModel +import typing from .voice import Voice +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic class GetVoicesResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/history.py b/src/elevenlabs/types/history.py index 66aa038..b953234 100644 --- a/src/elevenlabs/types/history.py +++ b/src/elevenlabs/types/history.py @@ -2,4 +2,4 @@ import typing -History = typing.Any +History = typing.Optional[typing.Any] diff --git a/src/elevenlabs/types/history_alignment_response_model.py b/src/elevenlabs/types/history_alignment_response_model.py index 0ef1e93..f1d3878 100644 --- a/src/elevenlabs/types/history_alignment_response_model.py +++ b/src/elevenlabs/types/history_alignment_response_model.py @@ -1,11 +1,9 @@ # This file was auto-generated by Fern from our API Definition. +from ..core.unchecked_base_model import UncheckedBaseModel import typing - -import pydantic - from ..core.pydantic_utilities import IS_PYDANTIC_V2 -from ..core.unchecked_base_model import UncheckedBaseModel +import pydantic class HistoryAlignmentResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/history_alignments_response_model.py b/src/elevenlabs/types/history_alignments_response_model.py index 06a4c31..ca1d67b 100644 --- a/src/elevenlabs/types/history_alignments_response_model.py +++ b/src/elevenlabs/types/history_alignments_response_model.py @@ -1,12 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -import typing - -import pydantic - -from ..core.pydantic_utilities import IS_PYDANTIC_V2 from ..core.unchecked_base_model import UncheckedBaseModel from .history_alignment_response_model import HistoryAlignmentResponseModel +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import typing +import pydantic class HistoryAlignmentsResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/history_item.py b/src/elevenlabs/types/history_item.py index d72051d..56461eb 100644 --- a/src/elevenlabs/types/history_item.py +++ b/src/elevenlabs/types/history_item.py @@ -1,16 +1,14 @@ # This file was auto-generated by Fern from our API Definition. +from ..core.unchecked_base_model import UncheckedBaseModel import typing - -import pydantic - from ..core.pydantic_utilities import IS_PYDANTIC_V2 -from ..core.unchecked_base_model import UncheckedBaseModel +import pydantic class HistoryItem(UncheckedBaseModel): - state: typing.Optional[typing.Any] = None - voice_category: typing.Optional[typing.Any] = None + state: typing.Optional[typing.Optional[typing.Any]] = None + voice_category: typing.Optional[typing.Optional[typing.Any]] = None if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/src/elevenlabs/types/http_validation_error.py b/src/elevenlabs/types/http_validation_error.py index c25d740..5449e98 100644 --- a/src/elevenlabs/types/http_validation_error.py +++ b/src/elevenlabs/types/http_validation_error.py @@ -1,12 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -import typing - -import pydantic - -from ..core.pydantic_utilities import IS_PYDANTIC_V2 from ..core.unchecked_base_model import UncheckedBaseModel +import typing from .validation_error import ValidationError +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic class HttpValidationError(UncheckedBaseModel): diff --git a/src/elevenlabs/types/initialize_connection.py b/src/elevenlabs/types/initialize_connection.py index 16a7420..b3d7b45 100644 --- a/src/elevenlabs/types/initialize_connection.py +++ b/src/elevenlabs/types/initialize_connection.py @@ -1,13 +1,11 @@ # This file was auto-generated by Fern from our API Definition. +from ..core.unchecked_base_model import UncheckedBaseModel import typing - import pydantic - -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -from ..core.unchecked_base_model import UncheckedBaseModel -from .generation_config import GenerationConfig from .realtime_voice_settings import RealtimeVoiceSettings +from .generation_config import GenerationConfig +from ..core.pydantic_utilities import IS_PYDANTIC_V2 class InitializeConnection(UncheckedBaseModel): diff --git a/src/elevenlabs/types/invoice.py b/src/elevenlabs/types/invoice.py index b7d8364..c2e6675 100644 --- a/src/elevenlabs/types/invoice.py +++ b/src/elevenlabs/types/invoice.py @@ -1,12 +1,10 @@ # This file was auto-generated by Fern from our API Definition. +from ..core.unchecked_base_model import UncheckedBaseModel +from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing - import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -from ..core.unchecked_base_model import UncheckedBaseModel - class Invoice(UncheckedBaseModel): amount_due_cents: int diff --git a/src/elevenlabs/types/language_response.py b/src/elevenlabs/types/language_response.py index e5837bf..deac624 100644 --- a/src/elevenlabs/types/language_response.py +++ b/src/elevenlabs/types/language_response.py @@ -1,12 +1,10 @@ # This file was auto-generated by Fern from our API Definition. +from ..core.unchecked_base_model import UncheckedBaseModel +from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing - import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -from ..core.unchecked_base_model import UncheckedBaseModel - class LanguageResponse(UncheckedBaseModel): language_id: str diff --git a/src/elevenlabs/types/library_voice_response.py b/src/elevenlabs/types/library_voice_response.py index dfd5022..531e9bf 100644 --- a/src/elevenlabs/types/library_voice_response.py +++ b/src/elevenlabs/types/library_voice_response.py @@ -1,11 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -import typing - +from ..core.unchecked_base_model import UncheckedBaseModel import pydantic - +import typing from ..core.pydantic_utilities import IS_PYDANTIC_V2 -from ..core.unchecked_base_model import UncheckedBaseModel class LibraryVoiceResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/manual_verification_file_response.py b/src/elevenlabs/types/manual_verification_file_response.py index db3f391..dcf0855 100644 --- a/src/elevenlabs/types/manual_verification_file_response.py +++ b/src/elevenlabs/types/manual_verification_file_response.py @@ -1,12 +1,10 @@ # This file was auto-generated by Fern from our API Definition. +from ..core.unchecked_base_model import UncheckedBaseModel +from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing - import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -from ..core.unchecked_base_model import UncheckedBaseModel - class ManualVerificationFileResponse(UncheckedBaseModel): file_id: str diff --git a/src/elevenlabs/types/manual_verification_response.py b/src/elevenlabs/types/manual_verification_response.py index 2da5c5d..1f92302 100644 --- a/src/elevenlabs/types/manual_verification_response.py +++ b/src/elevenlabs/types/manual_verification_response.py @@ -1,12 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -import typing - -import pydantic - -from ..core.pydantic_utilities import IS_PYDANTIC_V2 from ..core.unchecked_base_model import UncheckedBaseModel +import typing from .manual_verification_file_response import ManualVerificationFileResponse +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic class ManualVerificationResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/model.py b/src/elevenlabs/types/model.py index d6da8f1..11545b1 100644 --- a/src/elevenlabs/types/model.py +++ b/src/elevenlabs/types/model.py @@ -1,12 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -import typing - -import pydantic - -from ..core.pydantic_utilities import IS_PYDANTIC_V2 from ..core.unchecked_base_model import UncheckedBaseModel +import typing from .language_response import LanguageResponse +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic class Model(UncheckedBaseModel): diff --git a/src/elevenlabs/types/normalized_alignment.py b/src/elevenlabs/types/normalized_alignment.py index 52a942e..cac3e0c 100644 --- a/src/elevenlabs/types/normalized_alignment.py +++ b/src/elevenlabs/types/normalized_alignment.py @@ -1,11 +1,9 @@ # This file was auto-generated by Fern from our API Definition. +from ..core.unchecked_base_model import UncheckedBaseModel import typing - import pydantic - from ..core.pydantic_utilities import IS_PYDANTIC_V2 -from ..core.unchecked_base_model import UncheckedBaseModel class NormalizedAlignment(UncheckedBaseModel): diff --git a/src/elevenlabs/types/profile_page_response_model.py b/src/elevenlabs/types/profile_page_response_model.py index 15d3fef..a3afb2c 100644 --- a/src/elevenlabs/types/profile_page_response_model.py +++ b/src/elevenlabs/types/profile_page_response_model.py @@ -1,12 +1,10 @@ # This file was auto-generated by Fern from our API Definition. +from ..core.unchecked_base_model import UncheckedBaseModel +from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing - import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -from ..core.unchecked_base_model import UncheckedBaseModel - class ProfilePageResponseModel(UncheckedBaseModel): handle: str diff --git a/src/elevenlabs/types/project_extended_response_model.py b/src/elevenlabs/types/project_extended_response_model.py index fb44f70..847f5d2 100644 --- a/src/elevenlabs/types/project_extended_response_model.py +++ b/src/elevenlabs/types/project_extended_response_model.py @@ -1,13 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -import typing - -import pydantic - -from ..core.pydantic_utilities import IS_PYDANTIC_V2 from ..core.unchecked_base_model import UncheckedBaseModel -from .chapter_response import ChapterResponse from .project_state import ProjectState +import typing +from .chapter_response import ChapterResponse +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic class ProjectExtendedResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/project_response.py b/src/elevenlabs/types/project_response.py index 590f5b3..735032d 100644 --- a/src/elevenlabs/types/project_response.py +++ b/src/elevenlabs/types/project_response.py @@ -1,12 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -import typing - -import pydantic - -from ..core.pydantic_utilities import IS_PYDANTIC_V2 from ..core.unchecked_base_model import UncheckedBaseModel from .project_state import ProjectState +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import typing +import pydantic class ProjectResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/project_snapshot_response.py b/src/elevenlabs/types/project_snapshot_response.py index 8faa50c..c11a98d 100644 --- a/src/elevenlabs/types/project_snapshot_response.py +++ b/src/elevenlabs/types/project_snapshot_response.py @@ -1,12 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -import typing - -import pydantic - -from ..core.pydantic_utilities import IS_PYDANTIC_V2 from ..core.unchecked_base_model import UncheckedBaseModel +import typing from .project_snapshot_upload_response_model import ProjectSnapshotUploadResponseModel +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic class ProjectSnapshotResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/project_snapshot_upload_response_model.py b/src/elevenlabs/types/project_snapshot_upload_response_model.py index cb914d9..58493d0 100644 --- a/src/elevenlabs/types/project_snapshot_upload_response_model.py +++ b/src/elevenlabs/types/project_snapshot_upload_response_model.py @@ -1,12 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -import typing - -import pydantic - -from ..core.pydantic_utilities import IS_PYDANTIC_V2 from ..core.unchecked_base_model import UncheckedBaseModel from .status import Status +import typing +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic class ProjectSnapshotUploadResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/project_snapshots_response.py b/src/elevenlabs/types/project_snapshots_response.py index fe97e57..44dab72 100644 --- a/src/elevenlabs/types/project_snapshots_response.py +++ b/src/elevenlabs/types/project_snapshots_response.py @@ -1,12 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -import typing - -import pydantic - -from ..core.pydantic_utilities import IS_PYDANTIC_V2 from ..core.unchecked_base_model import UncheckedBaseModel +import typing from .project_snapshot_response import ProjectSnapshotResponse +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic class ProjectSnapshotsResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/pronunciation_dictionary_alias_rule_request_model.py b/src/elevenlabs/types/pronunciation_dictionary_alias_rule_request_model.py index d4963c5..f9e6424 100644 --- a/src/elevenlabs/types/pronunciation_dictionary_alias_rule_request_model.py +++ b/src/elevenlabs/types/pronunciation_dictionary_alias_rule_request_model.py @@ -1,12 +1,10 @@ # This file was auto-generated by Fern from our API Definition. +from ..core.unchecked_base_model import UncheckedBaseModel +from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing - import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -from ..core.unchecked_base_model import UncheckedBaseModel - class PronunciationDictionaryAliasRuleRequestModel(UncheckedBaseModel): string_to_replace: str diff --git a/src/elevenlabs/types/pronunciation_dictionary_phoneme_rule_request_model.py b/src/elevenlabs/types/pronunciation_dictionary_phoneme_rule_request_model.py index 84ed1c6..ed2b7fa 100644 --- a/src/elevenlabs/types/pronunciation_dictionary_phoneme_rule_request_model.py +++ b/src/elevenlabs/types/pronunciation_dictionary_phoneme_rule_request_model.py @@ -1,12 +1,10 @@ # This file was auto-generated by Fern from our API Definition. +from ..core.unchecked_base_model import UncheckedBaseModel +from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing - import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -from ..core.unchecked_base_model import UncheckedBaseModel - class PronunciationDictionaryPhonemeRuleRequestModel(UncheckedBaseModel): string_to_replace: str diff --git a/src/elevenlabs/types/pronunciation_dictionary_version_locator.py b/src/elevenlabs/types/pronunciation_dictionary_version_locator.py index 20737e8..eb806b4 100644 --- a/src/elevenlabs/types/pronunciation_dictionary_version_locator.py +++ b/src/elevenlabs/types/pronunciation_dictionary_version_locator.py @@ -1,12 +1,10 @@ # This file was auto-generated by Fern from our API Definition. +from ..core.unchecked_base_model import UncheckedBaseModel +from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing - import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -from ..core.unchecked_base_model import UncheckedBaseModel - class PronunciationDictionaryVersionLocator(UncheckedBaseModel): pronunciation_dictionary_id: str diff --git a/src/elevenlabs/types/realtime_voice_settings.py b/src/elevenlabs/types/realtime_voice_settings.py index 6546594..983efc5 100644 --- a/src/elevenlabs/types/realtime_voice_settings.py +++ b/src/elevenlabs/types/realtime_voice_settings.py @@ -1,11 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -import typing - +from ..core.unchecked_base_model import UncheckedBaseModel import pydantic - +import typing from ..core.pydantic_utilities import IS_PYDANTIC_V2 -from ..core.unchecked_base_model import UncheckedBaseModel class RealtimeVoiceSettings(UncheckedBaseModel): diff --git a/src/elevenlabs/types/recording_response.py b/src/elevenlabs/types/recording_response.py index 7816e88..03034c0 100644 --- a/src/elevenlabs/types/recording_response.py +++ b/src/elevenlabs/types/recording_response.py @@ -1,12 +1,10 @@ # This file was auto-generated by Fern from our API Definition. +from ..core.unchecked_base_model import UncheckedBaseModel +from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing - import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -from ..core.unchecked_base_model import UncheckedBaseModel - class RecordingResponse(UncheckedBaseModel): recording_id: str diff --git a/src/elevenlabs/types/remove_pronunciation_dictionary_rules_response_model.py b/src/elevenlabs/types/remove_pronunciation_dictionary_rules_response_model.py index 725a6df..d2f4fe3 100644 --- a/src/elevenlabs/types/remove_pronunciation_dictionary_rules_response_model.py +++ b/src/elevenlabs/types/remove_pronunciation_dictionary_rules_response_model.py @@ -1,12 +1,10 @@ # This file was auto-generated by Fern from our API Definition. +from ..core.unchecked_base_model import UncheckedBaseModel +from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing - import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -from ..core.unchecked_base_model import UncheckedBaseModel - class RemovePronunciationDictionaryRulesResponseModel(UncheckedBaseModel): id: str diff --git a/src/elevenlabs/types/send_text.py b/src/elevenlabs/types/send_text.py index 90e592b..e1a391e 100644 --- a/src/elevenlabs/types/send_text.py +++ b/src/elevenlabs/types/send_text.py @@ -1,11 +1,9 @@ # This file was auto-generated by Fern from our API Definition. +from ..core.unchecked_base_model import UncheckedBaseModel import typing - import pydantic - from ..core.pydantic_utilities import IS_PYDANTIC_V2 -from ..core.unchecked_base_model import UncheckedBaseModel class SendText(UncheckedBaseModel): diff --git a/src/elevenlabs/types/speech_history_item_response.py b/src/elevenlabs/types/speech_history_item_response.py index 2976cd3..21addda 100644 --- a/src/elevenlabs/types/speech_history_item_response.py +++ b/src/elevenlabs/types/speech_history_item_response.py @@ -1,15 +1,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing - -import pydantic - -from ..core.pydantic_utilities import IS_PYDANTIC_V2 from ..core.unchecked_base_model import UncheckedBaseModel +import typing +from .speech_history_item_response_model_voice_category import SpeechHistoryItemResponseModelVoiceCategory from .feedback_item import FeedbackItem -from .history_alignments_response_model import HistoryAlignmentsResponseModel from .source import Source -from .speech_history_item_response_model_voice_category import SpeechHistoryItemResponseModelVoiceCategory +from .history_alignments_response_model import HistoryAlignmentsResponseModel +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic class SpeechHistoryItemResponse(UncheckedBaseModel): @@ -24,8 +22,8 @@ class SpeechHistoryItemResponse(UncheckedBaseModel): character_count_change_from: typing.Optional[int] = None character_count_change_to: typing.Optional[int] = None content_type: typing.Optional[str] = None - state: typing.Optional[typing.Any] = None - settings: typing.Optional[typing.Dict[str, typing.Any]] = None + state: typing.Optional[typing.Optional[typing.Any]] = None + settings: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None feedback: typing.Optional[FeedbackItem] = None share_link_id: typing.Optional[str] = None source: typing.Optional[Source] = None diff --git a/src/elevenlabs/types/sso_provider_response_model.py b/src/elevenlabs/types/sso_provider_response_model.py index fd2f749..ee15827 100644 --- a/src/elevenlabs/types/sso_provider_response_model.py +++ b/src/elevenlabs/types/sso_provider_response_model.py @@ -1,12 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -import typing - -import pydantic - -from ..core.pydantic_utilities import IS_PYDANTIC_V2 from ..core.unchecked_base_model import UncheckedBaseModel from .sso_provider_response_model_provider_type import SsoProviderResponseModelProviderType +import typing +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic class SsoProviderResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/subscription.py b/src/elevenlabs/types/subscription.py index 9330605..a89f632 100644 --- a/src/elevenlabs/types/subscription.py +++ b/src/elevenlabs/types/subscription.py @@ -1,18 +1,16 @@ # This file was auto-generated by Fern from our API Definition. -import typing - -import pydantic - -from ..core.pydantic_utilities import IS_PYDANTIC_V2 from ..core.unchecked_base_model import UncheckedBaseModel +import typing from .currency import Currency +from .subscription_status import SubscriptionStatus from .extended_subscription_response_model_billing_period import ExtendedSubscriptionResponseModelBillingPeriod from .extended_subscription_response_model_character_refresh_period import ( ExtendedSubscriptionResponseModelCharacterRefreshPeriod, ) from .invoice import Invoice -from .subscription_status import SubscriptionStatus +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic class Subscription(UncheckedBaseModel): diff --git a/src/elevenlabs/types/subscription_response.py b/src/elevenlabs/types/subscription_response.py index 0115fb4..0513a81 100644 --- a/src/elevenlabs/types/subscription_response.py +++ b/src/elevenlabs/types/subscription_response.py @@ -1,15 +1,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing - -import pydantic - -from ..core.pydantic_utilities import IS_PYDANTIC_V2 from ..core.unchecked_base_model import UncheckedBaseModel from .currency import Currency +from .subscription_status import SubscriptionStatus from .subscription_response_model_billing_period import SubscriptionResponseModelBillingPeriod from .subscription_response_model_character_refresh_period import SubscriptionResponseModelCharacterRefreshPeriod -from .subscription_status import SubscriptionStatus +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import typing +import pydantic class SubscriptionResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/text_to_speech_as_stream_request.py b/src/elevenlabs/types/text_to_speech_as_stream_request.py index dd317b5..771e051 100644 --- a/src/elevenlabs/types/text_to_speech_as_stream_request.py +++ b/src/elevenlabs/types/text_to_speech_as_stream_request.py @@ -2,4 +2,4 @@ import typing -TextToSpeechAsStreamRequest = typing.Any +TextToSpeechAsStreamRequest = typing.Optional[typing.Any] diff --git a/src/elevenlabs/types/usage_characters_response_model.py b/src/elevenlabs/types/usage_characters_response_model.py index 86ee859..b817152 100644 --- a/src/elevenlabs/types/usage_characters_response_model.py +++ b/src/elevenlabs/types/usage_characters_response_model.py @@ -1,11 +1,9 @@ # This file was auto-generated by Fern from our API Definition. +from ..core.unchecked_base_model import UncheckedBaseModel import typing - -import pydantic - from ..core.pydantic_utilities import IS_PYDANTIC_V2 -from ..core.unchecked_base_model import UncheckedBaseModel +import pydantic class UsageCharactersResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/user.py b/src/elevenlabs/types/user.py index 208382d..df7839d 100644 --- a/src/elevenlabs/types/user.py +++ b/src/elevenlabs/types/user.py @@ -1,12 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -import typing - -import pydantic - -from ..core.pydantic_utilities import IS_PYDANTIC_V2 from ..core.unchecked_base_model import UncheckedBaseModel from .subscription_response import SubscriptionResponse +import typing +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic class User(UncheckedBaseModel): diff --git a/src/elevenlabs/types/validation_error.py b/src/elevenlabs/types/validation_error.py index f666a9e..72b616e 100644 --- a/src/elevenlabs/types/validation_error.py +++ b/src/elevenlabs/types/validation_error.py @@ -1,12 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -import typing - -import pydantic - -from ..core.pydantic_utilities import IS_PYDANTIC_V2 from ..core.unchecked_base_model import UncheckedBaseModel +import typing from .validation_error_loc_item import ValidationErrorLocItem +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic class ValidationError(UncheckedBaseModel): diff --git a/src/elevenlabs/types/verification_attempt_response.py b/src/elevenlabs/types/verification_attempt_response.py index 3ae23c3..3d4e06f 100644 --- a/src/elevenlabs/types/verification_attempt_response.py +++ b/src/elevenlabs/types/verification_attempt_response.py @@ -1,12 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -import typing - -import pydantic - -from ..core.pydantic_utilities import IS_PYDANTIC_V2 from ..core.unchecked_base_model import UncheckedBaseModel +import typing from .recording_response import RecordingResponse +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic class VerificationAttemptResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/voice.py b/src/elevenlabs/types/voice.py index e36e082..f3d1e57 100644 --- a/src/elevenlabs/types/voice.py +++ b/src/elevenlabs/types/voice.py @@ -1,17 +1,15 @@ # This file was auto-generated by Fern from our API Definition. -import typing - -import pydantic - -from ..core.pydantic_utilities import IS_PYDANTIC_V2 from ..core.unchecked_base_model import UncheckedBaseModel -from .fine_tuning_response import FineTuningResponse -from .voice_response_model_safety_control import VoiceResponseModelSafetyControl +import typing from .voice_sample import VoiceSample +from .fine_tuning_response import FineTuningResponse from .voice_settings import VoiceSettings from .voice_sharing_response import VoiceSharingResponse +from .voice_response_model_safety_control import VoiceResponseModelSafetyControl from .voice_verification_response import VoiceVerificationResponse +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic class Voice(UncheckedBaseModel): diff --git a/src/elevenlabs/types/voice_generation_parameter_option_response.py b/src/elevenlabs/types/voice_generation_parameter_option_response.py index ba188db..d445319 100644 --- a/src/elevenlabs/types/voice_generation_parameter_option_response.py +++ b/src/elevenlabs/types/voice_generation_parameter_option_response.py @@ -1,12 +1,10 @@ # This file was auto-generated by Fern from our API Definition. +from ..core.unchecked_base_model import UncheckedBaseModel +from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing - import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -from ..core.unchecked_base_model import UncheckedBaseModel - class VoiceGenerationParameterOptionResponse(UncheckedBaseModel): name: str diff --git a/src/elevenlabs/types/voice_generation_parameter_response.py b/src/elevenlabs/types/voice_generation_parameter_response.py index 8698803..6b19d77 100644 --- a/src/elevenlabs/types/voice_generation_parameter_response.py +++ b/src/elevenlabs/types/voice_generation_parameter_response.py @@ -1,12 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -import typing - -import pydantic - -from ..core.pydantic_utilities import IS_PYDANTIC_V2 from ..core.unchecked_base_model import UncheckedBaseModel +import typing from .voice_generation_parameter_option_response import VoiceGenerationParameterOptionResponse +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic class VoiceGenerationParameterResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/voice_sample.py b/src/elevenlabs/types/voice_sample.py index 9b23444..6a6b443 100644 --- a/src/elevenlabs/types/voice_sample.py +++ b/src/elevenlabs/types/voice_sample.py @@ -1,11 +1,9 @@ # This file was auto-generated by Fern from our API Definition. +from ..core.unchecked_base_model import UncheckedBaseModel import typing - -import pydantic - from ..core.pydantic_utilities import IS_PYDANTIC_V2 -from ..core.unchecked_base_model import UncheckedBaseModel +import pydantic class VoiceSample(UncheckedBaseModel): diff --git a/src/elevenlabs/types/voice_settings.py b/src/elevenlabs/types/voice_settings.py index d4dcf44..6b6ffd1 100644 --- a/src/elevenlabs/types/voice_settings.py +++ b/src/elevenlabs/types/voice_settings.py @@ -1,11 +1,9 @@ # This file was auto-generated by Fern from our API Definition. +from ..core.unchecked_base_model import UncheckedBaseModel import typing - -import pydantic - from ..core.pydantic_utilities import IS_PYDANTIC_V2 -from ..core.unchecked_base_model import UncheckedBaseModel +import pydantic class VoiceSettings(UncheckedBaseModel): diff --git a/src/elevenlabs/types/voice_sharing_response.py b/src/elevenlabs/types/voice_sharing_response.py index 40cf115..beb346c 100644 --- a/src/elevenlabs/types/voice_sharing_response.py +++ b/src/elevenlabs/types/voice_sharing_response.py @@ -1,14 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -import typing - -import pydantic - -from ..core.pydantic_utilities import IS_PYDANTIC_V2 from ..core.unchecked_base_model import UncheckedBaseModel +import typing +from .voice_sharing_state import VoiceSharingState from .category import Category from .review_status import ReviewStatus -from .voice_sharing_state import VoiceSharingState +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic class VoiceSharingResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/voice_verification_response.py b/src/elevenlabs/types/voice_verification_response.py index 2080cc7..2a18aaa 100644 --- a/src/elevenlabs/types/voice_verification_response.py +++ b/src/elevenlabs/types/voice_verification_response.py @@ -1,12 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -import typing - -import pydantic - -from ..core.pydantic_utilities import IS_PYDANTIC_V2 from ..core.unchecked_base_model import UncheckedBaseModel +import typing from .verification_attempt_response import VerificationAttemptResponse +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic class VoiceVerificationResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/usage/client.py b/src/elevenlabs/usage/client.py index 9f650c3..a6c7558 100644 --- a/src/elevenlabs/usage/client.py +++ b/src/elevenlabs/usage/client.py @@ -1,18 +1,18 @@ # This file was auto-generated by Fern from our API Definition. +from ..core.client_wrapper import SyncClientWrapper import typing -from json.decoder import JSONDecodeError - -from ..core.api_error import ApiError -from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from .types.usage_get_characters_usage_metrics_request_breakdown_type import ( + UsageGetCharactersUsageMetricsRequestBreakdownType, +) from ..core.request_options import RequestOptions +from ..types.usage_characters_response_model import UsageCharactersResponseModel from ..core.unchecked_base_model import construct_type from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.http_validation_error import HttpValidationError -from ..types.usage_characters_response_model import UsageCharactersResponseModel -from .types.usage_get_characters_usage_metrics_request_breakdown_type import ( - UsageGetCharactersUsageMetricsRequestBreakdownType, -) +from json.decoder import JSONDecodeError +from ..core.api_error import ApiError +from ..core.client_wrapper import AsyncClientWrapper class UsageClient: @@ -26,7 +26,7 @@ def get_characters_usage_metrics( end_unix: int, include_workspace_metrics: typing.Optional[bool] = None, breakdown_type: typing.Optional[UsageGetCharactersUsageMetricsRequestBreakdownType] = None, - request_options: typing.Optional[RequestOptions] = None + request_options: typing.Optional[RequestOptions] = None, ) -> UsageCharactersResponseModel: """ Returns the characters usage metrics for the current user or the entire workspace they are part of. The response will return a time axis with unix timestamps for each day and daily usage along that axis. The usage will be broken down by the specified breakdown type. For example, breakdown type "voice" will return the usage of each voice along the time axis. @@ -55,7 +55,7 @@ def get_characters_usage_metrics( Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -78,10 +78,22 @@ def get_characters_usage_metrics( ) try: if 200 <= _response.status_code < 300: - return typing.cast(UsageCharactersResponseModel, construct_type(type_=UsageCharactersResponseModel, object_=_response.json())) # type: ignore + return typing.cast( + UsageCharactersResponseModel, + construct_type( + type_=UsageCharactersResponseModel, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -100,7 +112,7 @@ async def get_characters_usage_metrics( end_unix: int, include_workspace_metrics: typing.Optional[bool] = None, breakdown_type: typing.Optional[UsageGetCharactersUsageMetricsRequestBreakdownType] = None, - request_options: typing.Optional[RequestOptions] = None + request_options: typing.Optional[RequestOptions] = None, ) -> UsageCharactersResponseModel: """ Returns the characters usage metrics for the current user or the entire workspace they are part of. The response will return a time axis with unix timestamps for each day and daily usage along that axis. The usage will be broken down by the specified breakdown type. For example, breakdown type "voice" will return the usage of each voice along the time axis. @@ -131,7 +143,7 @@ async def get_characters_usage_metrics( -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -160,10 +172,22 @@ async def main() -> None: ) try: if 200 <= _response.status_code < 300: - return typing.cast(UsageCharactersResponseModel, construct_type(type_=UsageCharactersResponseModel, object_=_response.json())) # type: ignore + return typing.cast( + UsageCharactersResponseModel, + construct_type( + type_=UsageCharactersResponseModel, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: diff --git a/src/elevenlabs/user/client.py b/src/elevenlabs/user/client.py index fc63c48..867f472 100644 --- a/src/elevenlabs/user/client.py +++ b/src/elevenlabs/user/client.py @@ -1,16 +1,16 @@ # This file was auto-generated by Fern from our API Definition. +from ..core.client_wrapper import SyncClientWrapper import typing -from json.decoder import JSONDecodeError - -from ..core.api_error import ApiError -from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.request_options import RequestOptions +from ..types.subscription import Subscription from ..core.unchecked_base_model import construct_type from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.http_validation_error import HttpValidationError -from ..types.subscription import Subscription +from json.decoder import JSONDecodeError +from ..core.api_error import ApiError from ..types.user import User +from ..core.client_wrapper import AsyncClientWrapper class UserClient: @@ -33,7 +33,7 @@ def get_subscription(self, *, request_options: typing.Optional[RequestOptions] = Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -41,14 +41,28 @@ def get_subscription(self, *, request_options: typing.Optional[RequestOptions] = client.user.get_subscription() """ _response = self._client_wrapper.httpx_client.request( - "v1/user/subscription", method="GET", request_options=request_options + "v1/user/subscription", + method="GET", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: - return typing.cast(Subscription, construct_type(type_=Subscription, object_=_response.json())) # type: ignore + return typing.cast( + Subscription, + construct_type( + type_=Subscription, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -71,20 +85,36 @@ def get(self, *, request_options: typing.Optional[RequestOptions] = None) -> Use Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) client.user.get() """ - _response = self._client_wrapper.httpx_client.request("v1/user", method="GET", request_options=request_options) + _response = self._client_wrapper.httpx_client.request( + "v1/user", + method="GET", + request_options=request_options, + ) try: if 200 <= _response.status_code < 300: - return typing.cast(User, construct_type(type_=User, object_=_response.json())) # type: ignore + return typing.cast( + User, + construct_type( + type_=User, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -114,7 +144,7 @@ async def get_subscription(self, *, request_options: typing.Optional[RequestOpti -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -128,14 +158,28 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - "v1/user/subscription", method="GET", request_options=request_options + "v1/user/subscription", + method="GET", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: - return typing.cast(Subscription, construct_type(type_=Subscription, object_=_response.json())) # type: ignore + return typing.cast( + Subscription, + construct_type( + type_=Subscription, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -160,7 +204,7 @@ async def get(self, *, request_options: typing.Optional[RequestOptions] = None) -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -174,14 +218,28 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - "v1/user", method="GET", request_options=request_options + "v1/user", + method="GET", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: - return typing.cast(User, construct_type(type_=User, object_=_response.json())) # type: ignore + return typing.cast( + User, + construct_type( + type_=User, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: diff --git a/src/elevenlabs/version.py b/src/elevenlabs/version.py index 5bab9a4..d337e9e 100644 --- a/src/elevenlabs/version.py +++ b/src/elevenlabs/version.py @@ -1,4 +1,3 @@ - from importlib import metadata __version__ = metadata.version("elevenlabs") diff --git a/src/elevenlabs/voice_generation/client.py b/src/elevenlabs/voice_generation/client.py index f578232..d02804a 100644 --- a/src/elevenlabs/voice_generation/client.py +++ b/src/elevenlabs/voice_generation/client.py @@ -1,18 +1,18 @@ # This file was auto-generated by Fern from our API Definition. import typing -from json.decoder import JSONDecodeError - -from ..core.api_error import ApiError -from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.client_wrapper import SyncClientWrapper from ..core.request_options import RequestOptions +from ..types.voice_generation_parameter_response import VoiceGenerationParameterResponse from ..core.unchecked_base_model import construct_type -from ..errors.unprocessable_entity_error import UnprocessableEntityError -from ..types.age import Age +from json.decoder import JSONDecodeError +from ..core.api_error import ApiError from ..types.gender import Gender +from ..types.age import Age +from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.http_validation_error import HttpValidationError from ..types.voice import Voice -from ..types.voice_generation_parameter_response import VoiceGenerationParameterResponse +from ..core.client_wrapper import AsyncClientWrapper # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -40,7 +40,7 @@ def generate_parameters( Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -48,11 +48,19 @@ def generate_parameters( client.voice_generation.generate_parameters() """ _response = self._client_wrapper.httpx_client.request( - "v1/voice-generation/generate-voice/parameters", method="GET", request_options=request_options + "v1/voice-generation/generate-voice/parameters", + method="GET", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: - return typing.cast(VoiceGenerationParameterResponse, construct_type(type_=VoiceGenerationParameterResponse, object_=_response.json())) # type: ignore + return typing.cast( + VoiceGenerationParameterResponse, + construct_type( + type_=VoiceGenerationParameterResponse, # type: ignore + object_=_response.json(), + ), + ) _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -66,7 +74,7 @@ def generate( age: Age, accent_strength: float, text: str, - request_options: typing.Optional[RequestOptions] = None + request_options: typing.Optional[RequestOptions] = None, ) -> typing.Iterator[bytes]: """ Generate a random voice based on parameters. This method returns a generated_voice_id in the response header, and a sample of the voice in the body. If you like the generated voice call /v1/voice-generation/create-voice with the generated_voice_id to create the voice. @@ -98,7 +106,7 @@ def generate( Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -114,7 +122,13 @@ def generate( with self._client_wrapper.httpx_client.stream( "v1/voice-generation/generate-voice", method="POST", - json={"gender": gender, "accent": accent, "age": age, "accent_strength": accent_strength, "text": text}, + json={ + "gender": gender, + "accent": accent, + "age": age, + "accent_strength": accent_strength, + "text": text, + }, request_options=request_options, omit=OMIT, ) as _response: @@ -126,7 +140,13 @@ def generate( _response.read() if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -140,7 +160,7 @@ def create_a_previously_generated_voice( voice_description: str, generated_voice_id: str, labels: typing.Optional[typing.Dict[str, str]] = OMIT, - request_options: typing.Optional[RequestOptions] = None + request_options: typing.Optional[RequestOptions] = None, ) -> Voice: """ Create a previously generated voice. This endpoint should be called after you fetched a generated_voice_id using /v1/voice-generation/generate-voice. @@ -169,7 +189,7 @@ def create_a_previously_generated_voice( Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -194,10 +214,22 @@ def create_a_previously_generated_voice( ) try: if 200 <= _response.status_code < 300: - return typing.cast(Voice, construct_type(type_=Voice, object_=_response.json())) # type: ignore + return typing.cast( + Voice, + construct_type( + type_=Voice, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -229,7 +261,7 @@ async def generate_parameters( -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -243,11 +275,19 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - "v1/voice-generation/generate-voice/parameters", method="GET", request_options=request_options + "v1/voice-generation/generate-voice/parameters", + method="GET", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: - return typing.cast(VoiceGenerationParameterResponse, construct_type(type_=VoiceGenerationParameterResponse, object_=_response.json())) # type: ignore + return typing.cast( + VoiceGenerationParameterResponse, + construct_type( + type_=VoiceGenerationParameterResponse, # type: ignore + object_=_response.json(), + ), + ) _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -261,7 +301,7 @@ async def generate( age: Age, accent_strength: float, text: str, - request_options: typing.Optional[RequestOptions] = None + request_options: typing.Optional[RequestOptions] = None, ) -> typing.AsyncIterator[bytes]: """ Generate a random voice based on parameters. This method returns a generated_voice_id in the response header, and a sample of the voice in the body. If you like the generated voice call /v1/voice-generation/create-voice with the generated_voice_id to create the voice. @@ -295,7 +335,7 @@ async def generate( -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -317,7 +357,13 @@ async def main() -> None: async with self._client_wrapper.httpx_client.stream( "v1/voice-generation/generate-voice", method="POST", - json={"gender": gender, "accent": accent, "age": age, "accent_strength": accent_strength, "text": text}, + json={ + "gender": gender, + "accent": accent, + "age": age, + "accent_strength": accent_strength, + "text": text, + }, request_options=request_options, omit=OMIT, ) as _response: @@ -329,7 +375,13 @@ async def main() -> None: await _response.aread() if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -343,7 +395,7 @@ async def create_a_previously_generated_voice( voice_description: str, generated_voice_id: str, labels: typing.Optional[typing.Dict[str, str]] = OMIT, - request_options: typing.Optional[RequestOptions] = None + request_options: typing.Optional[RequestOptions] = None, ) -> Voice: """ Create a previously generated voice. This endpoint should be called after you fetched a generated_voice_id using /v1/voice-generation/generate-voice. @@ -374,7 +426,7 @@ async def create_a_previously_generated_voice( -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -405,10 +457,22 @@ async def main() -> None: ) try: if 200 <= _response.status_code < 300: - return typing.cast(Voice, construct_type(type_=Voice, object_=_response.json())) # type: ignore + return typing.cast( + Voice, + construct_type( + type_=Voice, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: diff --git a/src/elevenlabs/voices/client.py b/src/elevenlabs/voices/client.py index 024785e..bcea9e2 100644 --- a/src/elevenlabs/voices/client.py +++ b/src/elevenlabs/voices/client.py @@ -1,22 +1,22 @@ # This file was auto-generated by Fern from our API Definition. import typing -from json.decoder import JSONDecodeError - -from .. import core -from ..core.api_error import ApiError -from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper -from ..core.jsonable_encoder import jsonable_encoder +from ..core.client_wrapper import SyncClientWrapper from ..core.request_options import RequestOptions +from ..types.get_voices_response import GetVoicesResponse from ..core.unchecked_base_model import construct_type from ..errors.unprocessable_entity_error import UnprocessableEntityError +from ..types.http_validation_error import HttpValidationError +from json.decoder import JSONDecodeError +from ..core.api_error import ApiError +from ..types.voice_settings import VoiceSettings +from ..core.jsonable_encoder import jsonable_encoder +from ..types.voice import Voice +from .. import core from ..types.add_voice_response_model import AddVoiceResponseModel from ..types.get_library_voices_response import GetLibraryVoicesResponse -from ..types.get_voices_response import GetVoicesResponse -from ..types.http_validation_error import HttpValidationError from ..types.profile_page_response_model import ProfilePageResponseModel -from ..types.voice import Voice -from ..types.voice_settings import VoiceSettings +from ..core.client_wrapper import AsyncClientWrapper # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -47,7 +47,7 @@ def get_all( Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -55,14 +55,31 @@ def get_all( client.voices.get_all() """ _response = self._client_wrapper.httpx_client.request( - "v1/voices", method="GET", params={"show_legacy": show_legacy}, request_options=request_options + "v1/voices", + method="GET", + params={ + "show_legacy": show_legacy, + }, + request_options=request_options, ) try: if 200 <= _response.status_code < 300: - return typing.cast(GetVoicesResponse, construct_type(type_=GetVoicesResponse, object_=_response.json())) # type: ignore + return typing.cast( + GetVoicesResponse, + construct_type( + type_=GetVoicesResponse, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -85,7 +102,7 @@ def get_default_settings(self, *, request_options: typing.Optional[RequestOption Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -93,11 +110,19 @@ def get_default_settings(self, *, request_options: typing.Optional[RequestOption client.voices.get_default_settings() """ _response = self._client_wrapper.httpx_client.request( - "v1/voices/settings/default", method="GET", request_options=request_options + "v1/voices/settings/default", + method="GET", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: - return typing.cast(VoiceSettings, construct_type(type_=VoiceSettings, object_=_response.json())) # type: ignore + return typing.cast( + VoiceSettings, + construct_type( + type_=VoiceSettings, # type: ignore + object_=_response.json(), + ), + ) _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -122,7 +147,7 @@ def get_settings(self, voice_id: str, *, request_options: typing.Optional[Reques Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -132,14 +157,28 @@ def get_settings(self, voice_id: str, *, request_options: typing.Optional[Reques ) """ _response = self._client_wrapper.httpx_client.request( - f"v1/voices/{jsonable_encoder(voice_id)}/settings", method="GET", request_options=request_options + f"v1/voices/{jsonable_encoder(voice_id)}/settings", + method="GET", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: - return typing.cast(VoiceSettings, construct_type(type_=VoiceSettings, object_=_response.json())) # type: ignore + return typing.cast( + VoiceSettings, + construct_type( + type_=VoiceSettings, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -174,7 +213,7 @@ def get( Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -186,22 +225,38 @@ def get( _response = self._client_wrapper.httpx_client.request( f"v1/voices/{jsonable_encoder(voice_id)}", method="GET", - params={"with_settings": with_settings}, + params={ + "with_settings": with_settings, + }, request_options=request_options, ) try: if 200 <= _response.status_code < 300: - return typing.cast(Voice, construct_type(type_=Voice, object_=_response.json())) # type: ignore + return typing.cast( + Voice, + construct_type( + type_=Voice, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - def delete(self, voice_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> typing.Any: + def delete( + self, voice_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> typing.Optional[typing.Any]: """ Deletes a voice by its ID. @@ -215,12 +270,12 @@ def delete(self, voice_id: str, *, request_options: typing.Optional[RequestOptio Returns ------- - typing.Any + typing.Optional[typing.Any] Successful Response Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -230,14 +285,28 @@ def delete(self, voice_id: str, *, request_options: typing.Optional[RequestOptio ) """ _response = self._client_wrapper.httpx_client.request( - f"v1/voices/{jsonable_encoder(voice_id)}", method="DELETE", request_options=request_options + f"v1/voices/{jsonable_encoder(voice_id)}", + method="DELETE", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: - return typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + return typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -246,7 +315,7 @@ def delete(self, voice_id: str, *, request_options: typing.Optional[RequestOptio def edit_settings( self, voice_id: str, *, request: VoiceSettings, request_options: typing.Optional[RequestOptions] = None - ) -> typing.Any: + ) -> typing.Optional[typing.Any]: """ Edit your settings for a specific voice. "similarity_boost" corresponds to"Clarity + Similarity Enhancement" in the web app and "stability" corresponds to "Stability" slider in the web app. @@ -262,13 +331,12 @@ def edit_settings( Returns ------- - typing.Any + typing.Optional[typing.Any] Successful Response Examples -------- - from elevenlabs import VoiceSettings - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs, VoiceSettings client = ElevenLabs( api_key="YOUR_API_KEY", @@ -291,10 +359,22 @@ def edit_settings( ) try: if 200 <= _response.status_code < 300: - return typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + return typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -337,7 +417,7 @@ def add( Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -349,17 +429,35 @@ def add( _response = self._client_wrapper.httpx_client.request( "v1/voices/add", method="POST", - data={"name": name, "description": description, "labels": labels}, - files={"files": files}, + data={ + "name": name, + "description": description, + "labels": labels, + }, + files={ + "files": files, + }, request_options=request_options, omit=OMIT, ) try: if 200 <= _response.status_code < 300: - return typing.cast(AddVoiceResponseModel, construct_type(type_=AddVoiceResponseModel, object_=_response.json())) # type: ignore + return typing.cast( + AddVoiceResponseModel, + construct_type( + type_=AddVoiceResponseModel, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -375,7 +473,7 @@ def edit( description: typing.Optional[str] = None, labels: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None, - ) -> typing.Any: + ) -> typing.Optional[typing.Any]: """ Edit a voice created by you. @@ -401,12 +499,12 @@ def edit( Returns ------- - typing.Any + typing.Optional[typing.Any] Successful Response Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -419,17 +517,35 @@ def edit( _response = self._client_wrapper.httpx_client.request( f"v1/voices/{jsonable_encoder(voice_id)}/edit", method="POST", - data={"name": name, "description": description, "labels": labels}, - files={"files": files}, + data={ + "name": name, + "description": description, + "labels": labels, + }, + files={ + "files": files, + }, request_options=request_options, omit=OMIT, ) try: if 200 <= _response.status_code < 300: - return typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + return typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -472,7 +588,7 @@ def add_sharing_voice( Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -486,17 +602,33 @@ def add_sharing_voice( _response = self._client_wrapper.httpx_client.request( f"v1/voices/add/{jsonable_encoder(public_user_id)}/{jsonable_encoder(voice_id)}", method="POST", - json={"new_name": new_name}, - headers={"xi-app-check-token": str(xi_app_check_token) if xi_app_check_token is not None else None}, + json={ + "new_name": new_name, + }, + headers={ + "xi-app-check-token": str(xi_app_check_token) if xi_app_check_token is not None else None, + }, request_options=request_options, omit=OMIT, ) try: if 200 <= _response.status_code < 300: - return typing.cast(AddVoiceResponseModel, construct_type(type_=AddVoiceResponseModel, object_=_response.json())) # type: ignore + return typing.cast( + AddVoiceResponseModel, + construct_type( + type_=AddVoiceResponseModel, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -578,7 +710,7 @@ def get_shared( Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -612,10 +744,22 @@ def get_shared( ) try: if 200 <= _response.status_code < 300: - return typing.cast(GetLibraryVoicesResponse, construct_type(type_=GetLibraryVoicesResponse, object_=_response.json())) # type: ignore + return typing.cast( + GetLibraryVoicesResponse, + construct_type( + type_=GetLibraryVoicesResponse, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -654,7 +798,7 @@ def get_similar_library_voices( Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -664,17 +808,34 @@ def get_similar_library_voices( _response = self._client_wrapper.httpx_client.request( "v1/similar-voices", method="POST", - data={"similarity_threshold": similarity_threshold, "top_k": top_k}, - files={"audio_file": audio_file}, + data={ + "similarity_threshold": similarity_threshold, + "top_k": top_k, + }, + files={ + "audio_file": audio_file, + }, request_options=request_options, omit=OMIT, ) try: if 200 <= _response.status_code < 300: - return typing.cast(GetLibraryVoicesResponse, construct_type(type_=GetLibraryVoicesResponse, object_=_response.json())) # type: ignore + return typing.cast( + GetLibraryVoicesResponse, + construct_type( + type_=GetLibraryVoicesResponse, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -702,7 +863,7 @@ def get_a_profile_page( Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -712,14 +873,28 @@ def get_a_profile_page( ) """ _response = self._client_wrapper.httpx_client.request( - f"profile/{jsonable_encoder(handle)}", method="GET", request_options=request_options + f"profile/{jsonable_encoder(handle)}", + method="GET", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: - return typing.cast(ProfilePageResponseModel, construct_type(type_=ProfilePageResponseModel, object_=_response.json())) # type: ignore + return typing.cast( + ProfilePageResponseModel, + construct_type( + type_=ProfilePageResponseModel, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -754,7 +929,7 @@ async def get_all( -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -768,14 +943,31 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - "v1/voices", method="GET", params={"show_legacy": show_legacy}, request_options=request_options + "v1/voices", + method="GET", + params={ + "show_legacy": show_legacy, + }, + request_options=request_options, ) try: if 200 <= _response.status_code < 300: - return typing.cast(GetVoicesResponse, construct_type(type_=GetVoicesResponse, object_=_response.json())) # type: ignore + return typing.cast( + GetVoicesResponse, + construct_type( + type_=GetVoicesResponse, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -800,7 +992,7 @@ async def get_default_settings(self, *, request_options: typing.Optional[Request -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -814,11 +1006,19 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - "v1/voices/settings/default", method="GET", request_options=request_options + "v1/voices/settings/default", + method="GET", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: - return typing.cast(VoiceSettings, construct_type(type_=VoiceSettings, object_=_response.json())) # type: ignore + return typing.cast( + VoiceSettings, + construct_type( + type_=VoiceSettings, # type: ignore + object_=_response.json(), + ), + ) _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -847,7 +1047,7 @@ async def get_settings( -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -863,14 +1063,28 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - f"v1/voices/{jsonable_encoder(voice_id)}/settings", method="GET", request_options=request_options + f"v1/voices/{jsonable_encoder(voice_id)}/settings", + method="GET", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: - return typing.cast(VoiceSettings, construct_type(type_=VoiceSettings, object_=_response.json())) # type: ignore + return typing.cast( + VoiceSettings, + construct_type( + type_=VoiceSettings, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -907,7 +1121,7 @@ async def get( -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -925,22 +1139,38 @@ async def main() -> None: _response = await self._client_wrapper.httpx_client.request( f"v1/voices/{jsonable_encoder(voice_id)}", method="GET", - params={"with_settings": with_settings}, + params={ + "with_settings": with_settings, + }, request_options=request_options, ) try: if 200 <= _response.status_code < 300: - return typing.cast(Voice, construct_type(type_=Voice, object_=_response.json())) # type: ignore + return typing.cast( + Voice, + construct_type( + type_=Voice, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - async def delete(self, voice_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> typing.Any: + async def delete( + self, voice_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> typing.Optional[typing.Any]: """ Deletes a voice by its ID. @@ -954,14 +1184,14 @@ async def delete(self, voice_id: str, *, request_options: typing.Optional[Reques Returns ------- - typing.Any + typing.Optional[typing.Any] Successful Response Examples -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -977,14 +1207,28 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - f"v1/voices/{jsonable_encoder(voice_id)}", method="DELETE", request_options=request_options + f"v1/voices/{jsonable_encoder(voice_id)}", + method="DELETE", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: - return typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + return typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -993,7 +1237,7 @@ async def main() -> None: async def edit_settings( self, voice_id: str, *, request: VoiceSettings, request_options: typing.Optional[RequestOptions] = None - ) -> typing.Any: + ) -> typing.Optional[typing.Any]: """ Edit your settings for a specific voice. "similarity_boost" corresponds to"Clarity + Similarity Enhancement" in the web app and "stability" corresponds to "Stability" slider in the web app. @@ -1009,15 +1253,14 @@ async def edit_settings( Returns ------- - typing.Any + typing.Optional[typing.Any] Successful Response Examples -------- import asyncio - from elevenlabs import VoiceSettings - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs, VoiceSettings client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -1046,10 +1289,22 @@ async def main() -> None: ) try: if 200 <= _response.status_code < 300: - return typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + return typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -1094,7 +1349,7 @@ async def add( -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -1112,17 +1367,35 @@ async def main() -> None: _response = await self._client_wrapper.httpx_client.request( "v1/voices/add", method="POST", - data={"name": name, "description": description, "labels": labels}, - files={"files": files}, + data={ + "name": name, + "description": description, + "labels": labels, + }, + files={ + "files": files, + }, request_options=request_options, omit=OMIT, ) try: if 200 <= _response.status_code < 300: - return typing.cast(AddVoiceResponseModel, construct_type(type_=AddVoiceResponseModel, object_=_response.json())) # type: ignore + return typing.cast( + AddVoiceResponseModel, + construct_type( + type_=AddVoiceResponseModel, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -1138,7 +1411,7 @@ async def edit( description: typing.Optional[str] = None, labels: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None, - ) -> typing.Any: + ) -> typing.Optional[typing.Any]: """ Edit a voice created by you. @@ -1164,14 +1437,14 @@ async def edit( Returns ------- - typing.Any + typing.Optional[typing.Any] Successful Response Examples -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -1190,17 +1463,35 @@ async def main() -> None: _response = await self._client_wrapper.httpx_client.request( f"v1/voices/{jsonable_encoder(voice_id)}/edit", method="POST", - data={"name": name, "description": description, "labels": labels}, - files={"files": files}, + data={ + "name": name, + "description": description, + "labels": labels, + }, + files={ + "files": files, + }, request_options=request_options, omit=OMIT, ) try: if 200 <= _response.status_code < 300: - return typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + return typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -1245,7 +1536,7 @@ async def add_sharing_voice( -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -1265,17 +1556,33 @@ async def main() -> None: _response = await self._client_wrapper.httpx_client.request( f"v1/voices/add/{jsonable_encoder(public_user_id)}/{jsonable_encoder(voice_id)}", method="POST", - json={"new_name": new_name}, - headers={"xi-app-check-token": str(xi_app_check_token) if xi_app_check_token is not None else None}, + json={ + "new_name": new_name, + }, + headers={ + "xi-app-check-token": str(xi_app_check_token) if xi_app_check_token is not None else None, + }, request_options=request_options, omit=OMIT, ) try: if 200 <= _response.status_code < 300: - return typing.cast(AddVoiceResponseModel, construct_type(type_=AddVoiceResponseModel, object_=_response.json())) # type: ignore + return typing.cast( + AddVoiceResponseModel, + construct_type( + type_=AddVoiceResponseModel, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -1359,7 +1666,7 @@ async def get_shared( -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -1399,10 +1706,22 @@ async def main() -> None: ) try: if 200 <= _response.status_code < 300: - return typing.cast(GetLibraryVoicesResponse, construct_type(type_=GetLibraryVoicesResponse, object_=_response.json())) # type: ignore + return typing.cast( + GetLibraryVoicesResponse, + construct_type( + type_=GetLibraryVoicesResponse, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -1443,7 +1762,7 @@ async def get_similar_library_voices( -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -1459,17 +1778,34 @@ async def main() -> None: _response = await self._client_wrapper.httpx_client.request( "v1/similar-voices", method="POST", - data={"similarity_threshold": similarity_threshold, "top_k": top_k}, - files={"audio_file": audio_file}, + data={ + "similarity_threshold": similarity_threshold, + "top_k": top_k, + }, + files={ + "audio_file": audio_file, + }, request_options=request_options, omit=OMIT, ) try: if 200 <= _response.status_code < 300: - return typing.cast(GetLibraryVoicesResponse, construct_type(type_=GetLibraryVoicesResponse, object_=_response.json())) # type: ignore + return typing.cast( + GetLibraryVoicesResponse, + construct_type( + type_=GetLibraryVoicesResponse, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -1499,7 +1835,7 @@ async def get_a_profile_page( -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -1515,14 +1851,28 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - f"profile/{jsonable_encoder(handle)}", method="GET", request_options=request_options + f"profile/{jsonable_encoder(handle)}", + method="GET", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: - return typing.cast(ProfilePageResponseModel, construct_type(type_=ProfilePageResponseModel, object_=_response.json())) # type: ignore + return typing.cast( + ProfilePageResponseModel, + construct_type( + type_=ProfilePageResponseModel, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: diff --git a/src/elevenlabs/workspace/client.py b/src/elevenlabs/workspace/client.py index 9b228da..ff9411c 100644 --- a/src/elevenlabs/workspace/client.py +++ b/src/elevenlabs/workspace/client.py @@ -1,17 +1,17 @@ # This file was auto-generated by Fern from our API Definition. import typing -from json.decoder import JSONDecodeError - -from ..core.api_error import ApiError -from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.client_wrapper import SyncClientWrapper from ..core.request_options import RequestOptions from ..core.unchecked_base_model import construct_type from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.http_validation_error import HttpValidationError +from json.decoder import JSONDecodeError +from ..core.api_error import ApiError from .types.body_update_member_v_1_workspace_members_post_workspace_role import ( BodyUpdateMemberV1WorkspaceMembersPostWorkspaceRole, ) +from ..core.client_wrapper import AsyncClientWrapper # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -21,7 +21,9 @@ class WorkspaceClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._client_wrapper = client_wrapper - def invite_user(self, *, email: str, request_options: typing.Optional[RequestOptions] = None) -> typing.Any: + def invite_user( + self, *, email: str, request_options: typing.Optional[RequestOptions] = None + ) -> typing.Optional[typing.Any]: """ Sends an email invitation to join your workspace to the provided email. If the user doesn't have an account they will be prompted to create one. If the user accepts this invite they will be added as a user to your workspace and your subscription using one of your seats. This endpoint may only be called by workspace administrators. @@ -35,12 +37,12 @@ def invite_user(self, *, email: str, request_options: typing.Optional[RequestOpt Returns ------- - typing.Any + typing.Optional[typing.Any] Successful Response Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -50,14 +52,32 @@ def invite_user(self, *, email: str, request_options: typing.Optional[RequestOpt ) """ _response = self._client_wrapper.httpx_client.request( - "v1/workspace/invites/add", method="POST", json={"email": email}, request_options=request_options, omit=OMIT + "v1/workspace/invites/add", + method="POST", + json={ + "email": email, + }, + request_options=request_options, + omit=OMIT, ) try: if 200 <= _response.status_code < 300: - return typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + return typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -66,7 +86,7 @@ def invite_user(self, *, email: str, request_options: typing.Optional[RequestOpt def delete_existing_invitation( self, *, email: str, request_options: typing.Optional[RequestOptions] = None - ) -> typing.Any: + ) -> typing.Optional[typing.Any]: """ Invalidates an existing email invitation. The invitation will still show up in the inbox it has been delivered to, but activating it to join the workspace won't work. This endpoint may only be called by workspace administrators. @@ -80,12 +100,12 @@ def delete_existing_invitation( Returns ------- - typing.Any + typing.Optional[typing.Any] Successful Response Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -95,14 +115,32 @@ def delete_existing_invitation( ) """ _response = self._client_wrapper.httpx_client.request( - "v1/workspace/invites", method="DELETE", json={"email": email}, request_options=request_options, omit=OMIT + "v1/workspace/invites", + method="DELETE", + json={ + "email": email, + }, + request_options=request_options, + omit=OMIT, ) try: if 200 <= _response.status_code < 300: - return typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + return typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -115,8 +153,8 @@ def update_member( email: str, is_locked: typing.Optional[bool] = OMIT, workspace_role: typing.Optional[BodyUpdateMemberV1WorkspaceMembersPostWorkspaceRole] = OMIT, - request_options: typing.Optional[RequestOptions] = None - ) -> typing.Any: + request_options: typing.Optional[RequestOptions] = None, + ) -> typing.Optional[typing.Any]: """ Updates attributes of a workspace member. Apart from the email identifier, all parameters will remain unchanged unless specified. This endpoint may only be called by workspace administrators. @@ -136,12 +174,12 @@ def update_member( Returns ------- - typing.Any + typing.Optional[typing.Any] Successful Response Examples -------- - from elevenlabs.client import ElevenLabs + from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", @@ -153,16 +191,32 @@ def update_member( _response = self._client_wrapper.httpx_client.request( "v1/workspace/members", method="POST", - json={"email": email, "is_locked": is_locked, "workspace_role": workspace_role}, + json={ + "email": email, + "is_locked": is_locked, + "workspace_role": workspace_role, + }, request_options=request_options, omit=OMIT, ) try: if 200 <= _response.status_code < 300: - return typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + return typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -174,7 +228,9 @@ class AsyncWorkspaceClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._client_wrapper = client_wrapper - async def invite_user(self, *, email: str, request_options: typing.Optional[RequestOptions] = None) -> typing.Any: + async def invite_user( + self, *, email: str, request_options: typing.Optional[RequestOptions] = None + ) -> typing.Optional[typing.Any]: """ Sends an email invitation to join your workspace to the provided email. If the user doesn't have an account they will be prompted to create one. If the user accepts this invite they will be added as a user to your workspace and your subscription using one of your seats. This endpoint may only be called by workspace administrators. @@ -188,14 +244,14 @@ async def invite_user(self, *, email: str, request_options: typing.Optional[Requ Returns ------- - typing.Any + typing.Optional[typing.Any] Successful Response Examples -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -211,14 +267,32 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - "v1/workspace/invites/add", method="POST", json={"email": email}, request_options=request_options, omit=OMIT + "v1/workspace/invites/add", + method="POST", + json={ + "email": email, + }, + request_options=request_options, + omit=OMIT, ) try: if 200 <= _response.status_code < 300: - return typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + return typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -227,7 +301,7 @@ async def main() -> None: async def delete_existing_invitation( self, *, email: str, request_options: typing.Optional[RequestOptions] = None - ) -> typing.Any: + ) -> typing.Optional[typing.Any]: """ Invalidates an existing email invitation. The invitation will still show up in the inbox it has been delivered to, but activating it to join the workspace won't work. This endpoint may only be called by workspace administrators. @@ -241,14 +315,14 @@ async def delete_existing_invitation( Returns ------- - typing.Any + typing.Optional[typing.Any] Successful Response Examples -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -264,14 +338,32 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - "v1/workspace/invites", method="DELETE", json={"email": email}, request_options=request_options, omit=OMIT + "v1/workspace/invites", + method="DELETE", + json={ + "email": email, + }, + request_options=request_options, + omit=OMIT, ) try: if 200 <= _response.status_code < 300: - return typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + return typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: @@ -284,8 +376,8 @@ async def update_member( email: str, is_locked: typing.Optional[bool] = OMIT, workspace_role: typing.Optional[BodyUpdateMemberV1WorkspaceMembersPostWorkspaceRole] = OMIT, - request_options: typing.Optional[RequestOptions] = None - ) -> typing.Any: + request_options: typing.Optional[RequestOptions] = None, + ) -> typing.Optional[typing.Any]: """ Updates attributes of a workspace member. Apart from the email identifier, all parameters will remain unchanged unless specified. This endpoint may only be called by workspace administrators. @@ -305,14 +397,14 @@ async def update_member( Returns ------- - typing.Any + typing.Optional[typing.Any] Successful Response Examples -------- import asyncio - from elevenlabs.client import AsyncElevenLabs + from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", @@ -330,16 +422,32 @@ async def main() -> None: _response = await self._client_wrapper.httpx_client.request( "v1/workspace/members", method="POST", - json={"email": email, "is_locked": is_locked, "workspace_role": workspace_role}, + json={ + "email": email, + "is_locked": is_locked, + "workspace_role": workspace_role, + }, request_options=request_options, omit=OMIT, ) try: if 200 <= _response.status_code < 300: - return typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + return typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast(HttpValidationError, construct_type(type_=HttpValidationError, object_=_response.json())) # type: ignore + typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) ) _response_json = _response.json() except JSONDecodeError: