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.
Files changed (264) hide show
  1. magic_hour/README.md +34 -0
  2. magic_hour/__init__.py +1 -1
  3. magic_hour/client.py +8 -17
  4. magic_hour/environment.py +13 -1
  5. magic_hour/helpers/__init__.py +4 -0
  6. magic_hour/helpers/download.py +77 -0
  7. magic_hour/helpers/logger.py +8 -0
  8. magic_hour/resources/v1/README.md +32 -0
  9. magic_hour/resources/v1/ai_clothes_changer/README.md +94 -5
  10. magic_hour/resources/v1/ai_clothes_changer/client.py +161 -16
  11. magic_hour/resources/v1/ai_face_editor/README.md +195 -0
  12. magic_hour/resources/v1/ai_face_editor/__init__.py +4 -0
  13. magic_hour/resources/v1/ai_face_editor/client.py +324 -0
  14. magic_hour/resources/v1/ai_gif_generator/README.md +116 -0
  15. magic_hour/resources/v1/ai_gif_generator/__init__.py +4 -0
  16. magic_hour/resources/v1/ai_gif_generator/client.py +257 -0
  17. magic_hour/resources/v1/ai_headshot_generator/README.md +81 -3
  18. magic_hour/resources/v1/ai_headshot_generator/client.py +167 -18
  19. magic_hour/resources/v1/ai_image_editor/README.md +125 -0
  20. magic_hour/resources/v1/ai_image_editor/__init__.py +4 -0
  21. magic_hour/resources/v1/ai_image_editor/client.py +290 -0
  22. magic_hour/resources/v1/ai_image_generator/README.md +99 -5
  23. magic_hour/resources/v1/ai_image_generator/client.py +170 -24
  24. magic_hour/resources/v1/ai_image_upscaler/README.md +89 -3
  25. magic_hour/resources/v1/ai_image_upscaler/client.py +173 -20
  26. magic_hour/resources/v1/ai_meme_generator/README.md +129 -0
  27. magic_hour/resources/v1/ai_meme_generator/__init__.py +4 -0
  28. magic_hour/resources/v1/ai_meme_generator/client.py +253 -0
  29. magic_hour/resources/v1/ai_photo_editor/README.md +119 -4
  30. magic_hour/resources/v1/ai_photo_editor/client.py +199 -18
  31. magic_hour/resources/v1/ai_qr_code_generator/README.md +84 -3
  32. magic_hour/resources/v1/ai_qr_code_generator/client.py +140 -18
  33. magic_hour/resources/v1/ai_talking_photo/README.md +137 -0
  34. magic_hour/resources/v1/ai_talking_photo/__init__.py +4 -0
  35. magic_hour/resources/v1/ai_talking_photo/client.py +326 -0
  36. magic_hour/resources/v1/ai_voice_cloner/README.md +62 -0
  37. magic_hour/resources/v1/ai_voice_cloner/__init__.py +4 -0
  38. magic_hour/resources/v1/ai_voice_cloner/client.py +272 -0
  39. magic_hour/resources/v1/ai_voice_generator/README.md +112 -0
  40. magic_hour/resources/v1/ai_voice_generator/__init__.py +4 -0
  41. magic_hour/resources/v1/ai_voice_generator/client.py +241 -0
  42. magic_hour/resources/v1/animation/README.md +128 -6
  43. magic_hour/resources/v1/animation/client.py +247 -22
  44. magic_hour/resources/v1/audio_projects/README.md +135 -0
  45. magic_hour/resources/v1/audio_projects/__init__.py +12 -0
  46. magic_hour/resources/v1/audio_projects/client.py +310 -0
  47. magic_hour/resources/v1/audio_projects/client_test.py +520 -0
  48. magic_hour/resources/v1/auto_subtitle_generator/README.md +128 -0
  49. magic_hour/resources/v1/auto_subtitle_generator/__init__.py +4 -0
  50. magic_hour/resources/v1/auto_subtitle_generator/client.py +346 -0
  51. magic_hour/resources/v1/client.py +75 -1
  52. magic_hour/resources/v1/face_detection/README.md +157 -0
  53. magic_hour/resources/v1/face_detection/__init__.py +12 -0
  54. magic_hour/resources/v1/face_detection/client.py +380 -0
  55. magic_hour/resources/v1/face_swap/README.md +137 -9
  56. magic_hour/resources/v1/face_swap/client.py +329 -38
  57. magic_hour/resources/v1/face_swap_photo/README.md +118 -3
  58. magic_hour/resources/v1/face_swap_photo/client.py +199 -14
  59. magic_hour/resources/v1/files/README.md +39 -0
  60. magic_hour/resources/v1/files/client.py +351 -1
  61. magic_hour/resources/v1/files/client_test.py +414 -0
  62. magic_hour/resources/v1/files/upload_urls/README.md +38 -17
  63. magic_hour/resources/v1/files/upload_urls/client.py +38 -34
  64. magic_hour/resources/v1/image_background_remover/README.md +96 -5
  65. magic_hour/resources/v1/image_background_remover/client.py +151 -16
  66. magic_hour/resources/v1/image_projects/README.md +82 -10
  67. magic_hour/resources/v1/image_projects/__init__.py +10 -2
  68. magic_hour/resources/v1/image_projects/client.py +154 -16
  69. magic_hour/resources/v1/image_projects/client_test.py +527 -0
  70. magic_hour/resources/v1/image_to_video/README.md +96 -11
  71. magic_hour/resources/v1/image_to_video/client.py +282 -38
  72. magic_hour/resources/v1/lip_sync/README.md +112 -9
  73. magic_hour/resources/v1/lip_sync/client.py +288 -34
  74. magic_hour/resources/v1/photo_colorizer/README.md +107 -0
  75. magic_hour/resources/v1/photo_colorizer/__init__.py +4 -0
  76. magic_hour/resources/v1/photo_colorizer/client.py +248 -0
  77. magic_hour/resources/v1/text_to_video/README.md +96 -7
  78. magic_hour/resources/v1/text_to_video/client.py +204 -18
  79. magic_hour/resources/v1/video_projects/README.md +81 -9
  80. magic_hour/resources/v1/video_projects/__init__.py +10 -2
  81. magic_hour/resources/v1/video_projects/client.py +151 -14
  82. magic_hour/resources/v1/video_projects/client_test.py +527 -0
  83. magic_hour/resources/v1/video_to_video/README.md +119 -15
  84. magic_hour/resources/v1/video_to_video/client.py +299 -46
  85. magic_hour/types/models/__init__.py +92 -56
  86. magic_hour/types/models/v1_ai_clothes_changer_create_response.py +33 -0
  87. magic_hour/types/models/v1_ai_face_editor_create_response.py +33 -0
  88. magic_hour/types/models/v1_ai_gif_generator_create_response.py +33 -0
  89. magic_hour/types/models/v1_ai_headshot_generator_create_response.py +33 -0
  90. magic_hour/types/models/v1_ai_image_editor_create_response.py +33 -0
  91. magic_hour/types/models/v1_ai_image_generator_create_response.py +33 -0
  92. magic_hour/types/models/v1_ai_image_upscaler_create_response.py +33 -0
  93. magic_hour/types/models/v1_ai_meme_generator_create_response.py +33 -0
  94. magic_hour/types/models/v1_ai_photo_editor_create_response.py +33 -0
  95. magic_hour/types/models/v1_ai_qr_code_generator_create_response.py +33 -0
  96. magic_hour/types/models/v1_ai_talking_photo_create_response.py +35 -0
  97. magic_hour/types/models/v1_ai_voice_cloner_create_response.py +27 -0
  98. magic_hour/types/models/v1_ai_voice_generator_create_response.py +27 -0
  99. magic_hour/types/models/v1_animation_create_response.py +35 -0
  100. magic_hour/types/models/v1_audio_projects_get_response.py +72 -0
  101. magic_hour/types/models/v1_audio_projects_get_response_downloads_item.py +19 -0
  102. magic_hour/types/models/{get_v1_image_projects_id_response_error.py → v1_audio_projects_get_response_error.py} +2 -2
  103. magic_hour/types/models/v1_auto_subtitle_generator_create_response.py +35 -0
  104. magic_hour/types/models/v1_face_detection_create_response.py +25 -0
  105. magic_hour/types/models/v1_face_detection_get_response.py +45 -0
  106. magic_hour/types/models/v1_face_detection_get_response_faces_item.py +25 -0
  107. magic_hour/types/models/v1_face_swap_create_response.py +35 -0
  108. magic_hour/types/models/v1_face_swap_photo_create_response.py +33 -0
  109. magic_hour/types/models/v1_files_upload_urls_create_response.py +24 -0
  110. magic_hour/types/models/{post_v1_files_upload_urls_response_items_item.py → v1_files_upload_urls_create_response_items_item.py} +2 -2
  111. magic_hour/types/models/v1_image_background_remover_create_response.py +33 -0
  112. magic_hour/types/models/{get_v1_image_projects_id_response.py → v1_image_projects_get_response.py} +20 -18
  113. magic_hour/types/models/{get_v1_video_projects_id_response_downloads_item.py → v1_image_projects_get_response_downloads_item.py} +1 -1
  114. magic_hour/types/models/{get_v1_video_projects_id_response_error.py → v1_image_projects_get_response_error.py} +2 -2
  115. magic_hour/types/models/v1_image_to_video_create_response.py +35 -0
  116. magic_hour/types/models/v1_lip_sync_create_response.py +35 -0
  117. magic_hour/types/models/v1_photo_colorizer_create_response.py +33 -0
  118. magic_hour/types/models/v1_text_to_video_create_response.py +35 -0
  119. magic_hour/types/models/{get_v1_video_projects_id_response.py → v1_video_projects_get_response.py} +26 -23
  120. magic_hour/types/models/{get_v1_video_projects_id_response_download.py → v1_video_projects_get_response_download.py} +1 -1
  121. magic_hour/types/models/{get_v1_image_projects_id_response_downloads_item.py → v1_video_projects_get_response_downloads_item.py} +1 -1
  122. magic_hour/types/models/v1_video_projects_get_response_error.py +25 -0
  123. magic_hour/types/models/v1_video_to_video_create_response.py +35 -0
  124. magic_hour/types/params/__init__.py +422 -176
  125. magic_hour/types/params/v1_ai_clothes_changer_create_body.py +40 -0
  126. magic_hour/types/params/v1_ai_clothes_changer_create_body_assets.py +58 -0
  127. magic_hour/types/params/v1_ai_clothes_changer_generate_body_assets.py +33 -0
  128. magic_hour/types/params/v1_ai_face_editor_create_body.py +52 -0
  129. magic_hour/types/params/v1_ai_face_editor_create_body_assets.py +33 -0
  130. magic_hour/types/params/v1_ai_face_editor_create_body_style.py +137 -0
  131. magic_hour/types/params/v1_ai_face_editor_generate_body_assets.py +17 -0
  132. magic_hour/types/params/v1_ai_gif_generator_create_body.py +47 -0
  133. magic_hour/types/params/{post_v1_ai_image_generator_body_style.py → v1_ai_gif_generator_create_body_style.py} +5 -5
  134. magic_hour/types/params/v1_ai_headshot_generator_create_body.py +49 -0
  135. magic_hour/types/params/v1_ai_headshot_generator_create_body_assets.py +33 -0
  136. magic_hour/types/params/v1_ai_headshot_generator_create_body_style.py +27 -0
  137. magic_hour/types/params/v1_ai_headshot_generator_generate_body_assets.py +17 -0
  138. magic_hour/types/params/v1_ai_image_editor_create_body.py +49 -0
  139. magic_hour/types/params/v1_ai_image_editor_create_body_assets.py +47 -0
  140. magic_hour/types/params/v1_ai_image_editor_create_body_style.py +41 -0
  141. magic_hour/types/params/v1_ai_image_editor_generate_body_assets.py +28 -0
  142. magic_hour/types/params/{post_v1_ai_image_generator_body.py → v1_ai_image_generator_create_body.py} +17 -11
  143. magic_hour/types/params/v1_ai_image_generator_create_body_style.py +127 -0
  144. magic_hour/types/params/v1_ai_image_upscaler_create_body.py +59 -0
  145. magic_hour/types/params/v1_ai_image_upscaler_create_body_assets.py +33 -0
  146. magic_hour/types/params/{post_v1_ai_image_upscaler_body_style.py → v1_ai_image_upscaler_create_body_style.py} +4 -4
  147. magic_hour/types/params/v1_ai_image_upscaler_generate_body_assets.py +17 -0
  148. magic_hour/types/params/v1_ai_meme_generator_create_body.py +37 -0
  149. magic_hour/types/params/v1_ai_meme_generator_create_body_style.py +73 -0
  150. magic_hour/types/params/{post_v1_ai_photo_editor_body.py → v1_ai_photo_editor_create_body.py} +15 -15
  151. magic_hour/types/params/v1_ai_photo_editor_create_body_assets.py +33 -0
  152. magic_hour/types/params/{post_v1_ai_photo_editor_body_style.py → v1_ai_photo_editor_create_body_style.py} +20 -4
  153. magic_hour/types/params/v1_ai_photo_editor_generate_body_assets.py +17 -0
  154. magic_hour/types/params/v1_ai_qr_code_generator_create_body.py +45 -0
  155. magic_hour/types/params/{post_v1_ai_qr_code_generator_body_style.py → v1_ai_qr_code_generator_create_body_style.py} +4 -4
  156. magic_hour/types/params/v1_ai_talking_photo_create_body.py +68 -0
  157. magic_hour/types/params/v1_ai_talking_photo_create_body_assets.py +46 -0
  158. magic_hour/types/params/v1_ai_talking_photo_create_body_style.py +44 -0
  159. magic_hour/types/params/v1_ai_talking_photo_generate_body_assets.py +26 -0
  160. magic_hour/types/params/v1_ai_voice_cloner_create_body.py +49 -0
  161. magic_hour/types/params/v1_ai_voice_cloner_create_body_assets.py +33 -0
  162. magic_hour/types/params/v1_ai_voice_cloner_create_body_style.py +28 -0
  163. magic_hour/types/params/v1_ai_voice_cloner_generate_body_assets.py +28 -0
  164. magic_hour/types/params/v1_ai_voice_generator_create_body.py +40 -0
  165. magic_hour/types/params/v1_ai_voice_generator_create_body_style.py +440 -0
  166. magic_hour/types/params/{post_v1_animation_body.py → v1_animation_create_body.py} +16 -16
  167. magic_hour/types/params/{post_v1_animation_body_assets.py → v1_animation_create_body_assets.py} +15 -5
  168. magic_hour/types/params/{post_v1_animation_body_style.py → v1_animation_create_body_style.py} +13 -10
  169. magic_hour/types/params/v1_animation_generate_body_assets.py +39 -0
  170. magic_hour/types/params/v1_auto_subtitle_generator_create_body.py +78 -0
  171. magic_hour/types/params/v1_auto_subtitle_generator_create_body_assets.py +33 -0
  172. magic_hour/types/params/v1_auto_subtitle_generator_create_body_style.py +56 -0
  173. magic_hour/types/params/v1_auto_subtitle_generator_create_body_style_custom_config.py +86 -0
  174. magic_hour/types/params/v1_auto_subtitle_generator_generate_body_assets.py +17 -0
  175. magic_hour/types/params/v1_face_detection_create_body.py +44 -0
  176. magic_hour/types/params/v1_face_detection_create_body_assets.py +33 -0
  177. magic_hour/types/params/v1_face_detection_generate_body_assets.py +17 -0
  178. magic_hour/types/params/v1_face_swap_create_body.py +92 -0
  179. magic_hour/types/params/v1_face_swap_create_body_assets.py +91 -0
  180. magic_hour/types/params/v1_face_swap_create_body_assets_face_mappings_item.py +44 -0
  181. magic_hour/types/params/v1_face_swap_create_body_style.py +33 -0
  182. magic_hour/types/params/v1_face_swap_generate_body_assets.py +56 -0
  183. magic_hour/types/params/v1_face_swap_generate_body_assets_face_mappings_item.py +25 -0
  184. magic_hour/types/params/v1_face_swap_photo_create_body.py +40 -0
  185. magic_hour/types/params/v1_face_swap_photo_create_body_assets.py +76 -0
  186. magic_hour/types/params/v1_face_swap_photo_create_body_assets_face_mappings_item.py +44 -0
  187. magic_hour/types/params/v1_face_swap_photo_generate_body_assets.py +47 -0
  188. magic_hour/types/params/v1_face_swap_photo_generate_body_assets_face_mappings_item.py +25 -0
  189. magic_hour/types/params/v1_files_upload_urls_create_body.py +36 -0
  190. magic_hour/types/params/v1_files_upload_urls_create_body_items_item.py +38 -0
  191. magic_hour/types/params/v1_image_background_remover_create_body.py +40 -0
  192. magic_hour/types/params/v1_image_background_remover_create_body_assets.py +49 -0
  193. magic_hour/types/params/v1_image_background_remover_generate_body_assets.py +27 -0
  194. magic_hour/types/params/v1_image_to_video_create_body.py +101 -0
  195. magic_hour/types/params/v1_image_to_video_create_body_assets.py +33 -0
  196. magic_hour/types/params/v1_image_to_video_create_body_style.py +53 -0
  197. magic_hour/types/params/v1_image_to_video_generate_body_assets.py +17 -0
  198. magic_hour/types/params/v1_lip_sync_create_body.py +100 -0
  199. magic_hour/types/params/{post_v1_lip_sync_body_assets.py → v1_lip_sync_create_body_assets.py} +15 -5
  200. magic_hour/types/params/v1_lip_sync_create_body_style.py +37 -0
  201. magic_hour/types/params/v1_lip_sync_generate_body_assets.py +36 -0
  202. magic_hour/types/params/v1_photo_colorizer_create_body.py +40 -0
  203. magic_hour/types/params/v1_photo_colorizer_create_body_assets.py +33 -0
  204. magic_hour/types/params/v1_photo_colorizer_generate_body_assets.py +17 -0
  205. magic_hour/types/params/v1_text_to_video_create_body.py +78 -0
  206. magic_hour/types/params/v1_text_to_video_create_body_style.py +43 -0
  207. magic_hour/types/params/v1_video_to_video_create_body.py +101 -0
  208. magic_hour/types/params/{post_v1_video_to_video_body_assets.py → v1_video_to_video_create_body_assets.py} +9 -4
  209. magic_hour/types/params/{post_v1_video_to_video_body_style.py → v1_video_to_video_create_body_style.py} +68 -26
  210. magic_hour/types/params/v1_video_to_video_generate_body_assets.py +27 -0
  211. magic_hour-0.44.0.dist-info/METADATA +328 -0
  212. magic_hour-0.44.0.dist-info/RECORD +231 -0
  213. magic_hour/core/__init__.py +0 -52
  214. magic_hour/core/api_error.py +0 -56
  215. magic_hour/core/auth.py +0 -314
  216. magic_hour/core/base_client.py +0 -618
  217. magic_hour/core/binary_response.py +0 -23
  218. magic_hour/core/query.py +0 -106
  219. magic_hour/core/request.py +0 -156
  220. magic_hour/core/response.py +0 -293
  221. magic_hour/core/type_utils.py +0 -28
  222. magic_hour/core/utils.py +0 -55
  223. magic_hour/types/models/post_v1_ai_clothes_changer_response.py +0 -25
  224. magic_hour/types/models/post_v1_ai_headshot_generator_response.py +0 -25
  225. magic_hour/types/models/post_v1_ai_image_generator_response.py +0 -25
  226. magic_hour/types/models/post_v1_ai_image_upscaler_response.py +0 -25
  227. magic_hour/types/models/post_v1_ai_photo_editor_response.py +0 -25
  228. magic_hour/types/models/post_v1_ai_qr_code_generator_response.py +0 -25
  229. magic_hour/types/models/post_v1_animation_response.py +0 -25
  230. magic_hour/types/models/post_v1_face_swap_photo_response.py +0 -25
  231. magic_hour/types/models/post_v1_face_swap_response.py +0 -25
  232. magic_hour/types/models/post_v1_files_upload_urls_response.py +0 -21
  233. magic_hour/types/models/post_v1_image_background_remover_response.py +0 -25
  234. magic_hour/types/models/post_v1_image_to_video_response.py +0 -25
  235. magic_hour/types/models/post_v1_lip_sync_response.py +0 -25
  236. magic_hour/types/models/post_v1_text_to_video_response.py +0 -25
  237. magic_hour/types/models/post_v1_video_to_video_response.py +0 -25
  238. magic_hour/types/params/post_v1_ai_clothes_changer_body.py +0 -40
  239. magic_hour/types/params/post_v1_ai_clothes_changer_body_assets.py +0 -45
  240. magic_hour/types/params/post_v1_ai_headshot_generator_body.py +0 -40
  241. magic_hour/types/params/post_v1_ai_headshot_generator_body_assets.py +0 -28
  242. magic_hour/types/params/post_v1_ai_image_upscaler_body.py +0 -57
  243. magic_hour/types/params/post_v1_ai_image_upscaler_body_assets.py +0 -28
  244. magic_hour/types/params/post_v1_ai_photo_editor_body_assets.py +0 -28
  245. magic_hour/types/params/post_v1_ai_qr_code_generator_body.py +0 -45
  246. magic_hour/types/params/post_v1_face_swap_body.py +0 -72
  247. magic_hour/types/params/post_v1_face_swap_body_assets.py +0 -52
  248. magic_hour/types/params/post_v1_face_swap_photo_body.py +0 -40
  249. magic_hour/types/params/post_v1_face_swap_photo_body_assets.py +0 -36
  250. magic_hour/types/params/post_v1_files_upload_urls_body.py +0 -31
  251. magic_hour/types/params/post_v1_files_upload_urls_body_items_item.py +0 -38
  252. magic_hour/types/params/post_v1_image_background_remover_body.py +0 -40
  253. magic_hour/types/params/post_v1_image_background_remover_body_assets.py +0 -28
  254. magic_hour/types/params/post_v1_image_to_video_body.py +0 -73
  255. magic_hour/types/params/post_v1_image_to_video_body_assets.py +0 -28
  256. magic_hour/types/params/post_v1_image_to_video_body_style.py +0 -37
  257. magic_hour/types/params/post_v1_lip_sync_body.py +0 -80
  258. magic_hour/types/params/post_v1_text_to_video_body.py +0 -57
  259. magic_hour/types/params/post_v1_text_to_video_body_style.py +0 -28
  260. magic_hour/types/params/post_v1_video_to_video_body.py +0 -93
  261. magic_hour-0.9.5.dist-info/METADATA +0 -133
  262. magic_hour-0.9.5.dist-info/RECORD +0 -132
  263. {magic_hour-0.9.5.dist-info → magic_hour-0.44.0.dist-info}/LICENSE +0 -0
  264. {magic_hour-0.9.5.dist-info → magic_hour-0.44.0.dist-info}/WHEEL +0 -0
