magic_hour 0.40.0__py3-none-any.whl → 0.44.0__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.
Files changed (73) hide show
  1. magic_hour/README.md +2 -3
  2. magic_hour/environment.py +1 -1
  3. magic_hour/helpers/download.py +2 -0
  4. magic_hour/resources/v1/README.md +2 -3
  5. magic_hour/resources/v1/ai_clothes_changer/README.md +13 -14
  6. magic_hour/resources/v1/ai_face_editor/README.md +26 -27
  7. magic_hour/resources/v1/ai_gif_generator/README.md +12 -13
  8. magic_hour/resources/v1/ai_gif_generator/client.py +2 -2
  9. magic_hour/resources/v1/ai_headshot_generator/README.md +13 -14
  10. magic_hour/resources/v1/ai_headshot_generator/client.py +2 -2
  11. magic_hour/resources/v1/ai_image_editor/README.md +24 -17
  12. magic_hour/resources/v1/ai_image_editor/client.py +40 -10
  13. magic_hour/resources/v1/ai_image_generator/README.md +26 -18
  14. magic_hour/resources/v1/ai_image_generator/client.py +14 -6
  15. magic_hour/resources/v1/ai_image_upscaler/README.md +14 -15
  16. magic_hour/resources/v1/ai_meme_generator/README.md +12 -13
  17. magic_hour/resources/v1/ai_photo_editor/README.md +22 -23
  18. magic_hour/resources/v1/ai_qr_code_generator/README.md +13 -14
  19. magic_hour/resources/v1/ai_qr_code_generator/client.py +4 -4
  20. magic_hour/resources/v1/ai_talking_photo/README.md +16 -17
  21. magic_hour/resources/v1/ai_voice_cloner/README.md +62 -0
  22. magic_hour/resources/v1/ai_voice_cloner/__init__.py +4 -0
  23. magic_hour/resources/v1/ai_voice_cloner/client.py +272 -0
  24. magic_hour/resources/v1/ai_voice_generator/README.md +66 -10
  25. magic_hour/resources/v1/ai_voice_generator/client.py +122 -0
  26. magic_hour/resources/v1/animation/README.md +24 -25
  27. magic_hour/resources/v1/audio_projects/README.md +58 -13
  28. magic_hour/resources/v1/audio_projects/__init__.py +10 -2
  29. magic_hour/resources/v1/audio_projects/client.py +137 -0
  30. magic_hour/resources/v1/audio_projects/client_test.py +520 -0
  31. magic_hour/resources/v1/auto_subtitle_generator/README.md +15 -16
  32. magic_hour/resources/v1/client.py +6 -0
  33. magic_hour/resources/v1/face_detection/README.md +21 -20
  34. magic_hour/resources/v1/face_swap/README.md +23 -25
  35. magic_hour/resources/v1/face_swap/client.py +2 -2
  36. magic_hour/resources/v1/face_swap_photo/README.md +13 -14
  37. magic_hour/resources/v1/files/README.md +1 -5
  38. magic_hour/resources/v1/files/upload_urls/README.md +11 -10
  39. magic_hour/resources/v1/files/upload_urls/client.py +6 -4
  40. magic_hour/resources/v1/image_background_remover/README.md +11 -12
  41. magic_hour/resources/v1/image_projects/README.md +12 -16
  42. magic_hour/resources/v1/image_to_video/README.md +19 -21
  43. magic_hour/resources/v1/lip_sync/README.md +27 -21
  44. magic_hour/resources/v1/lip_sync/client.py +15 -0
  45. magic_hour/resources/v1/photo_colorizer/README.md +10 -11
  46. magic_hour/resources/v1/text_to_video/README.md +15 -17
  47. magic_hour/resources/v1/video_projects/README.md +12 -16
  48. magic_hour/resources/v1/video_to_video/README.md +24 -26
  49. magic_hour/types/models/__init__.py +2 -0
  50. magic_hour/types/models/v1_ai_voice_cloner_create_response.py +27 -0
  51. magic_hour/types/models/v1_audio_projects_get_response.py +1 -1
  52. magic_hour/types/models/v1_video_projects_get_response.py +1 -1
  53. magic_hour/types/params/__init__.py +26 -0
  54. magic_hour/types/params/v1_ai_image_editor_create_body_assets.py +18 -4
  55. magic_hour/types/params/v1_ai_image_editor_create_body_style.py +13 -0
  56. magic_hour/types/params/v1_ai_image_editor_generate_body_assets.py +12 -1
  57. magic_hour/types/params/v1_ai_image_generator_create_body_style.py +16 -0
  58. magic_hour/types/params/v1_ai_talking_photo_create_body_style.py +6 -4
  59. magic_hour/types/params/v1_ai_voice_cloner_create_body.py +49 -0
  60. magic_hour/types/params/v1_ai_voice_cloner_create_body_assets.py +33 -0
  61. magic_hour/types/params/v1_ai_voice_cloner_create_body_style.py +28 -0
  62. magic_hour/types/params/v1_ai_voice_cloner_generate_body_assets.py +28 -0
  63. magic_hour/types/params/v1_ai_voice_generator_create_body_style.py +382 -2
  64. magic_hour/types/params/v1_face_swap_create_body_style.py +1 -1
  65. magic_hour/types/params/v1_files_upload_urls_create_body_items_item.py +1 -1
  66. magic_hour/types/params/v1_lip_sync_create_body.py +12 -0
  67. magic_hour/types/params/v1_lip_sync_create_body_style.py +37 -0
  68. magic_hour/types/params/v1_video_to_video_create_body.py +1 -1
  69. magic_hour/types/params/v1_video_to_video_create_body_style.py +32 -4
  70. {magic_hour-0.40.0.dist-info → magic_hour-0.44.0.dist-info}/METADATA +77 -62
  71. {magic_hour-0.40.0.dist-info → magic_hour-0.44.0.dist-info}/RECORD +73 -63
  72. {magic_hour-0.40.0.dist-info → magic_hour-0.44.0.dist-info}/LICENSE +0 -0
  73. {magic_hour-0.40.0.dist-info → magic_hour-0.44.0.dist-info}/WHEEL +0 -0
