|
7 | 7 | from ..types.music_prompt import MusicPrompt
|
8 | 8 | from .composition_plan.client import AsyncCompositionPlanClient, CompositionPlanClient
|
9 | 9 | from .raw_client import AsyncRawMusicClient, RawMusicClient
|
| 10 | +from .types.music_compose_detailed_request_output_format import MusicComposeDetailedRequestOutputFormat |
10 | 11 | from .types.music_compose_request_output_format import MusicComposeRequestOutputFormat
|
11 | 12 | from .types.music_stream_request_output_format import MusicStreamRequestOutputFormat
|
12 | 13 |
|
@@ -83,6 +84,59 @@ def compose(
|
83 | 84 | ) as r:
|
84 | 85 | yield from r.data
|
85 | 86 |
|
| 87 | + def compose_detailed( |
| 88 | + self, |
| 89 | + *, |
| 90 | + output_format: typing.Optional[MusicComposeDetailedRequestOutputFormat] = None, |
| 91 | + prompt: typing.Optional[str] = OMIT, |
| 92 | + music_prompt: typing.Optional[MusicPrompt] = OMIT, |
| 93 | + composition_plan: typing.Optional[MusicPrompt] = OMIT, |
| 94 | + music_length_ms: typing.Optional[int] = OMIT, |
| 95 | + model_id: typing.Optional[typing.Literal["music_v1"]] = OMIT, |
| 96 | + request_options: typing.Optional[RequestOptions] = None, |
| 97 | + ) -> typing.Iterator[bytes]: |
| 98 | + """ |
| 99 | + Compose a song from a prompt or a composition plan. |
| 100 | +
|
| 101 | + Parameters |
| 102 | + ---------- |
| 103 | + output_format : typing.Optional[MusicComposeDetailedRequestOutputFormat] |
| 104 | + Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs. |
| 105 | +
|
| 106 | + prompt : typing.Optional[str] |
| 107 | + A simple text prompt to generate a song from. Cannot be used in conjunction with `composition_plan`. |
| 108 | +
|
| 109 | + music_prompt : typing.Optional[MusicPrompt] |
| 110 | + A music prompt. Deprecated. Use `composition_plan` instead. |
| 111 | +
|
| 112 | + composition_plan : typing.Optional[MusicPrompt] |
| 113 | + A detailed composition plan to guide music generation. Cannot be used in conjunction with `prompt`. |
| 114 | +
|
| 115 | + music_length_ms : typing.Optional[int] |
| 116 | + The length of the song to generate in milliseconds. Used only in conjunction with `prompt`. Must be between 10000ms and 300000ms. Optional - if not provided, the model will choose a length based on the prompt. |
| 117 | +
|
| 118 | + model_id : typing.Optional[typing.Literal["music_v1"]] |
| 119 | + The model to use for the generation. |
| 120 | +
|
| 121 | + request_options : typing.Optional[RequestOptions] |
| 122 | + Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. |
| 123 | +
|
| 124 | + Returns |
| 125 | + ------- |
| 126 | + typing.Iterator[bytes] |
| 127 | + Successful Response |
| 128 | + """ |
| 129 | + with self._raw_client.compose_detailed( |
| 130 | + output_format=output_format, |
| 131 | + prompt=prompt, |
| 132 | + music_prompt=music_prompt, |
| 133 | + composition_plan=composition_plan, |
| 134 | + music_length_ms=music_length_ms, |
| 135 | + model_id=model_id, |
| 136 | + request_options=request_options, |
| 137 | + ) as r: |
| 138 | + yield from r.data |
| 139 | + |
86 | 140 | def stream(
|
87 | 141 | self,
|
88 | 142 | *,
|
@@ -207,6 +261,60 @@ async def compose(
|
207 | 261 | async for _chunk in r.data:
|
208 | 262 | yield _chunk
|
209 | 263 |
|
| 264 | + async def compose_detailed( |
| 265 | + self, |
| 266 | + *, |
| 267 | + output_format: typing.Optional[MusicComposeDetailedRequestOutputFormat] = None, |
| 268 | + prompt: typing.Optional[str] = OMIT, |
| 269 | + music_prompt: typing.Optional[MusicPrompt] = OMIT, |
| 270 | + composition_plan: typing.Optional[MusicPrompt] = OMIT, |
| 271 | + music_length_ms: typing.Optional[int] = OMIT, |
| 272 | + model_id: typing.Optional[typing.Literal["music_v1"]] = OMIT, |
| 273 | + request_options: typing.Optional[RequestOptions] = None, |
| 274 | + ) -> typing.AsyncIterator[bytes]: |
| 275 | + """ |
| 276 | + Compose a song from a prompt or a composition plan. |
| 277 | +
|
| 278 | + Parameters |
| 279 | + ---------- |
| 280 | + output_format : typing.Optional[MusicComposeDetailedRequestOutputFormat] |
| 281 | + Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs. |
| 282 | +
|
| 283 | + prompt : typing.Optional[str] |
| 284 | + A simple text prompt to generate a song from. Cannot be used in conjunction with `composition_plan`. |
| 285 | +
|
| 286 | + music_prompt : typing.Optional[MusicPrompt] |
| 287 | + A music prompt. Deprecated. Use `composition_plan` instead. |
| 288 | +
|
| 289 | + composition_plan : typing.Optional[MusicPrompt] |
| 290 | + A detailed composition plan to guide music generation. Cannot be used in conjunction with `prompt`. |
| 291 | +
|
| 292 | + music_length_ms : typing.Optional[int] |
| 293 | + The length of the song to generate in milliseconds. Used only in conjunction with `prompt`. Must be between 10000ms and 300000ms. Optional - if not provided, the model will choose a length based on the prompt. |
| 294 | +
|
| 295 | + model_id : typing.Optional[typing.Literal["music_v1"]] |
| 296 | + The model to use for the generation. |
| 297 | +
|
| 298 | + request_options : typing.Optional[RequestOptions] |
| 299 | + Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. |
| 300 | +
|
| 301 | + Returns |
| 302 | + ------- |
| 303 | + typing.AsyncIterator[bytes] |
| 304 | + Successful Response |
| 305 | + """ |
| 306 | + async with self._raw_client.compose_detailed( |
| 307 | + output_format=output_format, |
| 308 | + prompt=prompt, |
| 309 | + music_prompt=music_prompt, |
| 310 | + composition_plan=composition_plan, |
| 311 | + music_length_ms=music_length_ms, |
| 312 | + model_id=model_id, |
| 313 | + request_options=request_options, |
| 314 | + ) as r: |
| 315 | + async for _chunk in r.data: |
| 316 | + yield _chunk |
| 317 | + |
210 | 318 | async def stream(
|
211 | 319 | self,
|
212 | 320 | *,
|
|
0 commit comments