@@ -0,0 +1,346 @@
1
+ import typing
2
+
3
+ from magic_hour.helpers.logger import get_sdk_logger
4
+ from magic_hour.resources.v1.files.client import AsyncFilesClient, FilesClient
5
+ from magic_hour.resources.v1.video_projects.client import (
6
+ AsyncVideoProjectsClient,
7
+ VideoProjectsClient,
8
+ )
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 AutoSubtitleGeneratorClient:
24
+ def __init__(self, *, base_client: SyncBaseClient):
25
+ self._base_client = base_client
26
+
27
+ def generate(
28
+ self,
29
+ *,
30
+ assets: params.V1AutoSubtitleGeneratorCreateBodyAssets,
31
+ end_seconds: float,
32
+ start_seconds: float,
33
+ style: params.V1AutoSubtitleGeneratorCreateBodyStyle,
34
+ name: typing.Union[
35
+ typing.Optional[str], type_utils.NotGiven
36
+ ] = type_utils.NOT_GIVEN,
37
+ wait_for_completion: bool = True,
38
+ download_outputs: bool = True,
39
+ download_directory: typing.Optional[str] = None,
40
+ request_options: typing.Optional[RequestOptions] = None,
41
+ ):
42
+ """
43
+ Generate subtitled video (alias for create with additional functionality).
44
+
45
+ Automatically generate subtitles for your video in multiple languages.
46
+
47
+ Args:
48
+ name: The name of video. This value is mainly used for your own identification of the video.
49
+ assets: Provide the assets for auto subtitle generator
50
+ end_seconds: The end time of the input video in seconds. This value is used to trim the input video. The value must be greater than 0.1, and more than the start_seconds.
51
+ start_seconds: The start time of the input video in seconds. This value is used to trim the input video. The value must be greater than 0.
52
+ style: Style of the subtitle. At least one of `.style.template` or `.style.custom_config` must be provided.
53
+ * If only `.style.template` is provided, default values for the template will be used.
54
+ * If both are provided, the fields in `.style.custom_config` will be used to overwrite the fields in `.style.template`.
55
+ * If only `.style.custom_config` is provided, then all fields in `.style.custom_config` will be used.
56
+
57
+ To use custom config only, the following `custom_config` params are required:
58
+ * `.style.custom_config.font`
59
+ * `.style.custom_config.text_color`
60
+ * `.style.custom_config.vertical_position`
61
+ * `.style.custom_config.horizontal_position`
62
+
63
+ wait_for_completion: Whether to wait for the video project to complete
64
+ download_outputs: Whether to download the outputs
65
+ download_directory: The directory to download the outputs to. If not provided, the outputs will be downloaded to the current working directory
66
+ request_options: Additional options to customize the HTTP request
67
+
68
+ Returns:
69
+ V1VideoProjectsGetResponseWithDownloads: The response from the Auto Subtitle Generator API with the downloaded paths if `download_outputs` is True.
70
+
71
+ Examples:
72
+ ```py
73
+ response = client.v1.auto_subtitle_generator.generate(
74
+ assets={"video_file_path": "path/to/video.mp4"},
75
+ end_seconds=15.0,
76
+ start_seconds=0.0,
77
+ style={},
78
+ name="Subtitled Video",
79
+ wait_for_completion=True,
80
+ download_outputs=True,
81
+ download_directory="outputs/",
82
+ )
83
+ ```
84
+ """
85
+
86
+ file_client = FilesClient(base_client=self._base_client)
87
+
88
+ video_file_path = assets["video_file_path"]
89
+ assets["video_file_path"] = file_client.upload_file(file=video_file_path)
90
+
91
+ create_response = self.create(
92
+ assets=assets,
93
+ end_seconds=end_seconds,
94
+ start_seconds=start_seconds,
95
+ style=style,
96
+ name=name,
97
+ request_options=request_options,
98
+ )
99
+ logger.info(f"Auto Subtitle Generator response: {create_response}")
100
+
101
+ video_projects_client = VideoProjectsClient(base_client=self._base_client)
102
+ response = video_projects_client.check_result(
103
+ id=create_response.id,
104
+ wait_for_completion=wait_for_completion,
105
+ download_outputs=download_outputs,
106
+ download_directory=download_directory,
107
+ )
108
+
109
+ return response
110
+
111
+ def create(
112
+ self,
113
+ *,
114
+ assets: params.V1AutoSubtitleGeneratorCreateBodyAssets,
115
+ end_seconds: float,
116
+ start_seconds: float,
117
+ style: params.V1AutoSubtitleGeneratorCreateBodyStyle,
118
+ name: typing.Union[
119
+ typing.Optional[str], type_utils.NotGiven
120
+ ] = type_utils.NOT_GIVEN,
121
+ request_options: typing.Optional[RequestOptions] = None,
122
+ ) -> models.V1AutoSubtitleGeneratorCreateResponse:
123
+ """
124
+ Auto Subtitle Generator
125
+
126
+ Automatically generate subtitles for your video in multiple languages.
127
+
128
+ POST /v1/auto-subtitle-generator
129
+
130
+ Args:
131
+ name: The name of video. This value is mainly used for your own identification of the video.
132
+ assets: Provide the assets for auto subtitle generator
133
+ end_seconds: The end time of the input video in seconds. This value is used to trim the input video. The value must be greater than 0.1, and more than the start_seconds.
134
+ start_seconds: The start time of the input video in seconds. This value is used to trim the input video. The value must be greater than 0.
135
+ style: Style of the subtitle. At least one of `.style.template` or `.style.custom_config` must be provided.
136
+ * If only `.style.template` is provided, default values for the template will be used.
137
+ * If both are provided, the fields in `.style.custom_config` will be used to overwrite the fields in `.style.template`.
138
+ * If only `.style.custom_config` is provided, then all fields in `.style.custom_config` will be used.
139
+
140
+ To use custom config only, the following `custom_config` params are required:
141
+ * `.style.custom_config.font`
142
+ * `.style.custom_config.text_color`
143
+ * `.style.custom_config.vertical_position`
144
+ * `.style.custom_config.horizontal_position`
145
+
146
+ request_options: Additional options to customize the HTTP request
147
+
148
+ Returns:
149
+ Success
150
+
151
+ Raises:
152
+ ApiError: A custom exception class that provides additional context
153
+ for API errors, including the HTTP status code and response body.
154
+
155
+ Examples:
156
+ ```py
157
+ client.v1.auto_subtitle_generator.create(
158
+ assets={"video_file_path": "api-assets/id/1234.mp4"},
159
+ end_seconds=15.0,
160
+ start_seconds=0.0,
161
+ style={},
162
+ name="Auto Subtitle video",
163
+ )
164
+ ```
165
+ """
166
+ _json = to_encodable(
167
+ item={
168
+ "name": name,
169
+ "assets": assets,
170
+ "end_seconds": end_seconds,
171
+ "start_seconds": start_seconds,
172
+ "style": style,
173
+ },
174
+ dump_with=params._SerializerV1AutoSubtitleGeneratorCreateBody,
175
+ )
176
+ return self._base_client.request(
177
+ method="POST",
178
+ path="/v1/auto-subtitle-generator",
179
+ auth_names=["bearerAuth"],
180
+ json=_json,
181
+ cast_to=models.V1AutoSubtitleGeneratorCreateResponse,
182
+ request_options=request_options or default_request_options(),
183
+ )
184
+
185
+
186
+ class AsyncAutoSubtitleGeneratorClient:
187
+ def __init__(self, *, base_client: AsyncBaseClient):
188
+ self._base_client = base_client
189
+
190
+ async def generate(
191
+ self,
192
+ *,
193
+ assets: params.V1AutoSubtitleGeneratorCreateBodyAssets,
194
+ end_seconds: float,
195
+ start_seconds: float,
196
+ style: params.V1AutoSubtitleGeneratorCreateBodyStyle,
197
+ name: typing.Union[
198
+ typing.Optional[str], type_utils.NotGiven
199
+ ] = type_utils.NOT_GIVEN,
200
+ wait_for_completion: bool = True,
201
+ download_outputs: bool = True,
202
+ download_directory: typing.Optional[str] = None,
203
+ request_options: typing.Optional[RequestOptions] = None,
204
+ ):
205
+ """
206
+ Generate subtitled video (alias for create with additional functionality).
207
+
208
+ Automatically generate subtitles for your video in multiple languages.
209
+
210
+ Args:
211
+ name: The name of video. This value is mainly used for your own identification of the video.
212
+ assets: Provide the assets for auto subtitle generator
213
+ end_seconds: The end time of the input video in seconds. This value is used to trim the input video. The value must be greater than 0.1, and more than the start_seconds.
214
+ start_seconds: The start time of the input video in seconds. This value is used to trim the input video. The value must be greater than 0.
215
+ style: Style of the subtitle. At least one of `.style.template` or `.style.custom_config` must be provided.
216
+ * If only `.style.template` is provided, default values for the template will be used.
217
+ * If both are provided, the fields in `.style.custom_config` will be used to overwrite the fields in `.style.template`.
218
+ * If only `.style.custom_config` is provided, then all fields in `.style.custom_config` will be used.
219
+
220
+ To use custom config only, the following `custom_config` params are required:
221
+ * `.style.custom_config.font`
222
+ * `.style.custom_config.text_color`
223
+ * `.style.custom_config.vertical_position`
224
+ * `.style.custom_config.horizontal_position`
225
+
226
+ wait_for_completion: Whether to wait for the video project to complete
227
+ download_outputs: Whether to download the outputs
228
+ download_directory: The directory to download the outputs to. If not provided, the outputs will be downloaded to the current working directory
229
+ request_options: Additional options to customize the HTTP request
230
+
231
+ Returns:
232
+ V1VideoProjectsGetResponseWithDownloads: The response from the Auto Subtitle Generator API with the downloaded paths if `download_outputs` is True.
233
+
234
+ Examples:
235
+ ```py
236
+ response = await client.v1.auto_subtitle_generator.generate(
237
+ assets={"video_file_path": "path/to/video.mp4"},
238
+ end_seconds=15.0,
239
+ start_seconds=0.0,
240
+ style={},
241
+ name="Subtitled Video",
242
+ wait_for_completion=True,
243
+ download_outputs=True,
244
+ download_directory="outputs/",
245
+ )
246
+ ```
247
+ """
248
+
249
+ file_client = AsyncFilesClient(base_client=self._base_client)
250
+
251
+ video_file_path = assets["video_file_path"]
252
+ assets["video_file_path"] = await file_client.upload_file(file=video_file_path)
253
+
254
+ create_response = await self.create(
255
+ assets=assets,
256
+ end_seconds=end_seconds,
257
+ start_seconds=start_seconds,
258
+ style=style,
259
+ name=name,
260
+ request_options=request_options,
261
+ )
262
+ logger.info(f"Auto Subtitle Generator response: {create_response}")
263
+
264
+ video_projects_client = AsyncVideoProjectsClient(base_client=self._base_client)
265
+ response = await video_projects_client.check_result(
266
+ id=create_response.id,
267
+ wait_for_completion=wait_for_completion,
268
+ download_outputs=download_outputs,
269
+ download_directory=download_directory,
270
+ )
271
+
272
+ return response
273
+
274
+ async def create(
275
+ self,
276
+ *,
277
+ assets: params.V1AutoSubtitleGeneratorCreateBodyAssets,
278
+ end_seconds: float,
279
+ start_seconds: float,
280
+ style: params.V1AutoSubtitleGeneratorCreateBodyStyle,
281
+ name: typing.Union[
282
+ typing.Optional[str], type_utils.NotGiven
283
+ ] = type_utils.NOT_GIVEN,
284
+ request_options: typing.Optional[RequestOptions] = None,
285
+ ) -> models.V1AutoSubtitleGeneratorCreateResponse:
286
+ """
287
+ Auto Subtitle Generator
288
+
289
+ Automatically generate subtitles for your video in multiple languages.
290
+
291
+ POST /v1/auto-subtitle-generator
292
+
293
+ Args:
294
+ name: The name of video. This value is mainly used for your own identification of the video.
295
+ assets: Provide the assets for auto subtitle generator
296
+ end_seconds: The end time of the input video in seconds. This value is used to trim the input video. The value must be greater than 0.1, and more than the start_seconds.
297
+ start_seconds: The start time of the input video in seconds. This value is used to trim the input video. The value must be greater than 0.
298
+ style: Style of the subtitle. At least one of `.style.template` or `.style.custom_config` must be provided.
299
+ * If only `.style.template` is provided, default values for the template will be used.
300
+ * If both are provided, the fields in `.style.custom_config` will be used to overwrite the fields in `.style.template`.
301
+ * If only `.style.custom_config` is provided, then all fields in `.style.custom_config` will be used.
302
+
303
+ To use custom config only, the following `custom_config` params are required:
304
+ * `.style.custom_config.font`
305
+ * `.style.custom_config.text_color`
306
+ * `.style.custom_config.vertical_position`
307
+ * `.style.custom_config.horizontal_position`
308
+
309
+ request_options: Additional options to customize the HTTP request
310
+
311
+ Returns:
312
+ Success
313
+
314
+ Raises:
315
+ ApiError: A custom exception class that provides additional context
316
+ for API errors, including the HTTP status code and response body.
317
+
318
+ Examples:
319
+ ```py
320
+ await client.v1.auto_subtitle_generator.create(
321
+ assets={"video_file_path": "api-assets/id/1234.mp4"},
322
+ end_seconds=15.0,
323
+ start_seconds=0.0,
324
+ style={},
325
+ name="Auto Subtitle video",
326
+ )
327
+ ```
328
+ """
329
+ _json = to_encodable(
330
+ item={
331
+ "name": name,
332
+ "assets": assets,
333
+ "end_seconds": end_seconds,
334
+ "start_seconds": start_seconds,
335
+ "style": style,
336
+ },
337
+ dump_with=params._SerializerV1AutoSubtitleGeneratorCreateBody,
338
+ )
339
+ return await self._base_client.request(
340
+ method="POST",
341
+ path="/v1/auto-subtitle-generator",
342
+ auth_names=["bearerAuth"],
343
+ json=_json,
344
+ cast_to=models.V1AutoSubtitleGeneratorCreateResponse,
345
+ request_options=request_options or default_request_options(),
346
+ )
@@ -1,12 +1,23 @@
1
- from magic_hour.core import AsyncBaseClient, SyncBaseClient
2
1
  from magic_hour.resources.v1.ai_clothes_changer import (
3
2
  AiClothesChangerClient,
4
3
  AsyncAiClothesChangerClient,
5
4
  )
