magic_hour 0.9.5__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.
- magic_hour/README.md +34 -0
- magic_hour/__init__.py +1 -1
- magic_hour/client.py +8 -17
- magic_hour/environment.py +13 -1
- magic_hour/helpers/__init__.py +4 -0
- magic_hour/helpers/download.py +77 -0
- magic_hour/helpers/logger.py +8 -0
- magic_hour/resources/v1/README.md +32 -0
- magic_hour/resources/v1/ai_clothes_changer/README.md +94 -5
- magic_hour/resources/v1/ai_clothes_changer/client.py +161 -16
- magic_hour/resources/v1/ai_face_editor/README.md +195 -0
- magic_hour/resources/v1/ai_face_editor/__init__.py +4 -0
- magic_hour/resources/v1/ai_face_editor/client.py +324 -0
- magic_hour/resources/v1/ai_gif_generator/README.md +116 -0
- magic_hour/resources/v1/ai_gif_generator/__init__.py +4 -0
- magic_hour/resources/v1/ai_gif_generator/client.py +257 -0
- magic_hour/resources/v1/ai_headshot_generator/README.md +81 -3
- magic_hour/resources/v1/ai_headshot_generator/client.py +167 -18
- magic_hour/resources/v1/ai_image_editor/README.md +125 -0
- magic_hour/resources/v1/ai_image_editor/__init__.py +4 -0
- magic_hour/resources/v1/ai_image_editor/client.py +290 -0
- magic_hour/resources/v1/ai_image_generator/README.md +99 -5
- magic_hour/resources/v1/ai_image_generator/client.py +170 -24
- magic_hour/resources/v1/ai_image_upscaler/README.md +89 -3
- magic_hour/resources/v1/ai_image_upscaler/client.py +173 -20
- magic_hour/resources/v1/ai_meme_generator/README.md +129 -0
- magic_hour/resources/v1/ai_meme_generator/__init__.py +4 -0
- magic_hour/resources/v1/ai_meme_generator/client.py +253 -0
- magic_hour/resources/v1/ai_photo_editor/README.md +119 -4
- magic_hour/resources/v1/ai_photo_editor/client.py +199 -18
- magic_hour/resources/v1/ai_qr_code_generator/README.md +84 -3
- magic_hour/resources/v1/ai_qr_code_generator/client.py +140 -18
- magic_hour/resources/v1/ai_talking_photo/README.md +137 -0
- magic_hour/resources/v1/ai_talking_photo/__init__.py +4 -0
- magic_hour/resources/v1/ai_talking_photo/client.py +326 -0
- magic_hour/resources/v1/ai_voice_cloner/README.md +62 -0
- magic_hour/resources/v1/ai_voice_cloner/__init__.py +4 -0
- magic_hour/resources/v1/ai_voice_cloner/client.py +272 -0
- magic_hour/resources/v1/ai_voice_generator/README.md +112 -0
- magic_hour/resources/v1/ai_voice_generator/__init__.py +4 -0
- magic_hour/resources/v1/ai_voice_generator/client.py +241 -0
- magic_hour/resources/v1/animation/README.md +128 -6
- magic_hour/resources/v1/animation/client.py +247 -22
- magic_hour/resources/v1/audio_projects/README.md +135 -0
- magic_hour/resources/v1/audio_projects/__init__.py +12 -0
- magic_hour/resources/v1/audio_projects/client.py +310 -0
- magic_hour/resources/v1/audio_projects/client_test.py +520 -0
- magic_hour/resources/v1/auto_subtitle_generator/README.md +128 -0
- magic_hour/resources/v1/auto_subtitle_generator/__init__.py +4 -0
- magic_hour/resources/v1/auto_subtitle_generator/client.py +346 -0
- magic_hour/resources/v1/client.py +75 -1
- magic_hour/resources/v1/face_detection/README.md +157 -0
- magic_hour/resources/v1/face_detection/__init__.py +12 -0
- magic_hour/resources/v1/face_detection/client.py +380 -0
- magic_hour/resources/v1/face_swap/README.md +137 -9
- magic_hour/resources/v1/face_swap/client.py +329 -38
- magic_hour/resources/v1/face_swap_photo/README.md +118 -3
- magic_hour/resources/v1/face_swap_photo/client.py +199 -14
- magic_hour/resources/v1/files/README.md +39 -0
- magic_hour/resources/v1/files/client.py +351 -1
- magic_hour/resources/v1/files/client_test.py +414 -0
- magic_hour/resources/v1/files/upload_urls/README.md +38 -17
- magic_hour/resources/v1/files/upload_urls/client.py +38 -34
- magic_hour/resources/v1/image_background_remover/README.md +96 -5
- magic_hour/resources/v1/image_background_remover/client.py +151 -16
- magic_hour/resources/v1/image_projects/README.md +82 -10
- magic_hour/resources/v1/image_projects/__init__.py +10 -2
- magic_hour/resources/v1/image_projects/client.py +154 -16
- magic_hour/resources/v1/image_projects/client_test.py +527 -0
- magic_hour/resources/v1/image_to_video/README.md +96 -11
- magic_hour/resources/v1/image_to_video/client.py +282 -38
- magic_hour/resources/v1/lip_sync/README.md +112 -9
- magic_hour/resources/v1/lip_sync/client.py +288 -34
- magic_hour/resources/v1/photo_colorizer/README.md +107 -0
- magic_hour/resources/v1/photo_colorizer/__init__.py +4 -0
- magic_hour/resources/v1/photo_colorizer/client.py +248 -0
- magic_hour/resources/v1/text_to_video/README.md +96 -7
- magic_hour/resources/v1/text_to_video/client.py +204 -18
- magic_hour/resources/v1/video_projects/README.md +81 -9
- magic_hour/resources/v1/video_projects/__init__.py +10 -2
- magic_hour/resources/v1/video_projects/client.py +151 -14
- magic_hour/resources/v1/video_projects/client_test.py +527 -0
- magic_hour/resources/v1/video_to_video/README.md +119 -15
- magic_hour/resources/v1/video_to_video/client.py +299 -46
- magic_hour/types/models/__init__.py +92 -56
- magic_hour/types/models/v1_ai_clothes_changer_create_response.py +33 -0
- magic_hour/types/models/v1_ai_face_editor_create_response.py +33 -0
- magic_hour/types/models/v1_ai_gif_generator_create_response.py +33 -0
- magic_hour/types/models/v1_ai_headshot_generator_create_response.py +33 -0
- magic_hour/types/models/v1_ai_image_editor_create_response.py +33 -0
- magic_hour/types/models/v1_ai_image_generator_create_response.py +33 -0
- magic_hour/types/models/v1_ai_image_upscaler_create_response.py +33 -0
- magic_hour/types/models/v1_ai_meme_generator_create_response.py +33 -0
- magic_hour/types/models/v1_ai_photo_editor_create_response.py +33 -0
- magic_hour/types/models/v1_ai_qr_code_generator_create_response.py +33 -0
- magic_hour/types/models/v1_ai_talking_photo_create_response.py +35 -0
- magic_hour/types/models/v1_ai_voice_cloner_create_response.py +27 -0
- magic_hour/types/models/v1_ai_voice_generator_create_response.py +27 -0
- magic_hour/types/models/v1_animation_create_response.py +35 -0
- magic_hour/types/models/v1_audio_projects_get_response.py +72 -0
- magic_hour/types/models/v1_audio_projects_get_response_downloads_item.py +19 -0
- magic_hour/types/models/{get_v1_image_projects_id_response_error.py → v1_audio_projects_get_response_error.py} +2 -2
- magic_hour/types/models/v1_auto_subtitle_generator_create_response.py +35 -0
- magic_hour/types/models/v1_face_detection_create_response.py +25 -0
- magic_hour/types/models/v1_face_detection_get_response.py +45 -0
- magic_hour/types/models/v1_face_detection_get_response_faces_item.py +25 -0
- magic_hour/types/models/v1_face_swap_create_response.py +35 -0
- magic_hour/types/models/v1_face_swap_photo_create_response.py +33 -0
- magic_hour/types/models/v1_files_upload_urls_create_response.py +24 -0
- magic_hour/types/models/{post_v1_files_upload_urls_response_items_item.py → v1_files_upload_urls_create_response_items_item.py} +2 -2
- magic_hour/types/models/v1_image_background_remover_create_response.py +33 -0
- magic_hour/types/models/{get_v1_image_projects_id_response.py → v1_image_projects_get_response.py} +20 -18
- magic_hour/types/models/{get_v1_video_projects_id_response_downloads_item.py → v1_image_projects_get_response_downloads_item.py} +1 -1
- magic_hour/types/models/{get_v1_video_projects_id_response_error.py → v1_image_projects_get_response_error.py} +2 -2
- magic_hour/types/models/v1_image_to_video_create_response.py +35 -0
- magic_hour/types/models/v1_lip_sync_create_response.py +35 -0
- magic_hour/types/models/v1_photo_colorizer_create_response.py +33 -0
- magic_hour/types/models/v1_text_to_video_create_response.py +35 -0
- magic_hour/types/models/{get_v1_video_projects_id_response.py → v1_video_projects_get_response.py} +26 -23
- magic_hour/types/models/{get_v1_video_projects_id_response_download.py → v1_video_projects_get_response_download.py} +1 -1
- magic_hour/types/models/{get_v1_image_projects_id_response_downloads_item.py → v1_video_projects_get_response_downloads_item.py} +1 -1
- magic_hour/types/models/v1_video_projects_get_response_error.py +25 -0
- magic_hour/types/models/v1_video_to_video_create_response.py +35 -0
- magic_hour/types/params/__init__.py +422 -176
- magic_hour/types/params/v1_ai_clothes_changer_create_body.py +40 -0
- magic_hour/types/params/v1_ai_clothes_changer_create_body_assets.py +58 -0
- magic_hour/types/params/v1_ai_clothes_changer_generate_body_assets.py +33 -0
- magic_hour/types/params/v1_ai_face_editor_create_body.py +52 -0
- magic_hour/types/params/v1_ai_face_editor_create_body_assets.py +33 -0
- magic_hour/types/params/v1_ai_face_editor_create_body_style.py +137 -0
- magic_hour/types/params/v1_ai_face_editor_generate_body_assets.py +17 -0
- magic_hour/types/params/v1_ai_gif_generator_create_body.py +47 -0
- magic_hour/types/params/{post_v1_ai_image_generator_body_style.py → v1_ai_gif_generator_create_body_style.py} +5 -5
- magic_hour/types/params/v1_ai_headshot_generator_create_body.py +49 -0
- magic_hour/types/params/v1_ai_headshot_generator_create_body_assets.py +33 -0
- magic_hour/types/params/v1_ai_headshot_generator_create_body_style.py +27 -0
- magic_hour/types/params/v1_ai_headshot_generator_generate_body_assets.py +17 -0
- magic_hour/types/params/v1_ai_image_editor_create_body.py +49 -0
- magic_hour/types/params/v1_ai_image_editor_create_body_assets.py +47 -0
- magic_hour/types/params/v1_ai_image_editor_create_body_style.py +41 -0
- magic_hour/types/params/v1_ai_image_editor_generate_body_assets.py +28 -0
- magic_hour/types/params/{post_v1_ai_image_generator_body.py → v1_ai_image_generator_create_body.py} +17 -11
- magic_hour/types/params/v1_ai_image_generator_create_body_style.py +127 -0
- magic_hour/types/params/v1_ai_image_upscaler_create_body.py +59 -0
- magic_hour/types/params/v1_ai_image_upscaler_create_body_assets.py +33 -0
- magic_hour/types/params/{post_v1_ai_image_upscaler_body_style.py → v1_ai_image_upscaler_create_body_style.py} +4 -4
- magic_hour/types/params/v1_ai_image_upscaler_generate_body_assets.py +17 -0
- magic_hour/types/params/v1_ai_meme_generator_create_body.py +37 -0
- magic_hour/types/params/v1_ai_meme_generator_create_body_style.py +73 -0
- magic_hour/types/params/{post_v1_ai_photo_editor_body.py → v1_ai_photo_editor_create_body.py} +15 -15
- magic_hour/types/params/v1_ai_photo_editor_create_body_assets.py +33 -0
- magic_hour/types/params/{post_v1_ai_photo_editor_body_style.py → v1_ai_photo_editor_create_body_style.py} +20 -4
- magic_hour/types/params/v1_ai_photo_editor_generate_body_assets.py +17 -0
- magic_hour/types/params/v1_ai_qr_code_generator_create_body.py +45 -0
- magic_hour/types/params/{post_v1_ai_qr_code_generator_body_style.py → v1_ai_qr_code_generator_create_body_style.py} +4 -4
- magic_hour/types/params/v1_ai_talking_photo_create_body.py +68 -0
- magic_hour/types/params/v1_ai_talking_photo_create_body_assets.py +46 -0
- magic_hour/types/params/v1_ai_talking_photo_create_body_style.py +44 -0
- magic_hour/types/params/v1_ai_talking_photo_generate_body_assets.py +26 -0
- magic_hour/types/params/v1_ai_voice_cloner_create_body.py +49 -0
- magic_hour/types/params/v1_ai_voice_cloner_create_body_assets.py +33 -0
- magic_hour/types/params/v1_ai_voice_cloner_create_body_style.py +28 -0
- magic_hour/types/params/v1_ai_voice_cloner_generate_body_assets.py +28 -0
- magic_hour/types/params/v1_ai_voice_generator_create_body.py +40 -0
- magic_hour/types/params/v1_ai_voice_generator_create_body_style.py +440 -0
- magic_hour/types/params/{post_v1_animation_body.py → v1_animation_create_body.py} +16 -16
- magic_hour/types/params/{post_v1_animation_body_assets.py → v1_animation_create_body_assets.py} +15 -5
- magic_hour/types/params/{post_v1_animation_body_style.py → v1_animation_create_body_style.py} +13 -10
- magic_hour/types/params/v1_animation_generate_body_assets.py +39 -0
- magic_hour/types/params/v1_auto_subtitle_generator_create_body.py +78 -0
- magic_hour/types/params/v1_auto_subtitle_generator_create_body_assets.py +33 -0
- magic_hour/types/params/v1_auto_subtitle_generator_create_body_style.py +56 -0
- magic_hour/types/params/v1_auto_subtitle_generator_create_body_style_custom_config.py +86 -0
- magic_hour/types/params/v1_auto_subtitle_generator_generate_body_assets.py +17 -0
- magic_hour/types/params/v1_face_detection_create_body.py +44 -0
- magic_hour/types/params/v1_face_detection_create_body_assets.py +33 -0
- magic_hour/types/params/v1_face_detection_generate_body_assets.py +17 -0
- magic_hour/types/params/v1_face_swap_create_body.py +92 -0
- magic_hour/types/params/v1_face_swap_create_body_assets.py +91 -0
- magic_hour/types/params/v1_face_swap_create_body_assets_face_mappings_item.py +44 -0
- magic_hour/types/params/v1_face_swap_create_body_style.py +33 -0
- magic_hour/types/params/v1_face_swap_generate_body_assets.py +56 -0
- magic_hour/types/params/v1_face_swap_generate_body_assets_face_mappings_item.py +25 -0
- magic_hour/types/params/v1_face_swap_photo_create_body.py +40 -0
- magic_hour/types/params/v1_face_swap_photo_create_body_assets.py +76 -0
- magic_hour/types/params/v1_face_swap_photo_create_body_assets_face_mappings_item.py +44 -0
- magic_hour/types/params/v1_face_swap_photo_generate_body_assets.py +47 -0
- magic_hour/types/params/v1_face_swap_photo_generate_body_assets_face_mappings_item.py +25 -0
- magic_hour/types/params/v1_files_upload_urls_create_body.py +36 -0
- magic_hour/types/params/v1_files_upload_urls_create_body_items_item.py +38 -0
- magic_hour/types/params/v1_image_background_remover_create_body.py +40 -0
- magic_hour/types/params/v1_image_background_remover_create_body_assets.py +49 -0
- magic_hour/types/params/v1_image_background_remover_generate_body_assets.py +27 -0
- magic_hour/types/params/v1_image_to_video_create_body.py +101 -0
- magic_hour/types/params/v1_image_to_video_create_body_assets.py +33 -0
- magic_hour/types/params/v1_image_to_video_create_body_style.py +53 -0
- magic_hour/types/params/v1_image_to_video_generate_body_assets.py +17 -0
- magic_hour/types/params/v1_lip_sync_create_body.py +100 -0
- magic_hour/types/params/{post_v1_lip_sync_body_assets.py → v1_lip_sync_create_body_assets.py} +15 -5
- magic_hour/types/params/v1_lip_sync_create_body_style.py +37 -0
- magic_hour/types/params/v1_lip_sync_generate_body_assets.py +36 -0
- magic_hour/types/params/v1_photo_colorizer_create_body.py +40 -0
- magic_hour/types/params/v1_photo_colorizer_create_body_assets.py +33 -0
- magic_hour/types/params/v1_photo_colorizer_generate_body_assets.py +17 -0
- magic_hour/types/params/v1_text_to_video_create_body.py +78 -0
- magic_hour/types/params/v1_text_to_video_create_body_style.py +43 -0
- magic_hour/types/params/v1_video_to_video_create_body.py +101 -0
- magic_hour/types/params/{post_v1_video_to_video_body_assets.py → v1_video_to_video_create_body_assets.py} +9 -4
- magic_hour/types/params/{post_v1_video_to_video_body_style.py → v1_video_to_video_create_body_style.py} +68 -26
- magic_hour/types/params/v1_video_to_video_generate_body_assets.py +27 -0
- magic_hour-0.44.0.dist-info/METADATA +328 -0
- magic_hour-0.44.0.dist-info/RECORD +231 -0
- magic_hour/core/__init__.py +0 -52
- magic_hour/core/api_error.py +0 -56
- magic_hour/core/auth.py +0 -314
- magic_hour/core/base_client.py +0 -618
- magic_hour/core/binary_response.py +0 -23
- magic_hour/core/query.py +0 -106
- magic_hour/core/request.py +0 -156
- magic_hour/core/response.py +0 -293
- magic_hour/core/type_utils.py +0 -28
- magic_hour/core/utils.py +0 -55
- magic_hour/types/models/post_v1_ai_clothes_changer_response.py +0 -25
- magic_hour/types/models/post_v1_ai_headshot_generator_response.py +0 -25
- magic_hour/types/models/post_v1_ai_image_generator_response.py +0 -25
- magic_hour/types/models/post_v1_ai_image_upscaler_response.py +0 -25
- magic_hour/types/models/post_v1_ai_photo_editor_response.py +0 -25
- magic_hour/types/models/post_v1_ai_qr_code_generator_response.py +0 -25
- magic_hour/types/models/post_v1_animation_response.py +0 -25
- magic_hour/types/models/post_v1_face_swap_photo_response.py +0 -25
- magic_hour/types/models/post_v1_face_swap_response.py +0 -25
- magic_hour/types/models/post_v1_files_upload_urls_response.py +0 -21
- magic_hour/types/models/post_v1_image_background_remover_response.py +0 -25
- magic_hour/types/models/post_v1_image_to_video_response.py +0 -25
- magic_hour/types/models/post_v1_lip_sync_response.py +0 -25
- magic_hour/types/models/post_v1_text_to_video_response.py +0 -25
- magic_hour/types/models/post_v1_video_to_video_response.py +0 -25
- magic_hour/types/params/post_v1_ai_clothes_changer_body.py +0 -40
- magic_hour/types/params/post_v1_ai_clothes_changer_body_assets.py +0 -45
- magic_hour/types/params/post_v1_ai_headshot_generator_body.py +0 -40
- magic_hour/types/params/post_v1_ai_headshot_generator_body_assets.py +0 -28
- magic_hour/types/params/post_v1_ai_image_upscaler_body.py +0 -57
- magic_hour/types/params/post_v1_ai_image_upscaler_body_assets.py +0 -28
- magic_hour/types/params/post_v1_ai_photo_editor_body_assets.py +0 -28
- magic_hour/types/params/post_v1_ai_qr_code_generator_body.py +0 -45
- magic_hour/types/params/post_v1_face_swap_body.py +0 -72
- magic_hour/types/params/post_v1_face_swap_body_assets.py +0 -52
- magic_hour/types/params/post_v1_face_swap_photo_body.py +0 -40
- magic_hour/types/params/post_v1_face_swap_photo_body_assets.py +0 -36
- magic_hour/types/params/post_v1_files_upload_urls_body.py +0 -31
- magic_hour/types/params/post_v1_files_upload_urls_body_items_item.py +0 -38
- magic_hour/types/params/post_v1_image_background_remover_body.py +0 -40
- magic_hour/types/params/post_v1_image_background_remover_body_assets.py +0 -28
- magic_hour/types/params/post_v1_image_to_video_body.py +0 -73
- magic_hour/types/params/post_v1_image_to_video_body_assets.py +0 -28
- magic_hour/types/params/post_v1_image_to_video_body_style.py +0 -37
- magic_hour/types/params/post_v1_lip_sync_body.py +0 -80
- magic_hour/types/params/post_v1_text_to_video_body.py +0 -57
- magic_hour/types/params/post_v1_text_to_video_body_style.py +0 -28
- magic_hour/types/params/post_v1_video_to_video_body.py +0 -93
- magic_hour-0.9.5.dist-info/METADATA +0 -133
- magic_hour-0.9.5.dist-info/RECORD +0 -132
- {magic_hour-0.9.5.dist-info → magic_hour-0.44.0.dist-info}/LICENSE +0 -0
- {magic_hour-0.9.5.dist-info → magic_hour-0.44.0.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# v1.audio_projects
|
|
2
|
+
|
|
3
|
+
## Module Functions
|
|
4
|
+
|
|
5
|
+
<!-- CUSTOM DOCS START -->
|
|
6
|
+
|
|
7
|
+
### Check results <a name="check-result"></a>
|
|
8
|
+
|
|
9
|
+
Poll the details API to check on the status of the rendering. Optionally can also download the output
|
|
10
|
+
|
|
11
|
+
#### Parameters
|
|
12
|
+
|
|
13
|
+
| Parameter | Required | Description | Example |
|
|
14
|
+
| --------------------- | :------: | ---------------------------------------------------------------------------------------------------- | ---------------- |
|
|
15
|
+
| `id` | ✓ | Unique ID of the audio project. This value is returned by all of the POST APIs that create an audio. | `"cuid-example"` |
|
|
16
|
+
| `wait_for_completion` | ✗ | Whether to wait for the project to complete. | `True` |
|
|
17
|
+
| `download_outputs` | ✗ | Whether to download the generated files | `True` |
|
|
18
|
+
| `download_directory` | ✗ | Directory to save downloaded files (defaults to current directory) | `"./outputs"` |
|
|
19
|
+
|
|
20
|
+
#### Synchronous Client
|
|
21
|
+
|
|
22
|
+
```python
|
|
23
|
+
from magic_hour import Client
|
|
24
|
+
from os import getenv
|
|
25
|
+
|
|
26
|
+
client = Client(token=getenv("API_TOKEN"))
|
|
27
|
+
res = client.v1.audio_projects.check_result(
|
|
28
|
+
id="cuid-example",
|
|
29
|
+
wait_for_completion=True,
|
|
30
|
+
download_outputs=True,
|
|
31
|
+
download_directory="outputs",
|
|
32
|
+
)
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
#### Asynchronous Client
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
from magic_hour import AsyncClient
|
|
39
|
+
from os import getenv
|
|
40
|
+
|
|
41
|
+
client = AsyncClient(token=getenv("API_TOKEN"))
|
|
42
|
+
res = await client.v1.audio_projects.check_result(
|
|
43
|
+
id="cuid-example",
|
|
44
|
+
wait_for_completion=True,
|
|
45
|
+
download_outputs=True,
|
|
46
|
+
download_directory="outputs",
|
|
47
|
+
)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
<!-- CUSTOM DOCS END -->
|
|
51
|
+
|
|
52
|
+
### Delete audio <a name="delete"></a>
|
|
53
|
+
|
|
54
|
+
Permanently delete the rendered audio file(s). This action is not reversible, please be sure before deleting.
|
|
55
|
+
|
|
56
|
+
**API Endpoint**: `DELETE /v1/audio-projects/{id}`
|
|
57
|
+
|
|
58
|
+
#### Parameters
|
|
59
|
+
|
|
60
|
+
| Parameter | Required | Description | Example |
|
|
61
|
+
| --------- | :------: | ---------------------------------------------------------------------------------------------------- | ---------------- |
|
|
62
|
+
| `id` | ✓ | Unique ID of the audio project. This value is returned by all of the POST APIs that create an audio. | `"cuid-example"` |
|
|
63
|
+
|
|
64
|
+
#### Synchronous Client
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
from magic_hour import Client
|
|
68
|
+
from os import getenv
|
|
69
|
+
|
|
70
|
+
client = Client(token=getenv("API_TOKEN"))
|
|
71
|
+
res = client.v1.audio_projects.delete(id="cuid-example")
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
#### Asynchronous Client
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
from magic_hour import AsyncClient
|
|
78
|
+
from os import getenv
|
|
79
|
+
|
|
80
|
+
client = AsyncClient(token=getenv("API_TOKEN"))
|
|
81
|
+
res = await client.v1.audio_projects.delete(id="cuid-example")
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Get audio details <a name="get"></a>
|
|
85
|
+
|
|
86
|
+
Get the details of a audio project. The `downloads` field will be empty unless the audio was successfully rendered.
|
|
87
|
+
|
|
88
|
+
The audio can be one of the following status
|
|
89
|
+
|
|
90
|
+
- `draft` - not currently used
|
|
91
|
+
- `queued` - the job is queued and waiting for a GPU
|
|
92
|
+
- `rendering` - the generation is in progress
|
|
93
|
+
- `complete` - the audio is successful created
|
|
94
|
+
- `error` - an error occurred during rendering
|
|
95
|
+
- `canceled` - audio render is canceled by the user
|
|
96
|
+
|
|
97
|
+
**API Endpoint**: `GET /v1/audio-projects/{id}`
|
|
98
|
+
|
|
99
|
+
#### Parameters
|
|
100
|
+
|
|
101
|
+
| Parameter | Required | Description | Example |
|
|
102
|
+
| --------- | :------: | ---------------------------------------------------------------------------------------------------- | ---------------- |
|
|
103
|
+
| `id` | ✓ | Unique ID of the audio project. This value is returned by all of the POST APIs that create an audio. | `"cuid-example"` |
|
|
104
|
+
|
|
105
|
+
#### Synchronous Client
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
from magic_hour import Client
|
|
109
|
+
from os import getenv
|
|
110
|
+
|
|
111
|
+
client = Client(token=getenv("API_TOKEN"))
|
|
112
|
+
res = client.v1.audio_projects.get(id="cuid-example")
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
#### Asynchronous Client
|
|
116
|
+
|
|
117
|
+
```python
|
|
118
|
+
from magic_hour import AsyncClient
|
|
119
|
+
from os import getenv
|
|
120
|
+
|
|
121
|
+
client = AsyncClient(token=getenv("API_TOKEN"))
|
|
122
|
+
res = await client.v1.audio_projects.get(id="cuid-example")
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
#### Response
|
|
126
|
+
|
|
127
|
+
##### Type
|
|
128
|
+
|
|
129
|
+
[V1AudioProjectsGetResponse](/magic_hour/types/models/v1_audio_projects_get_response.py)
|
|
130
|
+
|
|
131
|
+
##### Example
|
|
132
|
+
|
|
133
|
+
```python
|
|
134
|
+
{"created_at": "1970-01-01T00:00:00", "credits_charged": 2, "downloads": [{"expires_at": "2024-10-19T05:16:19.027Z", "url": "https://videos.magichour.ai/id/output.wav"}], "enabled": True, "error": {"code": "no_source_face", "message": "Please use an image with a detectable face"}, "id": "cuid-example", "name": "Example Name", "status": "complete", "type_": "VOICE_GENERATOR"}
|
|
135
|
+
```
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import pydantic
|
|
3
|
+
import time
|
|
4
|
+
import typing
|
|
5
|
+
|
|
6
|
+
from magic_hour.helpers.download import download_files_async, download_files_sync
|
|
7
|
+
from magic_hour.helpers.logger import get_sdk_logger
|
|
8
|
+
from magic_hour.types import models
|
|
9
|
+
from make_api_request import (
|
|
10
|
+
AsyncBaseClient,
|
|
11
|
+
RequestOptions,
|
|
12
|
+
SyncBaseClient,
|
|
13
|
+
default_request_options,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
logger = get_sdk_logger(__name__)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class V1AudioProjectsGetResponseWithDownloads(models.V1AudioProjectsGetResponse):
|
|
21
|
+
downloaded_paths: typing.Optional[typing.List[str]] = pydantic.Field(
|
|
22
|
+
default=None, alias="downloaded_paths"
|
|
23
|
+
)
|
|
24
|
+
"""
|
|
25
|
+
The paths to the downloaded files.
|
|
26
|
+
|
|
27
|
+
This field is only populated if `download_outputs` is True and the audio project is complete.
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class AudioProjectsClient:
|
|
32
|
+
def __init__(self, *, base_client: SyncBaseClient):
|
|
33
|
+
self._base_client = base_client
|
|
34
|
+
|
|
35
|
+
def check_result(
|
|
36
|
+
self,
|
|
37
|
+
id: str,
|
|
38
|
+
wait_for_completion: bool,
|
|
39
|
+
download_outputs: bool,
|
|
40
|
+
download_directory: typing.Optional[str] = None,
|
|
41
|
+
) -> V1AudioProjectsGetResponseWithDownloads:
|
|
42
|
+
"""
|
|
43
|
+
Check the result of an audio project with optional waiting and downloading.
|
|
44
|
+
|
|
45
|
+
This method retrieves the status of an audio project and optionally waits for completion
|
|
46
|
+
and downloads the output files.
|
|
47
|
+
|
|
48
|
+
Args:
|
|
49
|
+
id: Unique ID of the audio project
|
|
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,
|
|
53
|
+
the outputs will be downloaded to the current working directory
|
|
54
|
+
|
|
55
|
+
Returns:
|
|
56
|
+
V1AudioProjectsGetResponseWithDownloads: The audio project response with optional
|
|
57
|
+
downloaded file paths included
|
|
58
|
+
"""
|
|
59
|
+
api_response = self.get(id=id)
|
|
60
|
+
if not wait_for_completion:
|
|
61
|
+
response = V1AudioProjectsGetResponseWithDownloads(
|
|
62
|
+
**api_response.model_dump()
|
|
63
|
+
)
|
|
64
|
+
return response
|
|
65
|
+
|
|
66
|
+
poll_interval = float(os.getenv("MAGIC_HOUR_POLL_INTERVAL", "0.5"))
|
|
67
|
+
|
|
68
|
+
status = api_response.status
|
|
69
|
+
|
|
70
|
+
while status not in ["complete", "error", "canceled"]:
|
|
71
|
+
api_response = self.get(id=id)
|
|
72
|
+
status = api_response.status
|
|
73
|
+
time.sleep(poll_interval)
|
|
74
|
+
|
|
75
|
+
if api_response.status != "complete":
|
|
76
|
+
log = logger.error if api_response.status == "error" else logger.info
|
|
77
|
+
log(
|
|
78
|
+
f"Audio project {id} has status {api_response.status}: {api_response.error}"
|
|
79
|
+
)
|
|
80
|
+
return V1AudioProjectsGetResponseWithDownloads(**api_response.model_dump())
|
|
81
|
+
|
|
82
|
+
if not download_outputs:
|
|
83
|
+
return V1AudioProjectsGetResponseWithDownloads(**api_response.model_dump())
|
|
84
|
+
|
|
85
|
+
downloaded_paths = download_files_sync(
|
|
86
|
+
downloads=api_response.downloads,
|
|
87
|
+
download_directory=download_directory,
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
return V1AudioProjectsGetResponseWithDownloads(
|
|
91
|
+
**api_response.model_dump(), downloaded_paths=downloaded_paths
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
def delete(
|
|
95
|
+
self, *, id: str, request_options: typing.Optional[RequestOptions] = None
|
|
96
|
+
) -> None:
|
|
97
|
+
"""
|
|
98
|
+
Delete audio
|
|
99
|
+
|
|
100
|
+
Permanently delete the rendered audio file(s). This action is not reversible, please be sure before deleting.
|
|
101
|
+
|
|
102
|
+
DELETE /v1/audio-projects/{id}
|
|
103
|
+
|
|
104
|
+
Args:
|
|
105
|
+
id: Unique ID of the audio project. This value is returned by all of the POST APIs that create an audio.
|
|
106
|
+
request_options: Additional options to customize the HTTP request
|
|
107
|
+
|
|
108
|
+
Returns:
|
|
109
|
+
204
|
|
110
|
+
|
|
111
|
+
Raises:
|
|
112
|
+
ApiError: A custom exception class that provides additional context
|
|
113
|
+
for API errors, including the HTTP status code and response body.
|
|
114
|
+
|
|
115
|
+
Examples:
|
|
116
|
+
```py
|
|
117
|
+
client.v1.audio_projects.delete(id="cuid-example")
|
|
118
|
+
```
|
|
119
|
+
"""
|
|
120
|
+
self._base_client.request(
|
|
121
|
+
method="DELETE",
|
|
122
|
+
path=f"/v1/audio-projects/{id}",
|
|
123
|
+
auth_names=["bearerAuth"],
|
|
124
|
+
cast_to=type(None),
|
|
125
|
+
request_options=request_options or default_request_options(),
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
def get(
|
|
129
|
+
self, *, id: str, request_options: typing.Optional[RequestOptions] = None
|
|
130
|
+
) -> models.V1AudioProjectsGetResponse:
|
|
131
|
+
"""
|
|
132
|
+
Get audio details
|
|
133
|
+
|
|
134
|
+
Get the details of a audio project. The `downloads` field will be empty unless the audio was successfully rendered.
|
|
135
|
+
|
|
136
|
+
The audio can be one of the following status
|
|
137
|
+
- `draft` - not currently used
|
|
138
|
+
- `queued` - the job is queued and waiting for a GPU
|
|
139
|
+
- `rendering` - the generation is in progress
|
|
140
|
+
- `complete` - the audio is successful created
|
|
141
|
+
- `error` - an error occurred during rendering
|
|
142
|
+
- `canceled` - audio render is canceled by the user
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
GET /v1/audio-projects/{id}
|
|
146
|
+
|
|
147
|
+
Args:
|
|
148
|
+
id: Unique ID of the audio project. This value is returned by all of the POST APIs that create an audio.
|
|
149
|
+
request_options: Additional options to customize the HTTP request
|
|
150
|
+
|
|
151
|
+
Returns:
|
|
152
|
+
Success
|
|
153
|
+
|
|
154
|
+
Raises:
|
|
155
|
+
ApiError: A custom exception class that provides additional context
|
|
156
|
+
for API errors, including the HTTP status code and response body.
|
|
157
|
+
|
|
158
|
+
Examples:
|
|
159
|
+
```py
|
|
160
|
+
client.v1.audio_projects.get(id="cuid-example")
|
|
161
|
+
```
|
|
162
|
+
"""
|
|
163
|
+
return self._base_client.request(
|
|
164
|
+
method="GET",
|
|
165
|
+
path=f"/v1/audio-projects/{id}",
|
|
166
|
+
auth_names=["bearerAuth"],
|
|
167
|
+
cast_to=models.V1AudioProjectsGetResponse,
|
|
168
|
+
request_options=request_options or default_request_options(),
|
|
169
|
+
)
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
class AsyncAudioProjectsClient:
|
|
173
|
+
def __init__(self, *, base_client: AsyncBaseClient):
|
|
174
|
+
self._base_client = base_client
|
|
175
|
+
|
|
176
|
+
async def check_result(
|
|
177
|
+
self,
|
|
178
|
+
id: str,
|
|
179
|
+
wait_for_completion: bool,
|
|
180
|
+
download_outputs: bool,
|
|
181
|
+
download_directory: typing.Optional[str] = None,
|
|
182
|
+
) -> V1AudioProjectsGetResponseWithDownloads:
|
|
183
|
+
"""
|
|
184
|
+
Check the result of an audio project with optional waiting and downloading.
|
|
185
|
+
|
|
186
|
+
This method retrieves the status of an audio project and optionally waits for completion
|
|
187
|
+
and downloads the output files.
|
|
188
|
+
|
|
189
|
+
Args:
|
|
190
|
+
id: Unique ID of the audio project
|
|
191
|
+
wait_for_completion: Whether to wait for the audio project to complete
|
|
192
|
+
download_outputs: Whether to download the outputs
|
|
193
|
+
download_directory: The directory to download the outputs to. If not provided,
|
|
194
|
+
the outputs will be downloaded to the current working directory
|
|
195
|
+
|
|
196
|
+
Returns:
|
|
197
|
+
V1AudioProjectsGetResponseWithDownloads: The audio project response with optional
|
|
198
|
+
downloaded file paths included
|
|
199
|
+
"""
|
|
200
|
+
api_response = await self.get(id=id)
|
|
201
|
+
if not wait_for_completion:
|
|
202
|
+
response = V1AudioProjectsGetResponseWithDownloads(
|
|
203
|
+
**api_response.model_dump()
|
|
204
|
+
)
|
|
205
|
+
return response
|
|
206
|
+
|
|
207
|
+
poll_interval = float(os.getenv("MAGIC_HOUR_POLL_INTERVAL", "0.5"))
|
|
208
|
+
|
|
209
|
+
status = api_response.status
|
|
210
|
+
|
|
211
|
+
while status not in ["complete", "error", "canceled"]:
|
|
212
|
+
api_response = await self.get(id=id)
|
|
213
|
+
status = api_response.status
|
|
214
|
+
time.sleep(poll_interval)
|
|
215
|
+
|
|
216
|
+
if api_response.status != "complete":
|
|
217
|
+
log = logger.error if api_response.status == "error" else logger.info
|
|
218
|
+
log(
|
|
219
|
+
f"Audio project {id} has status {api_response.status}: {api_response.error}"
|
|
220
|
+
)
|
|
221
|
+
return V1AudioProjectsGetResponseWithDownloads(**api_response.model_dump())
|
|
222
|
+
|
|
223
|
+
if not download_outputs:
|
|
224
|
+
return V1AudioProjectsGetResponseWithDownloads(**api_response.model_dump())
|
|
225
|
+
|
|
226
|
+
downloaded_paths = await download_files_async(
|
|
227
|
+
downloads=api_response.downloads,
|
|
228
|
+
download_directory=download_directory,
|
|
229
|
+
)
|
|
230
|
+
|
|
231
|
+
return V1AudioProjectsGetResponseWithDownloads(
|
|
232
|
+
**api_response.model_dump(), downloaded_paths=downloaded_paths
|
|
233
|
+
)
|
|
234
|
+
|
|
235
|
+
async def delete(
|
|
236
|
+
self, *, id: str, request_options: typing.Optional[RequestOptions] = None
|
|
237
|
+
) -> None:
|
|
238
|
+
"""
|
|
239
|
+
Delete audio
|
|
240
|
+
|
|
241
|
+
Permanently delete the rendered audio file(s). This action is not reversible, please be sure before deleting.
|
|
242
|
+
|
|
243
|
+
DELETE /v1/audio-projects/{id}
|
|
244
|
+
|
|
245
|
+
Args:
|
|
246
|
+
id: Unique ID of the audio project. This value is returned by all of the POST APIs that create an audio.
|
|
247
|
+
request_options: Additional options to customize the HTTP request
|
|
248
|
+
|
|
249
|
+
Returns:
|
|
250
|
+
204
|
|
251
|
+
|
|
252
|
+
Raises:
|
|
253
|
+
ApiError: A custom exception class that provides additional context
|
|
254
|
+
for API errors, including the HTTP status code and response body.
|
|
255
|
+
|
|
256
|
+
Examples:
|
|
257
|
+
```py
|
|
258
|
+
await client.v1.audio_projects.delete(id="cuid-example")
|
|
259
|
+
```
|
|
260
|
+
"""
|
|
261
|
+
await self._base_client.request(
|
|
262
|
+
method="DELETE",
|
|
263
|
+
path=f"/v1/audio-projects/{id}",
|
|
264
|
+
auth_names=["bearerAuth"],
|
|
265
|
+
cast_to=type(None),
|
|
266
|
+
request_options=request_options or default_request_options(),
|
|
267
|
+
)
|
|
268
|
+
|
|
269
|
+
async def get(
|
|
270
|
+
self, *, id: str, request_options: typing.Optional[RequestOptions] = None
|
|
271
|
+
) -> models.V1AudioProjectsGetResponse:
|
|
272
|
+
"""
|
|
273
|
+
Get audio details
|
|
274
|
+
|
|
275
|
+
Get the details of a audio project. The `downloads` field will be empty unless the audio was successfully rendered.
|
|
276
|
+
|
|
277
|
+
The audio can be one of the following status
|
|
278
|
+
- `draft` - not currently used
|
|
279
|
+
- `queued` - the job is queued and waiting for a GPU
|
|
280
|
+
- `rendering` - the generation is in progress
|
|
281
|
+
- `complete` - the audio is successful created
|
|
282
|
+
- `error` - an error occurred during rendering
|
|
283
|
+
- `canceled` - audio render is canceled by the user
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
GET /v1/audio-projects/{id}
|
|
287
|
+
|
|
288
|
+
Args:
|
|
289
|
+
id: Unique ID of the audio project. This value is returned by all of the POST APIs that create an audio.
|
|
290
|
+
request_options: Additional options to customize the HTTP request
|
|
291
|
+
|
|
292
|
+
Returns:
|
|
293
|
+
Success
|
|
294
|
+
|
|
295
|
+
Raises:
|
|
296
|
+
ApiError: A custom exception class that provides additional context
|
|
297
|
+
for API errors, including the HTTP status code and response body.
|
|
298
|
+
|
|
299
|
+
Examples:
|
|
300
|
+
```py
|
|
301
|
+
await client.v1.audio_projects.get(id="cuid-example")
|
|
302
|
+
```
|
|
303
|
+
"""
|
|
304
|
+
return await self._base_client.request(
|
|
305
|
+
method="GET",
|
|
306
|
+
path=f"/v1/audio-projects/{id}",
|
|
307
|
+
auth_names=["bearerAuth"],
|
|
308
|
+
cast_to=models.V1AudioProjectsGetResponse,
|
|
309
|
+
request_options=request_options or default_request_options(),
|
|
310
|
+
)
|