Skip to content

Commit

Permalink
SDK regeneration
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed Mar 12, 2024
1 parent 485764b commit 9a64d93
Show file tree
Hide file tree
Showing 11 changed files with 314 additions and 68 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "elevenlabs"
version = "0.0.46"
version = "0.0.47"
description = ""
readme = "README.md"
authors = []
Expand Down
14 changes: 14 additions & 0 deletions src/elevenlabs/audio_native/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ def create(
- auto_convert: bool. Whether to auto convert the project to audio or not.
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
---
from elevenlabs.client import ElevenLabs
client = ElevenLabs(
api_key="YOUR_API_KEY",
)
client.audio_native.create()
"""
_response = self._client_wrapper.httpx_client.request(
"POST",
Expand Down Expand Up @@ -194,6 +201,13 @@ async def create(
- auto_convert: bool. Whether to auto convert the project to audio or not.
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
---
from elevenlabs.client import AsyncElevenLabs
client = AsyncElevenLabs(
api_key="YOUR_API_KEY",
)
await client.audio_native.create()
"""
_response = await self._client_wrapper.httpx_client.request(
"POST",
Expand Down
2 changes: 1 addition & 1 deletion src/elevenlabs/core/client_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,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": "0.0.46",
"X-Fern-SDK-Version": "0.0.47",
}
if self._api_key is not None:
headers["xi-api-key"] = self._api_key
Expand Down
14 changes: 14 additions & 0 deletions src/elevenlabs/dubbing/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ def dub_a_video_or_an_audio_file(
- dubbing_studio: bool. Whether to prepare dub for edits in dubbing studio.
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
---
from elevenlabs.client import ElevenLabs
client = ElevenLabs(
api_key="YOUR_API_KEY",
)
client.dubbing.dub_a_video_or_an_audio_file()
"""
_response = self._client_wrapper.httpx_client.request(
"POST",
Expand Down Expand Up @@ -381,6 +388,13 @@ async def dub_a_video_or_an_audio_file(
- dubbing_studio: bool. Whether to prepare dub for edits in dubbing studio.
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
---
from elevenlabs.client import AsyncElevenLabs
client = AsyncElevenLabs(
api_key="YOUR_API_KEY",
)
await client.dubbing.dub_a_video_or_an_audio_file()
"""
_response = await self._client_wrapper.httpx_client.request(
"POST",
Expand Down
18 changes: 18 additions & 0 deletions src/elevenlabs/history/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,15 @@ def get_audio(
- history_item_id: str. History item ID to be used, you can use GET https://api.elevenlabs.io/v1/history to receive a list of history items and their IDs.
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
---
from elevenlabs.client import ElevenLabs
client = ElevenLabs(
api_key="YOUR_API_KEY",
)
client.history.get_audio(
history_item_id="string",
)
"""
with self._client_wrapper.httpx_client.stream(
"GET",
Expand Down Expand Up @@ -484,6 +493,15 @@ async def get_audio(
- history_item_id: str. History item ID to be used, you can use GET https://api.elevenlabs.io/v1/history to receive a list of history items and their IDs.
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
---
from elevenlabs.client import AsyncElevenLabs
client = AsyncElevenLabs(
api_key="YOUR_API_KEY",
)
await client.history.get_audio(
history_item_id="string",
)
"""
async with self._client_wrapper.httpx_client.stream(
"GET",
Expand Down
14 changes: 14 additions & 0 deletions src/elevenlabs/projects/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,13 @@ def add(
- callback_url: str. A url that will be called by our service when the project is converted with a json containing the status of the conversion
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
---
from elevenlabs.client import ElevenLabs
client = ElevenLabs(
api_key="YOUR_API_KEY",
)
client.projects.add()
"""
_response = self._client_wrapper.httpx_client.request(
"POST",
Expand Down Expand Up @@ -646,6 +653,13 @@ async def add(
- callback_url: str. A url that will be called by our service when the project is converted with a json containing the status of the conversion
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
---
from elevenlabs.client import AsyncElevenLabs
client = AsyncElevenLabs(
api_key="YOUR_API_KEY",
)
await client.projects.add()
"""
_response = await self._client_wrapper.httpx_client.request(
"POST",
Expand Down
14 changes: 14 additions & 0 deletions src/elevenlabs/pronunciation_dictionary/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ def add_from_file(
- description: str. A description of the pronunciation dictionary, used for identification only.
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
---
from elevenlabs.client import ElevenLabs
client = ElevenLabs(
api_key="YOUR_API_KEY",
)
client.pronunciation_dictionary.add_from_file()
"""
_response = self._client_wrapper.httpx_client.request(
"POST",
Expand Down Expand Up @@ -164,6 +171,13 @@ async def add_from_file(
- description: str. A description of the pronunciation dictionary, used for identification only.
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
---
from elevenlabs.client import AsyncElevenLabs
client = AsyncElevenLabs(
api_key="YOUR_API_KEY",
)
await client.pronunciation_dictionary.add_from_file()
"""
_response = await self._client_wrapper.httpx_client.request(
"POST",
Expand Down
97 changes: 66 additions & 31 deletions src/elevenlabs/speech_to_speech/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@
from ..core.jsonable_encoder import jsonable_encoder
from ..core.remove_none_from_dict import remove_none_from_dict
from ..core.request_options import RequestOptions
from ..errors.unprocessable_entity_error import UnprocessableEntityError
from ..types.http_validation_error import HttpValidationError

try:
import pydantic.v1 as pydantic # type: ignore
except ImportError:
import pydantic # type: ignore

# this is used as the default value for optional parameters
OMIT = typing.cast(typing.Any, ...)
Expand Down Expand Up @@ -57,6 +50,16 @@ def convert(
- voice_settings: str. Voice settings overriding stored setttings for the given voice. They are applied only on the given request. Needs to be send as a JSON encoded string.
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
---
from elevenlabs.client import ElevenLabs
client = ElevenLabs(
api_key="YOUR_API_KEY",
)
client.speech_to_speech.convert(
voice_id="string",
optimize_streaming_latency=1,
)
"""
with self._client_wrapper.httpx_client.stream(
"POST",
Expand Down Expand Up @@ -116,7 +119,7 @@ def convert_as_stream(
model_id: str,
voice_settings: str,
request_options: typing.Optional[RequestOptions] = None,
) -> None:
) -> typing.Iterator[bytes]:
"""
Create speech by combining the content and emotion of the uploaded audio with a voice of your choice and returns an audio stream.
Expand All @@ -138,8 +141,18 @@ def convert_as_stream(
- voice_settings: str. Voice settings overriding stored setttings for the given voice. They are applied only on the given request. Needs to be send as a JSON encoded string.
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
---
from elevenlabs.client import ElevenLabs
client = ElevenLabs(
api_key="YOUR_API_KEY",
)
client.speech_to_speech.convert_as_stream(
voice_id="string",
optimize_streaming_latency=1,
)
"""
_response = self._client_wrapper.httpx_client.request(
with self._client_wrapper.httpx_client.stream(
"POST",
urllib.parse.urljoin(
f"{self._client_wrapper.get_base_url()}/", f"v1/speech-to-speech/{jsonable_encoder(voice_id)}/stream"
Expand Down Expand Up @@ -176,16 +189,17 @@ def convert_as_stream(
else 60,
retries=0,
max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
)
if 200 <= _response.status_code < 300:
return
if _response.status_code == 422:
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
try:
_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)
) as _response:
if 200 <= _response.status_code < 300:
for _chunk in _response.iter_bytes():
yield _chunk
return
_response.read()
try:
_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)


class AsyncSpeechToSpeechClient:
Expand Down Expand Up @@ -223,6 +237,16 @@ async def convert(
- voice_settings: str. Voice settings overriding stored setttings for the given voice. They are applied only on the given request. Needs to be send as a JSON encoded string.
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
---
from elevenlabs.client import AsyncElevenLabs
client = AsyncElevenLabs(
api_key="YOUR_API_KEY",
)
await client.speech_to_speech.convert(
voice_id="string",
optimize_streaming_latency=1,
)
"""
async with self._client_wrapper.httpx_client.stream(
"POST",
Expand Down Expand Up @@ -282,7 +306,7 @@ async def convert_as_stream(
model_id: str,
voice_settings: str,
request_options: typing.Optional[RequestOptions] = None,
) -> None:
) -> typing.AsyncIterator[bytes]:
"""
Create speech by combining the content and emotion of the uploaded audio with a voice of your choice and returns an audio stream.
Expand All @@ -304,8 +328,18 @@ async def convert_as_stream(
- voice_settings: str. Voice settings overriding stored setttings for the given voice. They are applied only on the given request. Needs to be send as a JSON encoded string.
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
---
from elevenlabs.client import AsyncElevenLabs
client = AsyncElevenLabs(
api_key="YOUR_API_KEY",
)
await client.speech_to_speech.convert_as_stream(
voice_id="string",
optimize_streaming_latency=1,
)
"""
_response = await self._client_wrapper.httpx_client.request(
async with self._client_wrapper.httpx_client.stream(
"POST",
urllib.parse.urljoin(
f"{self._client_wrapper.get_base_url()}/", f"v1/speech-to-speech/{jsonable_encoder(voice_id)}/stream"
Expand Down Expand Up @@ -342,13 +376,14 @@ async def convert_as_stream(
else 60,
retries=0,
max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
)
if 200 <= _response.status_code < 300:
return
if _response.status_code == 422:
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
try:
_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)
) as _response:
if 200 <= _response.status_code < 300:
async for _chunk in _response.aiter_bytes():
yield _chunk
return
await _response.aread()
try:
_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)
Loading

0 comments on commit 9a64d93

Please sign in to comment.