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,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
+ )
@@ -0,0 +1,112 @@
1
+ # v1.ai_voice_generator
2
+
3
+ ## Module Functions
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
+
61
+ ### AI Voice Generator <a name="create"></a>
62
+
63
+ Generate speech from text. Each character costs 0.05 credits. The cost is rounded up to the nearest whole number.
64
+
65
+ **API Endpoint**: `POST /v1/ai-voice-generator`
66
+
67
+ #### Parameters
68
+
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"` |
75
+
76
+ #### Synchronous Client
77
+
78
+ ```python
79
+ from magic_hour import Client
80
+ from os import getenv
81
+
82
+ client = Client(token=getenv("API_TOKEN"))
83
+ res = client.v1.ai_voice_generator.create(
84
+ style={"prompt": "Hello, how are you?", "voice_name": "Elon Musk"},
85
+ name="Voice Generator audio",
86
+ )
87
+ ```
88
+
89
+ #### Asynchronous Client
90
+
91
+ ```python
92
+ from magic_hour import AsyncClient
93
+ from os import getenv
94
+
95
+ client = AsyncClient(token=getenv("API_TOKEN"))
96
+ res = await client.v1.ai_voice_generator.create(
97
+ style={"prompt": "Hello, how are you?", "voice_name": "Elon Musk"},
98
+ name="Voice Generator audio",
99
+ )
100
+ ```
101
+
102
+ #### Response
103
+
104
+ ##### Type
105
+
106
+ [V1AiVoiceGeneratorCreateResponse](/magic_hour/types/models/v1_ai_voice_generator_create_response.py)
107
+
108
+ ##### Example
109
+
110
+ ```python
111
+ {"credits_charged": 1, "id": "cuid-example"}
112
+ ```
@@ -0,0 +1,4 @@
1
+ from .client import AiVoiceGeneratorClient, AsyncAiVoiceGeneratorClient
2
+
3
+
4
+ __all__ = ["AiVoiceGeneratorClient", "AsyncAiVoiceGeneratorClient"]
@@ -0,0 +1,241 @@
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.types import models, params
9
+ from make_api_request import (
10
+ AsyncBaseClient,
11
+ RequestOptions,
12
+ SyncBaseClient,
13
+ default_request_options,
14
+ to_encodable,
15
+ type_utils,
16
+ )
17
+
18
+
19
+ logger = get_sdk_logger(__name__)
20
+
21
+
22
+ class AiVoiceGeneratorClient:
23
+ def __init__(self, *, base_client: SyncBaseClient):
24
+ self._base_client = base_client
25
+
26
+ def generate(
27
+ self,
28
+ *,
29
+ style: params.V1AiVoiceGeneratorCreateBodyStyle,
30
+ name: typing.Union[
31
+ typing.Optional[str], type_utils.NotGiven
32
+ ] = type_utils.NOT_GIVEN,
33
+ wait_for_completion: bool = True,
34
+ download_outputs: bool = True,
35
+ download_directory: typing.Optional[str] = None,
36
+ request_options: typing.Optional[RequestOptions] = None,
37
+ ):
38
+ """
39
+ Generate AI voice (alias for create with additional functionality).
40
+
41
+ Generate speech from text. Each character costs 0.05 credits. The cost is rounded up to the nearest whole number.
42
+
43
+ Args:
44
+ style: The content used to generate speech.
45
+ name: The name of audio. This value is mainly used for your own identification of the audio.
46
+ wait_for_completion: Whether to wait for the audio project to complete
47
+ download_outputs: Whether to download the outputs
48
+ download_directory: The directory to download the outputs to. If not provided, the outputs will be downloaded to the current working directory
49
+ request_options: Additional options to customize the HTTP request
50
+
51
+ Returns:
52
+ V1AudioProjectsGetResponseWithDownloads: The response from the AI Voice Generator API with the downloaded paths if `download_outputs` is True.
53
+
54
+ Examples:
55
+ ```py
56
+ response = client.v1.ai_voice_generator.generate(
57
+ style={"prompt": "Hello, how are you?", "voice_name": "Elon Musk"},
58
+ name="Generated Voice",
59
+ wait_for_completion=True,
60
+ download_outputs=True,
61
+ download_directory="outputs/",
62
+ )
63
+ ```
64
+ """
65
+
66
+ create_response = self.create(
67
+ style=style,
68
+ name=name,
69
+ request_options=request_options,
70
+ )
71
+ logger.info(f"AI Voice Generator response: {create_response}")
72
+
73
+ audio_projects_client = AudioProjectsClient(base_client=self._base_client)
74
+ response = audio_projects_client.check_result(
75
+ id=create_response.id,
76
+ wait_for_completion=wait_for_completion,
77
+ download_outputs=download_outputs,
78
+ download_directory=download_directory,
79
+ )
80
+
81
+ return response
82
+
83
+ def create(
84
+ self,
85
+ *,
86
+ style: params.V1AiVoiceGeneratorCreateBodyStyle,
87
+ name: typing.Union[
88
+ typing.Optional[str], type_utils.NotGiven
89
+ ] = type_utils.NOT_GIVEN,
90
+ request_options: typing.Optional[RequestOptions] = None,
91
+ ) -> models.V1AiVoiceGeneratorCreateResponse:
92
+ """
93
+ AI Voice Generator
94
+
95
+ Generate speech from text. Each character costs 0.05 credits. The cost is rounded up to the nearest whole number.
96
+
97
+ POST /v1/ai-voice-generator
98
+
99
+ Args:
100
+ name: The name of audio. This value is mainly used for your own identification of the audio.
101
+ style: The content used to generate speech.
102
+ request_options: Additional options to customize the HTTP request
103
+
104
+ Returns:
105
+ Success
106
+
107
+ Raises:
108
+ ApiError: A custom exception class that provides additional context
109
+ for API errors, including the HTTP status code and response body.
110
+
111
+ Examples:
112
+ ```py
113
+ client.v1.ai_voice_generator.create(
114
+ style={"prompt": "Hello, how are you?", "voice_name": "Elon Musk"},
115
+ name="Voice Generator audio",
116
+ )
117
+ ```
118
+ """
119
+ _json = to_encodable(
120
+ item={"name": name, "style": style},
121
+ dump_with=params._SerializerV1AiVoiceGeneratorCreateBody,
122
+ )
123
+ return self._base_client.request(
124
+ method="POST",
125
+ path="/v1/ai-voice-generator",
126
+ auth_names=["bearerAuth"],
127
+ json=_json,
128
+ cast_to=models.V1AiVoiceGeneratorCreateResponse,
129
+ request_options=request_options or default_request_options(),
130
+ )
131
+
132
+
133
+ class AsyncAiVoiceGeneratorClient:
134
+ def __init__(self, *, base_client: AsyncBaseClient):
135
+ self._base_client = base_client
136
+
137
+ async def generate(
138
+ self,
139
+ *,
140
+ style: params.V1AiVoiceGeneratorCreateBodyStyle,
141
+ name: typing.Union[
142
+ typing.Optional[str], type_utils.NotGiven
143
+ ] = type_utils.NOT_GIVEN,
144
+ wait_for_completion: bool = True,
145
+ download_outputs: bool = True,
146
+ download_directory: typing.Optional[str] = None,
147
+ request_options: typing.Optional[RequestOptions] = None,
148
+ ):
149
+ """
150
+ Generate AI voice (alias for create with additional functionality).
151
+
152
+ Generate speech from text. Each character costs 0.05 credits. The cost is rounded up to the nearest whole number.
153
+
154
+ Args:
155
+ style: The content used to generate speech.
156
+ name: The name of audio. This value is mainly used for your own identification of the audio.
157
+ wait_for_completion: Whether to wait for the audio project to complete
158
+ download_outputs: Whether to download the outputs
159
+ download_directory: The directory to download the outputs to. If not provided, the outputs will be downloaded to the current working directory
160
+ request_options: Additional options to customize the HTTP request
161
+
162
+ Returns:
163
+ V1AudioProjectsGetResponseWithDownloads: The response from the AI Voice Generator API with the downloaded paths if `download_outputs` is True.
164
+
165
+ Examples:
166
+ ```py
167
+ response = await client.v1.ai_voice_generator.generate(
168
+ style={"prompt": "Hello, how are you?", "voice_name": "Elon Musk"},
169
+ name="Generated Voice",
170
+ wait_for_completion=True,
171
+ download_outputs=True,
172
+ download_directory="outputs/",
173
+ )
174
+ ```
175
+ """
176
+
177
+ create_response = await self.create(
178
+ style=style,
179
+ name=name,
180
+ request_options=request_options,
181
+ )
182
+ logger.info(f"AI Voice Generator response: {create_response}")
183
+
184
+ audio_projects_client = AsyncAudioProjectsClient(base_client=self._base_client)
185
+ response = await audio_projects_client.check_result(
186
+ id=create_response.id,
187
+ wait_for_completion=wait_for_completion,
188
+ download_outputs=download_outputs,
189
+ download_directory=download_directory,
190
+ )
191
+
192
+ return response
193
+
194
+ async def create(
195
+ self,
196
+ *,
197
+ style: params.V1AiVoiceGeneratorCreateBodyStyle,
198
+ name: typing.Union[
199
+ typing.Optional[str], type_utils.NotGiven
200
+ ] = type_utils.NOT_GIVEN,
201
+ request_options: typing.Optional[RequestOptions] = None,
202
+ ) -> models.V1AiVoiceGeneratorCreateResponse:
203
+ """
204
+ AI Voice Generator
205
+
206
+ Generate speech from text. Each character costs 0.05 credits. The cost is rounded up to the nearest whole number.
207
+
208
+ POST /v1/ai-voice-generator
209
+
210
+ Args:
211
+ name: The name of audio. This value is mainly used for your own identification of the audio.
212
+ style: The content used to generate speech.
213
+ request_options: Additional options to customize the HTTP request
214
+
215
+ Returns:
216
+ Success
217
+
218
+ Raises:
219
+ ApiError: A custom exception class that provides additional context
220
+ for API errors, including the HTTP status code and response body.
221
+
222
+ Examples:
223
+ ```py
224
+ await client.v1.ai_voice_generator.create(
225
+ style={"prompt": "Hello, how are you?", "voice_name": "Elon Musk"},
226
+ name="Voice Generator audio",
227
+ )
228
+ ```
229
+ """
230
+ _json = to_encodable(
231
+ item={"name": name, "style": style},
232
+ dump_with=params._SerializerV1AiVoiceGeneratorCreateBody,
233
+ )
234
+ return await self._base_client.request(
235
+ method="POST",
236
+ path="/v1/ai-voice-generator",
237
+ auth_names=["bearerAuth"],
238
+ json=_json,
239
+ cast_to=models.V1AiVoiceGeneratorCreateResponse,
240
+ request_options=request_options or default_request_options(),
241
+ )