murf 1.2.0__py3-none-any.whl → 1.2.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of murf might be problematic. Click here for more details.

murf/__init__.py CHANGED
@@ -9,6 +9,7 @@ from .types import (
9
9
  ApiVoice,
10
10
  ApiVoiceGender,
11
11
  AuthTokenResponse,
12
+ CharacterCount,
12
13
  DubApiDetailResponse,
13
14
  DubJobStatusResponse,
14
15
  FormDataContentDisposition,
@@ -16,11 +17,15 @@ from .types import (
16
17
  GroupApiProjectResponse,
17
18
  LocaleResponse,
18
19
  LocaleResponseSupportsItem,
20
+ Metadata,
21
+ MurfApiTranslationResponse,
19
22
  PronunciationDetail,
20
23
  PronunciationDetailType,
21
24
  SourceLocaleResponse,
25
+ SpeechToSpeechResponse,
22
26
  StyleDetails,
23
- WordDuration,
27
+ Translation,
28
+ WordDurationResponse,
24
29
  )
25
30
  from .errors import (
26
31
  BadRequestError,
@@ -30,7 +35,7 @@ from .errors import (
30
35
  ServiceUnavailableError,
31
36
  UnauthorizedError,
32
37
  )
33
- from . import auth, dubbing, text_to_speech
38
+ from . import auth, dubbing, text, text_to_speech, voice_changer
34
39
  from .client import AsyncMurf, Murf
35
40
  from .dubbing_client import MurfDub
36
41
  from .environment import MurfEnvironment
@@ -48,6 +53,7 @@ __all__ = [
48
53
  "AsyncMurf",
49
54
  "AuthTokenResponse",
50
55
  "BadRequestError",
56
+ "CharacterCount",
51
57
  "DubApiDetailResponse",
52
58
  "DubJobStatusResponse",
53
59
  "ForbiddenError",
@@ -58,7 +64,9 @@ __all__ = [
58
64
  "InternalServerError",
59
65
  "LocaleResponse",
60
66
  "LocaleResponseSupportsItem",
67
+ "Metadata",
61
68
  "Murf",
69
+ "MurfApiTranslationResponse",
62
70
  "MurfDub",
63
71
  "MurfEnvironment",
64
72
  "PaymentRequiredError",
@@ -66,11 +74,15 @@ __all__ = [
66
74
  "PronunciationDetailType",
67
75
  "ServiceUnavailableError",
68
76
  "SourceLocaleResponse",
77
+ "SpeechToSpeechResponse",
69
78
  "StyleDetails",
79
+ "Translation",
70
80
  "UnauthorizedError",
71
- "WordDuration",
81
+ "WordDurationResponse",
72
82
  "__version__",
73
83
  "auth",
74
84
  "dubbing",
85
+ "text",
75
86
  "text_to_speech",
87
+ "voice_changer",
76
88
  ]
murf/base_client.py CHANGED
@@ -6,10 +6,14 @@ import httpx
6
6
  from .core.client_wrapper import SyncClientWrapper
7
7
  from .auth.client import AuthClient
8
8
  from .text_to_speech.client import TextToSpeechClient
9
+ from .text.client import TextClient
10
+ from .voice_changer.client import VoiceChangerClient
9
11
  from .dubbing.client import DubbingClient
10
12
  from .core.client_wrapper import AsyncClientWrapper
11
13
  from .auth.client import AsyncAuthClient
12
14
  from .text_to_speech.client import AsyncTextToSpeechClient
15
+ from .text.client import AsyncTextClient
16
+ from .voice_changer.client import AsyncVoiceChangerClient
13
17
  from .dubbing.client import AsyncDubbingClient
14
18
 
15
19
 
@@ -73,6 +77,8 @@ class BaseClient:
73
77
  )
74
78
  self.auth = AuthClient(client_wrapper=self._client_wrapper)
75
79
  self.text_to_speech = TextToSpeechClient(client_wrapper=self._client_wrapper)
80
+ self.text = TextClient(client_wrapper=self._client_wrapper)
81
+ self.voice_changer = VoiceChangerClient(client_wrapper=self._client_wrapper)
76
82
  self.dubbing = DubbingClient(client_wrapper=self._client_wrapper)
77
83
 
78
84
 
@@ -136,6 +142,8 @@ class AsyncBaseClient:
136
142
  )
137
143
  self.auth = AsyncAuthClient(client_wrapper=self._client_wrapper)
138
144
  self.text_to_speech = AsyncTextToSpeechClient(client_wrapper=self._client_wrapper)
145
+ self.text = AsyncTextClient(client_wrapper=self._client_wrapper)
146
+ self.voice_changer = AsyncVoiceChangerClient(client_wrapper=self._client_wrapper)
139
147
  self.dubbing = AsyncDubbingClient(client_wrapper=self._client_wrapper)
140
148
 
141
149
 
@@ -16,7 +16,7 @@ class BaseClientWrapper:
16
16
  headers: typing.Dict[str, str] = {
17
17
  "X-Fern-Language": "Python",
18
18
  "X-Fern-SDK-Name": "murf",
19
- "X-Fern-SDK-Version": "1.2.0",
19
+ "X-Fern-SDK-Version": "1.2.2",
20
20
  }
21
21
  if self._api_key is not None:
22
22
  headers["api-key"] = self._api_key
murf/text/__init__.py ADDED
@@ -0,0 +1,2 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
murf/text/client.py ADDED
@@ -0,0 +1,262 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+ from ..core.client_wrapper import SyncClientWrapper
5
+ from ..core.request_options import RequestOptions
6
+ from ..types.murf_api_translation_response import MurfApiTranslationResponse
7
+ from ..core.pydantic_utilities import parse_obj_as
8
+ from ..errors.bad_request_error import BadRequestError
9
+ from ..errors.payment_required_error import PaymentRequiredError
10
+ from ..errors.forbidden_error import ForbiddenError
11
+ from ..errors.internal_server_error import InternalServerError
12
+ from ..errors.service_unavailable_error import ServiceUnavailableError
13
+ from json.decoder import JSONDecodeError
14
+ from ..core.api_error import ApiError
15
+ from ..core.client_wrapper import AsyncClientWrapper
16
+
17
+ # this is used as the default value for optional parameters
18
+ OMIT = typing.cast(typing.Any, ...)
19
+
20
+
21
+ class TextClient:
22
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
23
+ self._client_wrapper = client_wrapper
24
+
25
+ def translate(
26
+ self,
27
+ *,
28
+ target_language: str,
29
+ texts: typing.Sequence[str],
30
+ request_options: typing.Optional[RequestOptions] = None,
31
+ ) -> MurfApiTranslationResponse:
32
+ """
33
+ Parameters
34
+ ----------
35
+ target_language : str
36
+ The language code for the target translation
37
+
38
+ texts : typing.Sequence[str]
39
+ List of texts to translate
40
+
41
+ request_options : typing.Optional[RequestOptions]
42
+ Request-specific configuration.
43
+
44
+ Returns
45
+ -------
46
+ MurfApiTranslationResponse
47
+ Ok
48
+
49
+ Examples
50
+ --------
51
+ from murf import Murf
52
+
53
+ client = Murf(
54
+ api_key="YOUR_API_KEY",
55
+ )
56
+ client.text.translate(
57
+ target_language="es-ES",
58
+ texts=["Hello, world.", "How are you?"],
59
+ )
60
+ """
61
+ _response = self._client_wrapper.httpx_client.request(
62
+ "v1/text/translate",
63
+ method="POST",
64
+ json={
65
+ "targetLanguage": target_language,
66
+ "texts": texts,
67
+ },
68
+ headers={
69
+ "content-type": "application/json",
70
+ },
71
+ request_options=request_options,
72
+ omit=OMIT,
73
+ )
74
+ try:
75
+ if 200 <= _response.status_code < 300:
76
+ return typing.cast(
77
+ MurfApiTranslationResponse,
78
+ parse_obj_as(
79
+ type_=MurfApiTranslationResponse, # type: ignore
80
+ object_=_response.json(),
81
+ ),
82
+ )
83
+ if _response.status_code == 400:
84
+ raise BadRequestError(
85
+ typing.cast(
86
+ typing.Optional[typing.Any],
87
+ parse_obj_as(
88
+ type_=typing.Optional[typing.Any], # type: ignore
89
+ object_=_response.json(),
90
+ ),
91
+ )
92
+ )
93
+ if _response.status_code == 402:
94
+ raise PaymentRequiredError(
95
+ typing.cast(
96
+ typing.Optional[typing.Any],
97
+ parse_obj_as(
98
+ type_=typing.Optional[typing.Any], # type: ignore
99
+ object_=_response.json(),
100
+ ),
101
+ )
102
+ )
103
+ if _response.status_code == 403:
104
+ raise ForbiddenError(
105
+ typing.cast(
106
+ typing.Optional[typing.Any],
107
+ parse_obj_as(
108
+ type_=typing.Optional[typing.Any], # type: ignore
109
+ object_=_response.json(),
110
+ ),
111
+ )
112
+ )
113
+ if _response.status_code == 500:
114
+ raise InternalServerError(
115
+ typing.cast(
116
+ typing.Optional[typing.Any],
117
+ parse_obj_as(
118
+ type_=typing.Optional[typing.Any], # type: ignore
119
+ object_=_response.json(),
120
+ ),
121
+ )
122
+ )
123
+ if _response.status_code == 503:
124
+ raise ServiceUnavailableError(
125
+ typing.cast(
126
+ typing.Optional[typing.Any],
127
+ parse_obj_as(
128
+ type_=typing.Optional[typing.Any], # type: ignore
129
+ object_=_response.json(),
130
+ ),
131
+ )
132
+ )
133
+ _response_json = _response.json()
134
+ except JSONDecodeError:
135
+ raise ApiError(status_code=_response.status_code, body=_response.text)
136
+ raise ApiError(status_code=_response.status_code, body=_response_json)
137
+
138
+
139
+ class AsyncTextClient:
140
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
141
+ self._client_wrapper = client_wrapper
142
+
143
+ async def translate(
144
+ self,
145
+ *,
146
+ target_language: str,
147
+ texts: typing.Sequence[str],
148
+ request_options: typing.Optional[RequestOptions] = None,
149
+ ) -> MurfApiTranslationResponse:
150
+ """
151
+ Parameters
152
+ ----------
153
+ target_language : str
154
+ The language code for the target translation
155
+
156
+ texts : typing.Sequence[str]
157
+ List of texts to translate
158
+
159
+ request_options : typing.Optional[RequestOptions]
160
+ Request-specific configuration.
161
+
162
+ Returns
163
+ -------
164
+ MurfApiTranslationResponse
165
+ Ok
166
+
167
+ Examples
168
+ --------
169
+ import asyncio
170
+
171
+ from murf import AsyncMurf
172
+
173
+ client = AsyncMurf(
174
+ api_key="YOUR_API_KEY",
175
+ )
176
+
177
+
178
+ async def main() -> None:
179
+ await client.text.translate(
180
+ target_language="es-ES",
181
+ texts=["Hello, world.", "How are you?"],
182
+ )
183
+
184
+
185
+ asyncio.run(main())
186
+ """
187
+ _response = await self._client_wrapper.httpx_client.request(
188
+ "v1/text/translate",
189
+ method="POST",
190
+ json={
191
+ "targetLanguage": target_language,
192
+ "texts": texts,
193
+ },
194
+ headers={
195
+ "content-type": "application/json",
196
+ },
197
+ request_options=request_options,
198
+ omit=OMIT,
199
+ )
200
+ try:
201
+ if 200 <= _response.status_code < 300:
202
+ return typing.cast(
203
+ MurfApiTranslationResponse,
204
+ parse_obj_as(
205
+ type_=MurfApiTranslationResponse, # type: ignore
206
+ object_=_response.json(),
207
+ ),
208
+ )
209
+ if _response.status_code == 400:
210
+ raise BadRequestError(
211
+ typing.cast(
212
+ typing.Optional[typing.Any],
213
+ parse_obj_as(
214
+ type_=typing.Optional[typing.Any], # type: ignore
215
+ object_=_response.json(),
216
+ ),
217
+ )
218
+ )
219
+ if _response.status_code == 402:
220
+ raise PaymentRequiredError(
221
+ typing.cast(
222
+ typing.Optional[typing.Any],
223
+ parse_obj_as(
224
+ type_=typing.Optional[typing.Any], # type: ignore
225
+ object_=_response.json(),
226
+ ),
227
+ )
228
+ )
229
+ if _response.status_code == 403:
230
+ raise ForbiddenError(
231
+ typing.cast(
232
+ typing.Optional[typing.Any],
233
+ parse_obj_as(
234
+ type_=typing.Optional[typing.Any], # type: ignore
235
+ object_=_response.json(),
236
+ ),
237
+ )
238
+ )
239
+ if _response.status_code == 500:
240
+ raise InternalServerError(
241
+ typing.cast(
242
+ typing.Optional[typing.Any],
243
+ parse_obj_as(
244
+ type_=typing.Optional[typing.Any], # type: ignore
245
+ object_=_response.json(),
246
+ ),
247
+ )
248
+ )
249
+ if _response.status_code == 503:
250
+ raise ServiceUnavailableError(
251
+ typing.cast(
252
+ typing.Optional[typing.Any],
253
+ parse_obj_as(
254
+ type_=typing.Optional[typing.Any], # type: ignore
255
+ object_=_response.json(),
256
+ ),
257
+ )
258
+ )
259
+ _response_json = _response.json()
260
+ except JSONDecodeError:
261
+ raise ApiError(status_code=_response.status_code, body=_response.text)
262
+ raise ApiError(status_code=_response.status_code, body=_response_json)