Skip to content

Commit f21a904

Browse files
committed
Release 2.0.0
1 parent 97a4776 commit f21a904

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1009
-235
lines changed

poetry.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "murf"
33

44
[tool.poetry]
55
name = "murf"
6-
version = "1.2.3"
6+
version = "2.0.0"
77
description = ""
88
readme = "README.md"
99
authors = []

src/murf/__init__.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@
88
ApiProjectResponseDubbingType,
99
ApiVoice,
1010
ApiVoiceGender,
11+
AudioOutput,
1112
AuthTokenResponse,
1213
CharacterCount,
14+
ClearContext,
1315
DubApiDetailResponse,
1416
DubJobStatusResponse,
17+
FinalOutput,
1518
FormDataContentDisposition,
1619
GenerateSpeechResponse,
1720
GroupApiProjectResponse,
@@ -21,10 +24,20 @@
2124
MurfApiTranslationResponse,
2225
PronunciationDetail,
2326
PronunciationDetailType,
27+
SendText,
28+
SetAdvancedSettings,
29+
SetVoiceConfiguration,
30+
SetVoiceConfigurationVoiceConfig,
31+
SetVoiceConfigurationVoiceConfigPronunciationDictionaryValue,
32+
SetVoiceConfigurationVoiceConfigPronunciationDictionaryValueType,
2433
SourceLocaleResponse,
2534
SpeechToSpeechResponse,
2635
StyleDetails,
2736
Translation,
37+
TtsRequestBothPayload,
38+
TtsRequestBothPayloadVoiceConfig,
39+
TtsRequestBothPayloadVoiceConfigPronunciationDictionary,
40+
TtsRequestBothPayloadVoiceConfigPronunciationDictionaryGuess,
2841
WordDurationResponse,
2942
)
3043
from .errors import (
@@ -35,10 +48,11 @@
3548
ServiceUnavailableError,
3649
UnauthorizedError,
3750
)
38-
from . import auth, dubbing, text, text_to_speech, voice_changer
51+
from . import auth, dubbing, stream_input, text, text_to_speech, voice_changer
3952
from .client import AsyncMurf, Murf
4053
from .dubbing_client import MurfDub
4154
from .environment import MurfEnvironment
55+
from .stream_input import ReceiveMessage, SendMessage
4256
from .text_to_speech import GenerateSpeechRequestModelVersion
4357
from .version import __version__
4458

@@ -51,11 +65,14 @@
5165
"ApiVoice",
5266
"ApiVoiceGender",
5367
"AsyncMurf",
68+
"AudioOutput",
5469
"AuthTokenResponse",
5570
"BadRequestError",
5671
"CharacterCount",
72+
"ClearContext",
5773
"DubApiDetailResponse",
5874
"DubJobStatusResponse",
75+
"FinalOutput",
5976
"ForbiddenError",
6077
"FormDataContentDisposition",
6178
"GenerateSpeechRequestModelVersion",
@@ -72,16 +89,29 @@
7289
"PaymentRequiredError",
7390
"PronunciationDetail",
7491
"PronunciationDetailType",
92+
"ReceiveMessage",
93+
"SendMessage",
94+
"SendText",
7595
"ServiceUnavailableError",
96+
"SetAdvancedSettings",
97+
"SetVoiceConfiguration",
98+
"SetVoiceConfigurationVoiceConfig",
99+
"SetVoiceConfigurationVoiceConfigPronunciationDictionaryValue",
100+
"SetVoiceConfigurationVoiceConfigPronunciationDictionaryValueType",
76101
"SourceLocaleResponse",
77102
"SpeechToSpeechResponse",
78103
"StyleDetails",
79104
"Translation",
105+
"TtsRequestBothPayload",
106+
"TtsRequestBothPayloadVoiceConfig",
107+
"TtsRequestBothPayloadVoiceConfigPronunciationDictionary",
108+
"TtsRequestBothPayloadVoiceConfigPronunciationDictionaryGuess",
80109
"UnauthorizedError",
81110
"WordDurationResponse",
82111
"__version__",
83112
"auth",
84113
"dubbing",
114+
"stream_input",
85115
"text",
86116
"text_to_speech",
87117
"voice_changer",