5
+ from magic_hour.resources.v1.ai_face_editor import (
6
+ AiFaceEditorClient,
7
+ AsyncAiFaceEditorClient,
8
+ )
9
+ from magic_hour.resources.v1.ai_gif_generator import (
10
+ AiGifGeneratorClient,
11
+ AsyncAiGifGeneratorClient,
12
+ )
6
13
  from magic_hour.resources.v1.ai_headshot_generator import (
7
14
  AiHeadshotGeneratorClient,
8
15
  AsyncAiHeadshotGeneratorClient,
9
16
  )
17
+ from magic_hour.resources.v1.ai_image_editor import (
18
+ AiImageEditorClient,
19
+ AsyncAiImageEditorClient,
20
+ )
10
21
  from magic_hour.resources.v1.ai_image_generator import (
11
22
  AiImageGeneratorClient,
12
23
  AsyncAiImageGeneratorClient,
@@ -15,6 +26,10 @@ from magic_hour.resources.v1.ai_image_upscaler import (
15
26
  AiImageUpscalerClient,
16
27
  AsyncAiImageUpscalerClient,
17
28
  )
29
+ from magic_hour.resources.v1.ai_meme_generator import (
30
+ AiMemeGeneratorClient,
31
+ AsyncAiMemeGeneratorClient,
32
+ )
18
33
  from magic_hour.resources.v1.ai_photo_editor import (
19
34
  AiPhotoEditorClient,
20
35
  AsyncAiPhotoEditorClient,
@@ -23,7 +38,31 @@ from magic_hour.resources.v1.ai_qr_code_generator import (
23
38
  AiQrCodeGeneratorClient,
24
39
  AsyncAiQrCodeGeneratorClient,
25
40
  )
41
+ from magic_hour.resources.v1.ai_talking_photo import (
42
+ AiTalkingPhotoClient,
43
+ AsyncAiTalkingPhotoClient,
44
+ )
45
+ from magic_hour.resources.v1.ai_voice_cloner import (
46
+ AiVoiceClonerClient,
47
+ AsyncAiVoiceClonerClient,
48
+ )
49
+ from magic_hour.resources.v1.ai_voice_generator import (
50
+ AiVoiceGeneratorClient,
51
+ AsyncAiVoiceGeneratorClient,
52
+ )
26
53
  from magic_hour.resources.v1.animation import AnimationClient, AsyncAnimationClient
54
+ from magic_hour.resources.v1.audio_projects import (
55
+ AsyncAudioProjectsClient,
56
+ AudioProjectsClient,
57
+ )
58
+ from magic_hour.resources.v1.auto_subtitle_generator import (
59
+ AsyncAutoSubtitleGeneratorClient,
60
+ AutoSubtitleGeneratorClient,
61
+ )
62
+ from magic_hour.resources.v1.face_detection import (
63
+ AsyncFaceDetectionClient,
64
+ FaceDetectionClient,
65
+ )
27
66
  from magic_hour.resources.v1.face_swap import AsyncFaceSwapClient, FaceSwapClient
28
67
  from magic_hour.resources.v1.face_swap_photo import (
29
68
  AsyncFaceSwapPhotoClient,
@@ -43,6 +82,10 @@ from magic_hour.resources.v1.image_to_video import (
43
82
  ImageToVideoClient,
44
83
  )
45
84
  from magic_hour.resources.v1.lip_sync import AsyncLipSyncClient, LipSyncClient
85
+ from magic_hour.resources.v1.photo_colorizer import (
86
+ AsyncPhotoColorizerClient,
87
+ PhotoColorizerClient,
88
+ )
46
89
  from magic_hour.resources.v1.text_to_video import (
47
90
  AsyncTextToVideoClient,
48
91
  TextToVideoClient,
@@ -55,6 +98,7 @@ from magic_hour.resources.v1.video_to_video import (
55
98
  AsyncVideoToVideoClient,
56
99
  VideoToVideoClient,
57
100
  )
101
+ from make_api_request import AsyncBaseClient, SyncBaseClient
58
102
 
59
103
 
60
104
  class V1Client:
@@ -62,17 +106,26 @@ class V1Client:
62
106
  self._base_client = base_client
63
107
  self.image_projects = ImageProjectsClient(base_client=self._base_client)
64
108
  self.video_projects = VideoProjectsClient(base_client=self._base_client)
109
+ self.face_detection = FaceDetectionClient(base_client=self._base_client)
65
110
  self.ai_clothes_changer = AiClothesChangerClient(base_client=self._base_client)
111
+ self.ai_face_editor = AiFaceEditorClient(base_client=self._base_client)
112
+ self.ai_gif_generator = AiGifGeneratorClient(base_client=self._base_client)
66
113
  self.ai_headshot_generator = AiHeadshotGeneratorClient(
67
114
  base_client=self._base_client
68
115
  )
116
+ self.ai_image_editor = AiImageEditorClient(base_client=self._base_client)
69
117
  self.ai_image_generator = AiImageGeneratorClient(base_client=self._base_client)
70
118
  self.ai_image_upscaler = AiImageUpscalerClient(base_client=self._base_client)
119
+ self.ai_meme_generator = AiMemeGeneratorClient(base_client=self._base_client)
71
120
  self.ai_photo_editor = AiPhotoEditorClient(base_client=self._base_client)
72
121
  self.ai_qr_code_generator = AiQrCodeGeneratorClient(
73
122
  base_client=self._base_client
74
123
  )
124
+ self.ai_talking_photo = AiTalkingPhotoClient(base_client=self._base_client)
75
125
  self.animation = AnimationClient(base_client=self._base_client)
126
+ self.auto_subtitle_generator = AutoSubtitleGeneratorClient(
127
+ base_client=self._base_client
128
+ )
76
129
  self.face_swap = FaceSwapClient(base_client=self._base_client)
77
130
  self.face_swap_photo = FaceSwapPhotoClient(base_client=self._base_client)
78
131
  self.files = FilesClient(base_client=self._base_client)
@@ -81,8 +134,12 @@ class V1Client:
81
134
  )
82
135
  self.image_to_video = ImageToVideoClient(base_client=self._base_client)
83
136
  self.lip_sync = LipSyncClient(base_client=self._base_client)
137
+ self.photo_colorizer = PhotoColorizerClient(base_client=self._base_client)
84
138
  self.text_to_video = TextToVideoClient(base_client=self._base_client)
85
139
  self.video_to_video = VideoToVideoClient(base_client=self._base_client)
140
+ self.audio_projects = AudioProjectsClient(base_client=self._base_client)
141
+ self.ai_voice_generator = AiVoiceGeneratorClient(base_client=self._base_client)
142
+ self.ai_voice_cloner = AiVoiceClonerClient(base_client=self._base_client)
86
143
 
87
144
 
88
145
  class AsyncV1Client:
@@ -90,23 +147,34 @@ class AsyncV1Client:
90
147
  self._base_client = base_client
91
148
  self.image_projects = AsyncImageProjectsClient(base_client=self._base_client)
92
149
  self.video_projects = AsyncVideoProjectsClient(base_client=self._base_client)
150
+ self.face_detection = AsyncFaceDetectionClient(base_client=self._base_client)
93
151
  self.ai_clothes_changer = AsyncAiClothesChangerClient(
94
152
  base_client=self._base_client
95
153
  )
154
+ self.ai_face_editor = AsyncAiFaceEditorClient(base_client=self._base_client)
155
+ self.ai_gif_generator = AsyncAiGifGeneratorClient(base_client=self._base_client)
96
156
  self.ai_headshot_generator = AsyncAiHeadshotGeneratorClient(
97
157
  base_client=self._base_client
98
158
  )
159
+ self.ai_image_editor = AsyncAiImageEditorClient(base_client=self._base_client)
99
160
  self.ai_image_generator = AsyncAiImageGeneratorClient(
100
161
  base_client=self._base_client
101
162
  )
102
163
  self.ai_image_upscaler = AsyncAiImageUpscalerClient(
103
164
  base_client=self._base_client
104
165
  )
166
+ self.ai_meme_generator = AsyncAiMemeGeneratorClient(
167
+ base_client=self._base_client
168
+ )
105
169
  self.ai_photo_editor = AsyncAiPhotoEditorClient(base_client=self._base_client)
106
170
  self.ai_qr_code_generator = AsyncAiQrCodeGeneratorClient(
107
171
  base_client=self._base_client
108
172
  )
173
+ self.ai_talking_photo = AsyncAiTalkingPhotoClient(base_client=self._base_client)
109
174
  self.animation = AsyncAnimationClient(base_client=self._base_client)
175
+ self.auto_subtitle_generator = AsyncAutoSubtitleGeneratorClient(
176
+ base_client=self._base_client
177
+ )
110
178
  self.face_swap = AsyncFaceSwapClient(base_client=self._base_client)
111
179
  self.face_swap_photo = AsyncFaceSwapPhotoClient(base_client=self._base_client)
112
180
  self.files = AsyncFilesClient(base_client=self._base_client)
@@ -115,5 +183,11 @@ class AsyncV1Client:
115
183
  )
116
184
  self.image_to_video = AsyncImageToVideoClient(base_client=self._base_client)
117
185
  self.lip_sync = AsyncLipSyncClient(base_client=self._base_client)
186
+ self.photo_colorizer = AsyncPhotoColorizerClient(base_client=self._base_client)
118
187
  self.text_to_video = AsyncTextToVideoClient(base_client=self._base_client)
119
188
  self.video_to_video = AsyncVideoToVideoClient(base_client=self._base_client)
189
+ self.audio_projects = AsyncAudioProjectsClient(base_client=self._base_client)
190
+ self.ai_voice_generator = AsyncAiVoiceGeneratorClient(
191
+ base_client=self._base_client
192
+ )
193
+ self.ai_voice_cloner = AsyncAiVoiceClonerClient(base_client=self._base_client)
@@ -0,0 +1,157 @@
1
+ # v1.face_detection
2
+
3
+ ## Module Functions
4
+
5
+ <!-- CUSTOM DOCS START -->
6
+
7
+ ### Face Detection 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.face_detection.generate(
35
+ assets={"target_file_path": "/path/to/1234.png"}, confidence_score=0.5
36
+ wait_for_completion=True,
37
+ download_outputs=True,
38
+ download_directory="outputs"
39
+ )
40
+ ```
41
+
42
+ #### Asynchronous Client
43
+
44
+ ```python
45
+ from magic_hour import AsyncClient
46
+ from os import getenv
47
+
48
+ client = AsyncClient(token=getenv("API_TOKEN"))
49
+ res = await client.v1.face_detection.generate(
50
+ assets={"target_file_path": "/path/to/1234.png"}, confidence_score=0.5
51
+ wait_for_completion=True,
52
+ download_outputs=True,
53
+ download_directory="outputs"
54
+ )
55
+ ```
56
+
57
+ <!-- CUSTOM DOCS END -->
58
+
59
+ ### Get face detection details <a name="get"></a>
60
+
61
+ Get the details of a face detection task.
62
+
63
+ Use this API to get the list of faces detected in the image or video to use in the [face swap photo](/api-reference/face-swap-photo/face-swap-photo) or [face swap video](/api-reference/face-swap/face-swap-video) API calls for multi-face swaps.
64
+
65
+ **API Endpoint**: `GET /v1/face-detection/{id}`
66
+
67
+ #### Parameters
68
+
69
+ | Parameter | Required | Description | Example |
70
+ | --------- | :------: | ------------------------------------------------------------------------------------------------------------------------ | ---------------- |
71
+ | `id` | ✓ | The id of the task. This value is returned by the [face detection API](/api-reference/files/face-detection#response-id). | `"uuid-example"` |
72
+
73
+ #### Synchronous Client
74
+
75
+ ```python
76
+ from magic_hour import Client
77
+ from os import getenv
78
+
79
+ client = Client(token=getenv("API_TOKEN"))
80
+ res = client.v1.face_detection.get(id="uuid-example")
81
+ ```
82
+
83
+ #### Asynchronous Client
84
+
85
+ ```python
86
+ from magic_hour import AsyncClient
87
+ from os import getenv
88
+
89
+ client = AsyncClient(token=getenv("API_TOKEN"))
90
+ res = await client.v1.face_detection.get(id="uuid-example")
91
+ ```
92
+
93
+ #### Response
94
+
95
+ ##### Type
96
+
97
+ [V1FaceDetectionGetResponse](/magic_hour/types/models/v1_face_detection_get_response.py)
98
+
99
+ ##### Example
100
+
101
+ ```python
102
+ {"credits_charged": 0, "faces": [{"path": "api-assets/id/0-0.png", "url": "https://videos.magichour.ai/api-assets/id/0-0.png"}], "id": "uuid-example", "status": "complete"}
103
+ ```
104
+
105
+ ### Face Detection <a name="create"></a>
106
+
107
+ Detect faces in an image or video.
108
+
109
+ Use this API to get the list of faces detected in the image or video to use in the [face swap photo](/api-reference/face-swap-photo/face-swap-photo) or [face swap video](/api-reference/face-swap/face-swap-video) API calls for multi-face swaps.
110
+
111
+ Note: Face detection is free to use for the near future. Pricing may change in the future.
112
+
113
+ **API Endpoint**: `POST /v1/face-detection`
114
+
115
+ #### Parameters
116
+
117
+ | Parameter | Required | Description | Example |
118
+ | --------------------- | :------: | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ |
119
+ | `assets` | ✓ | Provide the assets for face detection | `{"target_file_path": "api-assets/id/1234.png"}` |
120
+ | `└─ target_file_path` | ✓ | This is the image or video where the face will be detected. 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"` |
121
+ | `confidence_score` | ✗ | Confidence threshold for filtering detected faces. * Higher values (e.g., 0.9) include only faces detected with high certainty, reducing false positives. * Lower values (e.g., 0.3) include more faces, but may increase the chance of incorrect detections. | `0.5` |
122
+
123
+ #### Synchronous Client
124
+
125
+ ```python
126
+ from magic_hour import Client
127
+ from os import getenv
128
+
129
+ client = Client(token=getenv("API_TOKEN"))
130
+ res = client.v1.face_detection.create(
131
+ assets={"target_file_path": "api-assets/id/1234.png"}, confidence_score=0.5
132
+ )
133
+ ```
134
+
135
+ #### Asynchronous Client
136
+
137
+ ```python
138
+ from magic_hour import AsyncClient
139
+ from os import getenv
140
+
141
+ client = AsyncClient(token=getenv("API_TOKEN"))
142
+ res = await client.v1.face_detection.create(
143
+ assets={"target_file_path": "api-assets/id/1234.png"}, confidence_score=0.5
144
+ )
145
+ ```
146
+
147
+ #### Response
148
+
149
+ ##### Type
150
+
151
+ [V1FaceDetectionCreateResponse](/magic_hour/types/models/v1_face_detection_create_response.py)
152
+
153
+ ##### Example
154
+
155
+ ```python
156
+ {"credits_charged": 123, "id": "uuid-example"}
157
+ ```
@@ -0,0 +1,12 @@
1
+ from .client import (
2
+ AsyncFaceDetectionClient,
3
+ FaceDetectionClient,
4
+ V1FaceDetectionGetResponseWithDownloads,
5
+ )
6
+
7
+
8
+ __all__ = [
9
+ "AsyncFaceDetectionClient",
10
+ "FaceDetectionClient",
11
+ "V1FaceDetectionGetResponseWithDownloads",
12
+ ]