@@ -2,8 +2,6 @@
2
2
 
3
3
  ## Module Functions
4
4
 
5
-
6
-
7
5
  <!-- CUSTOM DOCS START -->
8
6
 
9
7
  ### Ai Talking Photo Generate Workflow <a name="generate"></a>
@@ -69,6 +67,7 @@ res = await client.v1.ai_talking_photo.generate(
69
67
  ```
70
68
 
71
69
  <!-- CUSTOM DOCS END -->
70
+
72
71
  ### AI Talking Photo <a name="create"></a>
73
72
 
74
73
  Create a talking photo from an image and audio or text input.
@@ -77,17 +76,17 @@ Create a talking photo from an image and audio or text input.
77
76
 
78
77
  #### Parameters
79
78
 
80
- | Parameter | Required | Description | Example |
81
- |-----------|:--------:|-------------|--------|
82
- | `assets` | | Provide the assets for creating a talking photo | `{"audio_file_path": "api-assets/id/1234.mp3", "image_file_path": "api-assets/id/1234.png"}` |
83
- | `└─ audio_file_path` | | The audio file to sync with the image. This value is either - a direct URL to the video file - `file_path` field from the response of the [upload urls API](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls). Please refer to the [Input File documentation](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls#input-file) to learn more. | `"api-assets/id/1234.mp3"` |
84
- | `└─ image_file_path` | | The source image to animate. This value is either - a direct URL to the video file - `file_path` field from the response of the [upload urls API](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls). Please refer to the [Input File documentation](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls#input-file) to learn more. | `"api-assets/id/1234.png"` |
85
- | `end_seconds` | | The end time of the input audio in seconds. The maximum duration allowed is 60 seconds. | `15.0` |
86
- | `start_seconds` | | The start time of the input audio in seconds. The maximum duration allowed is 60 seconds. | `0.0` |
87
- | `name` | | The name of image. This value is mainly used for your own identification of the image. | `"Talking Photo image"` |
88
- | `style` | | Attributes used to dictate the style of the output | `{"generation_mode": "expressive", "intensity": 1.5}` |
89
- | `└─ generation_mode` | | Controls overall motion style. * `pro` - Realistic, high fidelity, accurate lip sync, slower. * `expressive` - More motion and facial expressiveness; may introduce visual artifacts. * `stable` - Reduced motion for cleaner output; may result in minimal animation. (Deprecated: passing this value will be treated as `pro`) | `"expressive"` |
90
- | `└─ intensity` | | Note: this value is only applicable when generation_mode is `expressive`. The value can include up to 2 decimal places. * Lower values yield more stability but can suppress mouth movement. * Higher values increase motion and expressiveness, with a higher risk of distortion. | `1.5` |
79
+ | Parameter | Required | Description | Example |
80
+ | -------------------- | :------: | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- |
81
+ | `assets` | | Provide the assets for creating a talking photo | `{"audio_file_path": "api-assets/id/1234.mp3", "image_file_path": "api-assets/id/1234.png"}` |
82
+ | `└─ audio_file_path` | | The audio file to sync with the image. This value is either - a direct URL to the video file - `file_path` field from the response of the [upload urls API](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls). Please refer to the [Input File documentation](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls#input-file) to learn more. | `"api-assets/id/1234.mp3"` |
83
+ | `└─ image_file_path` | | The source image to animate. This value is either - a direct URL to the video file - `file_path` field from the response of the [upload urls API](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls). Please refer to the [Input File documentation](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls#input-file) to learn more. | `"api-assets/id/1234.png"` |
84
+ | `end_seconds` | | The end time of the input audio in seconds. The maximum duration allowed is 60 seconds. | `15.0` |
85
+ | `start_seconds` | | The start time of the input audio in seconds. The maximum duration allowed is 60 seconds. | `0.0` |
86
+ | `name` | | The name of image. This value is mainly used for your own identification of the image. | `"Talking Photo image"` |
87
+ | `style` | | Attributes used to dictate the style of the output | `{"generation_mode": "pro", "intensity": 1.5}` |
88
+ | `└─ generation_mode` | | Controls overall motion style. * `pro` - Higher fidelity, realistic detail, accurate lip sync, and faster generation. * `standard` - More expressive motion, but lower visual fidelity. * `expressive` - More motion and facial expressiveness; may introduce visual artifacts. (Deprecated: passing this value will be treated as `standard`) * `stable` - Reduced motion for cleaner output; may result in minimal animation. (Deprecated: passing this value will be treated as `pro`) | `"pro"` |
89
+ | `└─ intensity` | | Note: this value is only applicable when generation_mode is `expressive`. The value can include up to 2 decimal places. * Lower values yield more stability but can suppress mouth movement. * Higher values increase motion and expressiveness, with a higher risk of distortion. | `1.5` |
91
90
 
92
91
  #### Synchronous Client
93
92
 
@@ -105,7 +104,6 @@ res = client.v1.ai_talking_photo.create(
105
104
  start_seconds=0.0,
106
105
  name="Talking Photo image",
107
106
  )
108
-
109
107
  ```
110
108
 
111
109
  #### Asynchronous Client
@@ -124,15 +122,16 @@ res = await client.v1.ai_talking_photo.create(
124
122
  start_seconds=0.0,
125
123
  name="Talking Photo image",
126
124
  )
127
-
128
125
  ```
129
126
 
130
127
  #### Response
131
128
 
132
129
  ##### Type
130
+
133
131
  [V1AiTalkingPhotoCreateResponse](/magic_hour/types/models/v1_ai_talking_photo_create_response.py)
134
132
 
135
133
  ##### Example
136
- `{"credits_charged": 450, "estimated_frame_cost": 450, "id": "cuid-example"}`
137
-
138
134
 
135
+ ```python
136
+ {"credits_charged": 450, "estimated_frame_cost": 450, "id": "cuid-example"}
137
+ ```
@@ -0,0 +1,62 @@
1
+ # v1.ai_voice_cloner
2
+
3
+ ## Module Functions
4
+
5
+ ### AI Voice Cloner <a name="create"></a>
6
+
7
+ Clone a voice from an audio sample and generate speech.
8
+
9
+ - Each character costs 0.05 credits.
10
+ - The cost is rounded up to the nearest whole number
11
+
12
+ **API Endpoint**: `POST /v1/ai-voice-cloner`
13
+
14
+ #### Parameters
15
+
16
+ | Parameter | Required | Description | Example |
17
+ | -------------------- | :------: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------- |
18
+ | `assets` | ✓ | Provide the assets for voice cloning. | `{"audio_file_path": "api-assets/id/1234.mp3"}` |
19
+ | `└─ audio_file_path` | ✓ | The audio used to clone the voice. This value is either - a direct URL to the video file - `file_path` field from the response of the [upload urls API](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls). Please refer to the [Input File documentation](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls#input-file) to learn more. | `"api-assets/id/1234.mp3"` |
20
+ | `style` | ✓ | | `{"prompt": "Hello, this is my cloned voice."}` |
21
+ | `└─ prompt` | ✓ | Text used to generate speech from the cloned voice. The character limit is 1000 characters. | `"Hello, this is my cloned voice."` |
22
+ | `name` | ✗ | The name of audio. This value is mainly used for your own identification of the audio. | `"Voice Cloner audio"` |
23
+
24
+ #### Synchronous Client
25
+
26
+ ```python
27
+ from magic_hour import Client
28
+ from os import getenv
29
+
30
+ client = Client(token=getenv("API_TOKEN"))
31
+ res = client.v1.ai_voice_cloner.create(
32
+ assets={"audio_file_path": "api-assets/id/1234.mp3"},
33
+ style={"prompt": "Hello, this is my cloned voice."},
34
+ name="Voice Cloner audio",
35
+ )
36
+ ```
37
+
38
+ #### Asynchronous Client
39
+
40
+ ```python
41
+ from magic_hour import AsyncClient
42
+ from os import getenv
43
+
44
+ client = AsyncClient(token=getenv("API_TOKEN"))
45
+ res = await client.v1.ai_voice_cloner.create(
46
+ assets={"audio_file_path": "api-assets/id/1234.mp3"},
47
+ style={"prompt": "Hello, this is my cloned voice."},
48
+ name="Voice Cloner audio",
49
+ )
50
+ ```
51
+
52
+ #### Response
53
+
54
+ ##### Type
55
+
56
+ [V1AiVoiceClonerCreateResponse](/magic_hour/types/models/v1_ai_voice_cloner_create_response.py)
57
+
58
+ ##### Example
59
+
60
+ ```python
61
+ {"credits_charged": 1, "id": "cuid-example"}
62
+ ```
@@ -0,0 +1,4 @@
1
+ from .client import AiVoiceClonerClient, AsyncAiVoiceClonerClient
2
+
3
+
4
+ __all__ = ["AiVoiceClonerClient", "AsyncAiVoiceClonerClient"]
@@ -0,0 +1,272 @@
1
+ import typing
2
+
3
+ from magic_hour.helpers.logger import get_sdk_logger
4
+ from magic_hour.resources.v1.audio_projects.client import (
5
+ AsyncAudioProjectsClient,
6
+ AudioProjectsClient,
7
+ )
8
+ from magic_hour.resources.v1.files.client import AsyncFilesClient, FilesClient
9
+ from magic_hour.types import models, params
10
+ from make_api_request import (
11
+ AsyncBaseClient,
12
+ RequestOptions,
13
+ SyncBaseClient,
14
+ default_request_options,
15
+ to_encodable,
16
+ type_utils,
17
+ )
18
+
19
+
20
+ logger = get_sdk_logger(__name__)
21
+
22
+
23
+ class AiVoiceClonerClient:
24
+ def __init__(self, *, base_client: SyncBaseClient):
25
+ self._base_client = base_client
26
+
27
+ def generate(
28
+ self,
29
+ *,
30
+ assets: params.V1AiVoiceClonerGenerateBodyAssets,
31
+ style: params.V1AiVoiceClonerCreateBodyStyle,
32
+ name: typing.Union[
33
+ typing.Optional[str], type_utils.NotGiven
34
+ ] = type_utils.NOT_GIVEN,
35
+ wait_for_completion: bool = True,
36
+ download_outputs: bool = True,
37
+ download_directory: typing.Optional[str] = None,
38
+ request_options: typing.Optional[RequestOptions] = None,
39
+ ):
40
+ """
41
+ Generate cloned voice audio (alias for create with additional functionality).
42
+
43
+ Clone a voice from an audio sample and generate speech with automatic file upload,
44
+ completion waiting, and output downloading.
45
+
46
+ Args:
47
+ assets: Provide the assets for voice cloning (local file paths will be auto-uploaded)
48
+ style: Voice cloning style parameters including the text prompt
49
+ name: The name of audio. This value is mainly used for your own identification of the audio.
50
+ wait_for_completion: Whether to wait for the audio project to complete
51
+ download_outputs: Whether to download the outputs
52
+ download_directory: The directory to download the outputs to. If not provided, the outputs will be downloaded to the current working directory
53
+ request_options: Additional options to customize the HTTP request
54
+
55
+ Returns:
56
+ V1AudioProjectsGetResponseWithDownloads: The response from the AI Voice Cloner API with the downloaded paths if `download_outputs` is True.
57
+
58
+ Examples:
59
+ ```py
60
+ response = client.v1.ai_voice_cloner.generate(
61
+ assets={"audio_file_path": "path/to/voice_sample.mp3"},
62
+ style={"prompt": "Hello, this is my cloned voice speaking."},
63
+ name="Cloned Voice Audio",
64
+ wait_for_completion=True,
65
+ download_outputs=True,
66
+ download_directory="outputs/",
67
+ )
68
+ ```
69
+ """
70
+
71
+ file_client = FilesClient(base_client=self._base_client)
72
+
73
+ audio_file_path = assets["audio_file_path"]
74
+ assets["audio_file_path"] = file_client.upload_file(file=audio_file_path)
75
+
76
+ create_response = self.create(
77
+ assets=assets,
78
+ style=style,
79
+ name=name,
80
+ request_options=request_options,
81
+ )
82
+ logger.info(f"AI Voice Cloner response: {create_response}")
83
+
84
+ audio_projects_client = AudioProjectsClient(base_client=self._base_client)
85
+ response = audio_projects_client.check_result(
86
+ id=create_response.id,
87
+ wait_for_completion=wait_for_completion,
88
+ download_outputs=download_outputs,
89
+ download_directory=download_directory,
90
+ )
91
+
92
+ return response
93
+
94
+ def create(
95
+ self,
96
+ *,
97
+ assets: params.V1AiVoiceClonerCreateBodyAssets,
98
+ style: params.V1AiVoiceClonerCreateBodyStyle,
99
+ name: typing.Union[
100
+ typing.Optional[str], type_utils.NotGiven
101
+ ] = type_utils.NOT_GIVEN,
102
+ request_options: typing.Optional[RequestOptions] = None,
103
+ ) -> models.V1AiVoiceClonerCreateResponse:
104
+ """
105
+ AI Voice Cloner
106
+
107
+ Clone a voice from an audio sample and generate speech.
108
+ * Each character costs 0.05 credits.
109
+ * The cost is rounded up to the nearest whole number
110
+
111
+ POST /v1/ai-voice-cloner
112
+
113
+ Args:
114
+ name: The name of audio. This value is mainly used for your own identification of the audio.
115
+ assets: Provide the assets for voice cloning.
116
+ style: V1AiVoiceClonerCreateBodyStyle
117
+ request_options: Additional options to customize the HTTP request
118
+
119
+ Returns:
120
+ Success
121
+
122
+ Raises:
123
+ ApiError: A custom exception class that provides additional context
124
+ for API errors, including the HTTP status code and response body.
125
+
126
+ Examples:
127
+ ```py
128
+ client.v1.ai_voice_cloner.create(
129
+ assets={"audio_file_path": "api-assets/id/1234.mp3"},
130
+ style={"prompt": "Hello, this is my cloned voice."},
131
+ name="Voice Cloner audio",
132
+ )
133
+ ```
134
+ """
135
+ _json = to_encodable(
136
+ item={"name": name, "assets": assets, "style": style},
137
+ dump_with=params._SerializerV1AiVoiceClonerCreateBody,
138
+ )
139
+ return self._base_client.request(
140
+ method="POST",
141
+ path="/v1/ai-voice-cloner",
142
+ auth_names=["bearerAuth"],
143
+ json=_json,
144
+ cast_to=models.V1AiVoiceClonerCreateResponse,
145
+ request_options=request_options or default_request_options(),
146
+ )
147
+
148
+
149
+ class AsyncAiVoiceClonerClient:
150
+ def __init__(self, *, base_client: AsyncBaseClient):
151
+ self._base_client = base_client
152
+
153
+ async def generate(
154
+ self,
155
+ *,
156
+ assets: params.V1AiVoiceClonerGenerateBodyAssets,
157
+ style: params.V1AiVoiceClonerCreateBodyStyle,
158
+ name: typing.Union[
159
+ typing.Optional[str], type_utils.NotGiven
160
+ ] = type_utils.NOT_GIVEN,
161
+ wait_for_completion: bool = True,
162
+ download_outputs: bool = True,
163
+ download_directory: typing.Optional[str] = None,
164
+ request_options: typing.Optional[RequestOptions] = None,
165
+ ):
166
+ """
167
+ Generate cloned voice audio (alias for create with additional functionality).
168
+
169
+ Clone a voice from an audio sample and generate speech with automatic file upload,
170
+ completion waiting, and output downloading.
171
+
172
+ Args:
173
+ assets: Provide the assets for voice cloning (local file paths will be auto-uploaded)
174
+ style: Voice cloning style parameters including the text prompt
175
+ name: The name of audio. This value is mainly used for your own identification of the audio.
176
+ wait_for_completion: Whether to wait for the audio project to complete
177
+ download_outputs: Whether to download the outputs
178
+ download_directory: The directory to download the outputs to. If not provided, the outputs will be downloaded to the current working directory
179
+ request_options: Additional options to customize the HTTP request
180
+
181
+ Returns:
182
+ V1AudioProjectsGetResponseWithDownloads: The response from the AI Voice Cloner API with the downloaded paths if `download_outputs` is True.
183
+
184
+ Examples:
185
+ ```py
186
+ response = await client.v1.ai_voice_cloner.generate(
187
+ assets={"audio_file_path": "path/to/voice_sample.mp3"},
188
+ style={"prompt": "Hello, this is my cloned voice speaking."},
189
+ name="Cloned Voice Audio",
190
+ wait_for_completion=True,
191
+ download_outputs=True,
192
+ download_directory="outputs/",
193
+ )
194
+ ```
195
+ """
196
+
197
+ file_client = AsyncFilesClient(base_client=self._base_client)
198
+
199
+ audio_file_path = assets["audio_file_path"]
200
+ assets["audio_file_path"] = await file_client.upload_file(file=audio_file_path)
201
+
202
+ create_response = await self.create(
203
+ assets=assets,
204
+ style=style,
205
+ name=name,
206
+ request_options=request_options,
207
+ )
208
+ logger.info(f"AI Voice Cloner response: {create_response}")
209
+
210
+ audio_projects_client = AsyncAudioProjectsClient(base_client=self._base_client)
211
+ response = await audio_projects_client.check_result(
212
+ id=create_response.id,
213
+ wait_for_completion=wait_for_completion,
214
+ download_outputs=download_outputs,
215
+ download_directory=download_directory,
216
+ )
217
+
218
+ return response
219
+
220
+ async def create(
221
+ self,
222
+ *,
223
+ assets: params.V1AiVoiceClonerCreateBodyAssets,
224
+ style: params.V1AiVoiceClonerCreateBodyStyle,
225
+ name: typing.Union[
226
+ typing.Optional[str], type_utils.NotGiven
227
+ ] = type_utils.NOT_GIVEN,
228
+ request_options: typing.Optional[RequestOptions] = None,
229
+ ) -> models.V1AiVoiceClonerCreateResponse:
230
+ """
231
+ AI Voice Cloner
232
+
233
+ Clone a voice from an audio sample and generate speech.
234
+ * Each character costs 0.05 credits.
235
+ * The cost is rounded up to the nearest whole number
236
+
237
+ POST /v1/ai-voice-cloner
238
+
239
+ Args:
240
+ name: The name of audio. This value is mainly used for your own identification of the audio.
241
+ assets: Provide the assets for voice cloning.
242
+ style: V1AiVoiceClonerCreateBodyStyle
243
+ request_options: Additional options to customize the HTTP request
244
+
245
+ Returns:
246
+ Success
247
+
248
+ Raises:
249
+ ApiError: A custom exception class that provides additional context
250
+ for API errors, including the HTTP status code and response body.
251
+
252
+ Examples:
253
+ ```py
254
+ await client.v1.ai_voice_cloner.create(
255
+ assets={"audio_file_path": "api-assets/id/1234.mp3"},
256
+ style={"prompt": "Hello, this is my cloned voice."},
257
+ name="Voice Cloner audio",
258
+ )
259
+ ```
260
+ """
261
+ _json = to_encodable(
262
+ item={"name": name, "assets": assets, "style": style},
263
+ dump_with=params._SerializerV1AiVoiceClonerCreateBody,
264
+ )
265
+ return await self._base_client.request(
266
+ method="POST",
267
+ path="/v1/ai-voice-cloner",
268
+ auth_names=["bearerAuth"],
269
+ json=_json,
270
+ cast_to=models.V1AiVoiceClonerCreateResponse,
271
+ request_options=request_options or default_request_options(),
272
+ )
@@ -2,6 +2,62 @@
2
2
 
3
3
  ## Module Functions
4
4
 
5
+ <!-- CUSTOM DOCS START -->
6
+
7
+ ### Ai Talking Photo Generate Workflow <a name="generate"></a>
8
+
9
+ The workflow performs the following action
10
+
11
+ 1. upload local assets to Magic Hour storage. So you can pass in a local path instead of having to upload files yourself
12
+ 2. trigger a generation
13
+ 3. poll for a completion status. This is configurable
14
+ 4. if success, download the output to local directory
15
+
16
+ > [!TIP]
17
+ > This is the recommended way to use the SDK unless you have specific needs where it is necessary to split up the actions.
18
+
19
+ #### Parameters
20
+
21
+ In Additional to the parameters listed in the `.create` section below, `.generate` introduces 3 new parameters:
22
+
23
+ - `wait_for_completion` (bool, default True): Whether to wait for the project to complete.
24
+ - `download_outputs` (bool, default True): Whether to download the generated files
25
+ - `download_directory` (str, optional): Directory to save downloaded files (defaults to current directory)
26
+
27
+ #### Synchronous Client
28
+
29
+ ```python
30
+ from magic_hour import Client
31
+ from os import getenv
32
+
33
+ client = Client(token=getenv("API_TOKEN"))
34
+ res = client.v1.ai_voice_generator.generate(
35
+ style={"prompt": "Hello, how are you?", "voice_name": "Elon Musk"},
36
+ name="Voice Generator audio",
37
+ wait_for_completion=True,
38
+ download_outputs=True,
39
+ download_directory="outputs"
40
+ )
41
+ ```
42
+
43
+ #### Asynchronous Client
44
+
45
+ ```python
46
+ from magic_hour import AsyncClient
47
+ from os import getenv
48
+
49
+ client = AsyncClient(token=getenv("API_TOKEN"))
50
+ res = await client.v1.ai_voice_generator.generate(
51
+ style={"prompt": "Hello, how are you?", "voice_name": "Elon Musk"},
52
+ name="Voice Generator audio",
53
+ wait_for_completion=True,
54
+ download_outputs=True,
55
+ download_directory="outputs"
56
+ )
57
+ ```
58
+
59
+ <!-- CUSTOM DOCS END -->
60
+
5
61
  ### AI Voice Generator <a name="create"></a>
6
62
 
7
63
  Generate speech from text. Each character costs 0.05 credits. The cost is rounded up to the nearest whole number.
@@ -10,12 +66,12 @@ Generate speech from text. Each character costs 0.05 credits. The cost is rounde
10
66
 
11
67
  #### Parameters
12
68
 
13
- | Parameter | Required | Description | Example |
14
- |-----------|:--------:|-------------|--------|
15
- | `style` | | The content used to generate speech. | `{"prompt": "Hello, how are you?", "voice_name": "Elon Musk"}` |
16
- | `└─ prompt` | | Text used to generate speech. Starter tier users can use up to 200 characters, while Creator, Pro, or Business users can use up to 1000. | `"Hello, how are you?"` |
17
- | `└─ voice_name` | | The voice to use for the speech. Available voices: Elon Musk, Mark Zuckerberg, Joe Rogan, Barack Obama, Morgan Freeman, Kanye West, Donald Trump, Joe Biden, Kim Kardashian, Taylor Swift | `"Elon Musk"` |
18
- | `name` | | The name of audio. This value is mainly used for your own identification of the audio. | `"Voice Generator audio"` |
69
+ | Parameter | Required | Description | Example |
70
+ | --------------- | :------: | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------- |
71
+ | `style` | | The content used to generate speech. | `{"prompt": "Hello, how are you?", "voice_name": "Elon Musk"}` |
72
+ | `└─ prompt` | | Text used to generate speech. Starter tier users can use up to 1000 characters, while Creator, Pro, or Business users can use up to 1000. | `"Hello, how are you?"` |
73
+ | `└─ voice_name` | | The voice to use for the speech. Available voices: Elon Musk, Mark Zuckerberg, Joe Rogan, Barack Obama, Morgan Freeman, Kanye West, Donald Trump, Joe Biden, Kim Kardashian, Taylor Swift, James Earl Jones, Samuel L. Jackson, Jeff Goldblum, David Attenborough, Sean Connery, Cillian Murphy, Anne Hathaway, Julia Roberts, Natalie Portman, Steve Carell, Amy Poehler, Stephen Colbert, Jimmy Fallon, David Letterman, Alex Trebek, Katy Perry, Prince, Kevin Bacon, Tom Hiddleston, Adam Driver, Alan Rickman, Alexz Johnson, Ana Gasteyer, Andrew Rannells, Arden Cho, Bear Grylls, Ben McKenzie, Ben Stiller, Ben Whishaw, Billie Joe Armstrong, Bingbing Li, Bob Barker, Booboo Stewart, Bradley Steven Perry, Bruno Mars, Caity Lotz, Cameron Boyce, Candice Accola, Carrie Underwood, Casey Affleck, Caterina Scorsone, Cedric the Entertainer, Chace Crawford, Chadwick Boseman, Charlie Day, Chris Hemsworth, Chris Martin, Christopher Mintz-Plasse, Dan Fogler, Dan Stevens, Daniel Dae Kim, Danielle Panabaker, Dave Bautista, David Schwimmer, Denis Leary, Derek Mears, Diego Luna, Donald Glover, Donnie Yen, Doutzen Kroes, Dove Cameron, Dr. Dre, Drake Bell, Elle Fanning, Ernie Hudson, Fergie, Forest Whitaker, Francia Raisa, Freddie Highmore, Gillian Jacobs, Gina Carano, Ginnifer Goodwin, Gordon Ramsay, Guy Pearce, Gwendoline Christie, Hailee Steinfeld, Howie Mandel, Hugh Jackman, Hugh Laurie, J. K. Simmons, Jack Black, Jared Leto, Jennifer Carpenter, Kesha, Kris Jenner, Kristen Bell, Lorde, Matt Smith, Marilyn Monroe, Charlie Chaplin, Albert Einstein, Abraham Lincoln, John F. Kennedy, Lucille Ball, A.R. Rahman, Aamir Khan, Ajay Devgn, Akshay Kumar, Alain Delon, Alan Alda, Alan Cumming, Amitabh Bachchan, Ang Lee, Ansel Elgort, Anthony Anderson, Anthony Mackie, Armie Hammer, Asa Butterfield, B.J. Novak, Barbara Eden, Betty White, Bill Nighy, Bill Pullman, Blake Shelton, Bonnie Wright, Brad Paisley, Brendan Gleeson, Brian Cox, Bruno Ganz, Burt Reynolds, Carrie Fisher, Charles Dance, Chiwetel Ejiofor, Chris Pine, Christina Hendricks, Christina Ricci, Cyndi Lauper, Dakota Fanning, Damian Lewis, Dan Aykroyd, Daniel Craig, David Oyelowo, David Tennant, Diane Keaton, Diane Kruger, Dick Van Dyke, Domhnall Gleeson, Dominic Cooper, Donald Sutherland, Drew Carey, Eartha Kitt, Eddie Izzard, Edward Asner, Eli Roth, Elisabeth Moss, Ellen Burstyn, Emile Hirsch, Ezra Miller, Felicity Jones, Fiona Shaw, Florence Henderson, Freida Pinto, Geena Davis, Gemma Arterton, Geri Halliwell, Glenn Close, Gloria Steinem, Greta Gerwig, Gugu Mbatha-Raw, Hans Zimmer, Harry Connick Jr., Harvey Keitel, Helena Bonham Carter, Henry Cavill, Hilary Swank, Hugh Bonneville, Idina Menzel, Imelda Staunton, Ingrid Bergman, Irrfan Khan, Isla Fisher, Iwan Rheon, Jack Lemmon, Janet Jackson, Jason Bateman, Jason Segel, Jennifer Coolidge, Johnny Galecki, Jon Favreau, Joseph Gordon-Levitt, Josh Brolin, Josh Gad, Josh Groban, Julia Louis-Dreyfus, Kristen Stewart, Kristen Wiig, Rooney Mara, Caitriona Balfe, J.J. Abrams, Zoe Saldana | `"Elon Musk"` |
74
+ | `name` | | The name of audio. This value is mainly used for your own identification of the audio. | `"Voice Generator audio"` |
19
75
 
20
76
  #### Synchronous Client
21
77
 
@@ -28,7 +84,6 @@ res = client.v1.ai_voice_generator.create(
28
84
  style={"prompt": "Hello, how are you?", "voice_name": "Elon Musk"},
29
85
  name="Voice Generator audio",
30
86
  )
31
-
32
87
  ```
33
88
 
34
89
  #### Asynchronous Client
@@ -42,15 +97,16 @@ res = await client.v1.ai_voice_generator.create(
42
97
  style={"prompt": "Hello, how are you?", "voice_name": "Elon Musk"},
43
98
  name="Voice Generator audio",
44
99
  )
45
-
46
100
  ```
47
101
 
48
102
  #### Response
49
103
 
50
104
  ##### Type
105
+
51
106
  [V1AiVoiceGeneratorCreateResponse](/magic_hour/types/models/v1_ai_voice_generator_create_response.py)
52
107
 
53
108
  ##### Example
54
- `{"credits_charged": 1, "id": "cuid-example"}`
55
-
56
109
 
110
+ ```python
111
+ {"credits_charged": 1, "id": "cuid-example"}
112
+ ```