src/murf/auth/client.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import typing
55
from ..core.request_options import RequestOptions
66
from ..types.auth_token_response import AuthTokenResponse
7-
from ..core.pydantic_utilities import parse_obj_as
7+
from ..core.unchecked_base_model import construct_type
88
from ..errors.bad_request_error import BadRequestError
99
from ..errors.unauthorized_error import UnauthorizedError
1010
from ..errors.service_unavailable_error import ServiceUnavailableError
@@ -42,14 +42,15 @@ def generate_token(self, *, request_options: typing.Optional[RequestOptions] = N
4242
"""
4343
_response = self._client_wrapper.httpx_client.request(
4444
"v1/auth/token",
45+
base_url=self._client_wrapper.get_environment().base,
4546
method="GET",
4647
request_options=request_options,
4748
)
4849
try:
4950
if 200 <= _response.status_code < 300:
5051
return typing.cast(
5152
AuthTokenResponse,
52-
parse_obj_as(
53+
construct_type(
5354
type_=AuthTokenResponse, # type: ignore
5455
object_=_response.json(),
5556
),
@@ -58,7 +59,7 @@ def generate_token(self, *, request_options: typing.Optional[RequestOptions] = N
5859
raise BadRequestError(
5960
typing.cast(
6061
typing.Optional[typing.Any],
61-
parse_obj_as(
62+
construct_type(
6263
type_=typing.Optional[typing.Any], # type: ignore
6364
object_=_response.json(),
6465
),
@@ -68,7 +69,7 @@ def generate_token(self, *, request_options: typing.Optional[RequestOptions] = N
6869
raise UnauthorizedError(
6970
typing.cast(
7071
typing.Optional[typing.Any],
71-
parse_obj_as(
72+
construct_type(
7273
type_=typing.Optional[typing.Any], # type: ignore
7374
object_=_response.json(),
7475
),
@@ -78,7 +79,7 @@ def generate_token(self, *, request_options: typing.Optional[RequestOptions] = N
7879
raise ServiceUnavailableError(
7980
typing.cast(
8081
typing.Optional[typing.Any],
81-
parse_obj_as(
82+
construct_type(
8283
type_=typing.Optional[typing.Any], # type: ignore
8384
object_=_response.json(),
8485
),
@@ -127,14 +128,15 @@ async def main() -> None:
127128
"""
128129
_response = await self._client_wrapper.httpx_client.request(
129130
"v1/auth/token",
131+
base_url=self._client_wrapper.get_environment().base,
130132
method="GET",
131133
request_options=request_options,
132134
)
133135
try:
134136
if 200 <= _response.status_code < 300:
135137
return typing.cast(
136138
AuthTokenResponse,
137-
parse_obj_as(
139+
construct_type(
138140
type_=AuthTokenResponse, # type: ignore
139141
object_=_response.json(),
140142
),
@@ -143,7 +145,7 @@ async def main() -> None:
143145
raise BadRequestError(
144146
typing.cast(
145147
typing.Optional[typing.Any],
146-
parse_obj_as(
148+
construct_type(
147149
type_=typing.Optional[typing.Any], # type: ignore
148150
object_=_response.json(),
149151
),
@@ -153,7 +155,7 @@ async def main() -> None:
153155
raise UnauthorizedError(
154156
typing.cast(
155157
typing.Optional[typing.Any],
156-
parse_obj_as(
158+
construct_type(
157159
type_=typing.Optional[typing.Any], # type: ignore
158160
object_=_response.json(),
159161
),
@@ -163,7 +165,7 @@ async def main() -> None:
163165
raise ServiceUnavailableError(
164166
typing.cast(
165167
typing.Optional[typing.Any],
166-
parse_obj_as(
168+
construct_type(
167169
type_=typing.Optional[typing.Any], # type: ignore
168170
object_=_response.json(),
169171
),

src/murf/base_client.py

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This file was auto-generated by Fern from our API Definition.
22

3-
import typing
43
from .environment import MurfEnvironment
4+
import typing
55
import httpx
66
from .core.client_wrapper import SyncClientWrapper
77
from .auth.client import AuthClient
@@ -23,9 +23,6 @@ class BaseClient:
2323
2424
Parameters
2525
----------
26-
base_url : typing.Optional[str]
27-
The base url to use for requests from the client.
28-
2926
environment : MurfEnvironment
3027
The environment to use for requests from the client. from .environment import MurfEnvironment
3128
@@ -57,7 +54,6 @@ class BaseClient:
5754
def __init__(
5855
self,
5956
*,
60-
base_url: typing.Optional[str] = None,
6157
environment: MurfEnvironment = MurfEnvironment.DEFAULT,
6258
api_key: typing.Optional[str] = None,
6359
timeout: typing.Optional[float] = None,
@@ -66,7 +62,7 @@ def __init__(
6662
):
6763
_defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None
6864
self._client_wrapper = SyncClientWrapper(
69-
base_url=_get_base_url(base_url=base_url, environment=environment),
65+
environment=environment,
7066
api_key=api_key,
7167
httpx_client=httpx_client
7268
if httpx_client is not None
@@ -88,9 +84,6 @@ class AsyncBaseClient:
8884
8985
Parameters
9086
----------
91-
base_url : typing.Optional[str]
92-
The base url to use for requests from the client.
93-
9487
environment : MurfEnvironment
9588
The environment to use for requests from the client. from .environment import MurfEnvironment
9689
@@ -122,7 +115,6 @@ class AsyncBaseClient:
122115
def __init__(
123116
self,
124117
*,
125-
base_url: typing.Optional[str] = None,
126118
environment: MurfEnvironment = MurfEnvironment.DEFAULT,
127119
api_key: typing.Optional[str] = None,
128120
timeout: typing.Optional[float] = None,
@@ -131,7 +123,7 @@ def __init__(
131123
):
132124
_defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None
133125
self._client_wrapper = AsyncClientWrapper(
134-
base_url=_get_base_url(base_url=base_url, environment=environment),
126+
environment=environment,
135127
api_key=api_key,
136128
httpx_client=httpx_client
137129
if httpx_client is not None
@@ -145,12 +137,3 @@ def __init__(
145137
self.text = AsyncTextClient(client_wrapper=self._client_wrapper)
146138
self.voice_changer = AsyncVoiceChangerClient(client_wrapper=self._client_wrapper)
147139
self.dubbing = AsyncDubbingClient(client_wrapper=self._client_wrapper)
148-
149-
150-
def _get_base_url(*, base_url: typing.Optional[str] = None, environment: MurfEnvironment) -> str:
151-
if base_url is not None:
152-
return base_url
153-
elif environment is not None:
154-
return environment.value
155-
else:
156-
raise Exception("Please pass in either base_url or environment to construct the client")

src/murf/core/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from .remove_none_from_dict import remove_none_from_dict
2020
from .request_options import RequestOptions
2121
from .serialization import FieldMetadata, convert_and_respect_annotation_metadata
22+
from .unchecked_base_model import UncheckedBaseModel, UnionMetadata, construct_type
2223

2324
__all__ = [
2425
"ApiError",
@@ -31,8 +32,11 @@
3132
"IS_PYDANTIC_V2",
3233
"RequestOptions",
3334
"SyncClientWrapper",
35+
"UncheckedBaseModel",
36+
"UnionMetadata",
3437
"UniversalBaseModel",
3538
"UniversalRootModel",
39+
"construct_type",
3640
"convert_and_respect_annotation_metadata",
3741
"convert_file_dict_to_httpx_tuples",
3842
"encode_query",

src/murf/core/client_wrapper.py

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,36 @@
11
# This file was auto-generated by Fern from our API Definition.
22

33
import typing
4+
from ..environment import MurfEnvironment
45
import httpx
56
from .http_client import HttpClient
67
from .http_client import AsyncHttpClient
78

89

910
class BaseClientWrapper:
10-
def __init__(self, *, api_key: typing.Optional[str] = None, base_url: str, timeout: typing.Optional[float] = None):
11+
def __init__(
12+
self,
13+
*,
14+
api_key: typing.Optional[str] = None,
15+
environment: MurfEnvironment,
16+
timeout: typing.Optional[float] = None,
17+
):
1118
self._api_key = api_key
12-
self._base_url = base_url
19+
self._environment = environment
1320
self._timeout = timeout
1421

1522
def get_headers(self) -> typing.Dict[str, str]:
1623
headers: typing.Dict[str, str] = {
1724
"X-Fern-Language": "Python",
1825
"X-Fern-SDK-Name": "murf",
19-
"X-Fern-SDK-Version": "1.2.3",
26+
"X-Fern-SDK-Version": "2.0.0",
2027
}
2128
if self._api_key is not None:
2229
headers["api-key"] = self._api_key
2330
return headers
2431

25-
def get_base_url(self) -> str:
26-
return self._base_url
32+
def get_environment(self) -> MurfEnvironment:
33+
return self._environment
2734

2835
def get_timeout(self) -> typing.Optional[float]:
2936
return self._timeout
@@ -34,16 +41,13 @@ def __init__(
3441
self,
3542
*,
3643
api_key: typing.Optional[str] = None,
37-
base_url: str,
44+
environment: MurfEnvironment,
3845
timeout: typing.Optional[float] = None,
3946
httpx_client: httpx.Client,
4047
):
41-
super().__init__(api_key=api_key, base_url=base_url, timeout=timeout)
48+
super().__init__(api_key=api_key, environment=environment, timeout=timeout)
4249
self.httpx_client = HttpClient(
43-
httpx_client=httpx_client,
44-
base_headers=self.get_headers,
45-
base_timeout=self.get_timeout,
46-
base_url=self.get_base_url,
50+
httpx_client=httpx_client, base_headers=self.get_headers, base_timeout=self.get_timeout
4751
)
4852

4953

@@ -52,14 +56,11 @@ def __init__(
5256
self,
5357
*,
5458
api_key: typing.Optional[str] = None,
55-
base_url: str,
59+
environment: MurfEnvironment,
5660
timeout: typing.Optional[float] = None,
5761
httpx_client: httpx.AsyncClient,
5862
):
59-
super().__init__(api_key=api_key, base_url=base_url, timeout=timeout)
63+
super().__init__(api_key=api_key, environment=environment, timeout=timeout)
6064
self.httpx_client = AsyncHttpClient(
61-
httpx_client=httpx_client,
62-
base_headers=self.get_headers,
63-
base_timeout=self.get_timeout,
64-
base_url=self.get_base_url,
65+
httpx_client=httpx_client, base_headers=self.get_headers, base_timeout=self.get_timeout
6566
)

0 commit comments

Comments
 (0)