o
    lWiav                     @  s   d dl mZ d dlZddlmZ ddlmZmZ ddlm	Z	 ddl
mZ dd	lmZmZ dd
lmZ ddlmZ ddlmZ ddlmZ ddlmZ ejrUddlmZmZ eejdZG dd dZ G dd dZ!dS )    )annotationsN   )core)AsyncClientWrapperSyncClientWrapper)RequestOptions)MusicPrompt   )AsyncRawMusicClientRawMusicClient)'MusicComposeDetailedRequestOutputFormat)MusicComposeRequestOutputFormat)%MusicSeparateStemsRequestOutputFormat)(MusicSeparateStemsRequestStemVariationId)MusicStreamRequestOutputFormat)AsyncCompositionPlanClientCompositionPlanClient.c                   @     e Zd Zd2ddZed3ddZd	eeeeeeeed	d

d4ddZd	eeeeeeeed	d
d5d"d#Zd	eeeeeed	d$d6d&d'Z	d	eed	d(d7d.d/Z
ed0d1 Zd	S )8MusicClientclient_wrapperr   c                C     t |d| _|| _d | _d S Nr   )r   _raw_client_client_wrapper_composition_planselfr    r   [/var/www/html/asistente-voz-ia/venv/lib/python3.10/site-packages/elevenlabs/music/client.py__init__      
zMusicClient.__init__returnr   c                 C     | j S )z
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        RawMusicClient
        r   r   r   r   r   with_raw_response      	zMusicClient.with_raw_responseN
output_formatpromptcomposition_planmusic_length_msmodel_idforce_instrumentalrespect_sections_durationsstore_for_inpaintingsign_with_c_2_parequest_optionsr)   0typing.Optional[MusicComposeRequestOutputFormat]r*   typing.Optional[str]r+   typing.Optional[MusicPrompt]r,   typing.Optional[int]r-   +typing.Optional[typing.Literal['music_v1']]r.   typing.Optional[bool]r/   r0   r1   r2   typing.Optional[RequestOptions]typing.Iterator[bytes]c       
         c  T    | j j|||||||||	|
d
}|jE dH  W d   dS 1 s#w   Y  dS )u^  
        Compose a song from a prompt or a composition plan.

        Parameters
        ----------
        output_format : typing.Optional[MusicComposeRequestOutputFormat]
            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.

        prompt : typing.Optional[str]
            A simple text prompt to generate a song from. Cannot be used in conjunction with `composition_plan`.

        composition_plan : typing.Optional[MusicPrompt]
            A detailed composition plan to guide music generation. Cannot be used in conjunction with `prompt`.

        music_length_ms : typing.Optional[int]
            The length of the song to generate in milliseconds. Used only in conjunction with `prompt`. Must be between 3000ms and 300000ms. Optional - if not provided, the model will choose a length based on the prompt.

        model_id : typing.Optional[typing.Literal["music_v1"]]
            The model to use for the generation.

        force_instrumental : typing.Optional[bool]
            If true, guarantees that the generated song will be instrumental. If false, the song may or may not be instrumental depending on the `prompt`. Can only be used with `prompt`.

        respect_sections_durations : typing.Optional[bool]
            Controls how strictly section durations in the `composition_plan` are enforced. Only used with `composition_plan`. When set to true, the model will precisely respect each section's `duration_ms` from the plan. When set to false, the model may adjust individual section durations which will generally lead to better generation quality and improved latency, while always preserving the total song duration from the plan.

        store_for_inpainting : typing.Optional[bool]
            Whether to store the generated song for inpainting. Only available to enterprise clients with access to the inpainting API.

        sign_with_c_2_pa : typing.Optional[bool]
            Whether to sign the generated song with C2PA. Applicable only for mp3 files.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.

        Returns
        -------
        typing.Iterator[bytes]
            The generated audio file in the format specified

        Examples
        --------
        from elevenlabs import ElevenLabs

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.music.compose()
        r(   Nr   composedata)r   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   rr   r   r   r=   )       ?"zMusicClient.compose
r)   r*   r+   r,   r-   r.   r0   with_timestampsr1   r2   8typing.Optional[MusicComposeDetailedRequestOutputFormat]rB   c       
         c  r;   )u
  
        Compose a song from a prompt or a composition plan.

        Parameters
        ----------
        output_format : typing.Optional[MusicComposeDetailedRequestOutputFormat]
            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.

        prompt : typing.Optional[str]
            A simple text prompt to generate a song from. Cannot be used in conjunction with `composition_plan`.

        composition_plan : typing.Optional[MusicPrompt]
            A detailed composition plan to guide music generation. Cannot be used in conjunction with `prompt`.

        music_length_ms : typing.Optional[int]
            The length of the song to generate in milliseconds. Used only in conjunction with `prompt`. Must be between 3000ms and 300000ms. Optional - if not provided, the model will choose a length based on the prompt.

        model_id : typing.Optional[typing.Literal["music_v1"]]
            The model to use for the generation.

        force_instrumental : typing.Optional[bool]
            If true, guarantees that the generated song will be instrumental. If false, the song may or may not be instrumental depending on the `prompt`. Can only be used with `prompt`.

        store_for_inpainting : typing.Optional[bool]
            Whether to store the generated song for inpainting. Only available to enterprise clients with access to the inpainting API.

        with_timestamps : typing.Optional[bool]
            Whether to return the timestamps of the words in the generated song.

        sign_with_c_2_pa : typing.Optional[bool]
            Whether to sign the generated song with C2PA. Applicable only for mp3 files.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.

        Returns
        -------
        typing.Iterator[bytes]
            Multipart/mixed response with JSON metadata and binary audio file

        Examples
        --------
        from elevenlabs import ElevenLabs

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.music.compose_detailed()
        rA   Nr   compose_detailedr>   )r   r)   r*   r+   r,   r-   r.   r0   rB   r1   r2   r?   r   r   r   rE   v   r@   zMusicClient.compose_detailedr)   r*   r+   r,   r-   r.   r0   r2   /typing.Optional[MusicStreamRequestOutputFormat]c          
   
   c  sP    | j j||||||||d}	|	jE dH  W d   dS 1 s!w   Y  dS )u  
        Stream a composed song from a prompt or a composition plan.

        Parameters
        ----------
        output_format : typing.Optional[MusicStreamRequestOutputFormat]
            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.

        prompt : typing.Optional[str]
            A simple text prompt to generate a song from. Cannot be used in conjunction with `composition_plan`.

        composition_plan : typing.Optional[MusicPrompt]
            A detailed composition plan to guide music generation. Cannot be used in conjunction with `prompt`.

        music_length_ms : typing.Optional[int]
            The length of the song to generate in milliseconds. Used only in conjunction with `prompt`. Must be between 3000ms and 300000ms. Optional - if not provided, the model will choose a length based on the prompt.

        model_id : typing.Optional[typing.Literal["music_v1"]]
            The model to use for the generation.

        force_instrumental : typing.Optional[bool]
            If true, guarantees that the generated song will be instrumental. If false, the song may or may not be instrumental depending on the `prompt`. Can only be used with `prompt`.

        store_for_inpainting : typing.Optional[bool]
            Whether to store the generated song for inpainting. Only available to enterprise clients with access to the inpainting API.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.

        Returns
        -------
        typing.Iterator[bytes]
            Streaming audio data in the format specified

        Examples
        --------
        from elevenlabs import ElevenLabs

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.music.stream()
        rF   Nr   streamr>   )
r   r)   r*   r+   r,   r-   r.   r0   r2   r?   r   r   r   rI      s   7	"zMusicClient.streamr)   stem_variation_idr1   r2   file	core.File6typing.Optional[MusicSeparateStemsRequestOutputFormat]rK   9typing.Optional[MusicSeparateStemsRequestStemVariationId]c                c  sJ    | j j|||||d}|jE dH  W d   dS 1 sw   Y  dS )u  
        Separate an audio file into individual stems. This endpoint might have high latency, depending on the length of the audio file.

        Parameters
        ----------
        file : core.File
            See core.File for more documentation

        output_format : typing.Optional[MusicSeparateStemsRequestOutputFormat]
            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.

        stem_variation_id : typing.Optional[MusicSeparateStemsRequestStemVariationId]
            The id of the stem variation to use.

        sign_with_c_2_pa : typing.Optional[bool]
            Whether to sign the generated song with C2PA. Applicable only for mp3 files.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.

        Returns
        -------
        typing.Iterator[bytes]
            ZIP archive containing separated audio stems. Each stem is provided as a separate audio file in the requested output format.
        rL   r)   rK   r1   r2   Nr   separate_stemsr>   )r   rL   r)   rK   r1   r2   r?   r   r   r   rR     s   ""zMusicClient.separate_stemsc                 C  *   | j d u rddlm} || jd| _ | j S )Nr	   )r   r   )r   composition_plan.clientr   r   )r   r   r   r   r   r+   1     
zMusicClient.composition_plan)r   r   )r"   r   )r)   r3   r*   r4   r+   r5   r,   r6   r-   r7   r.   r8   r/   r8   r0   r8   r1   r8   r2   r9   r"   r:   )r)   rC   r*   r4   r+   r5   r,   r6   r-   r7   r.   r8   r0   r8   rB   r8   r1   r8   r2   r9   r"   r:   )r)   rG   r*   r4   r+   r5   r,   r6   r-   r7   r.   r8   r0   r8   r2   r9   r"   r:   )rL   rM   r)   rN   rK   rO   r1   r8   r2   r9   r"   r:   __name__
__module____qualname__r    propertyr&   OMITr=   rE   rI   rR   r+   r   r   r   r   r      sT    
PPG+r   c                   @  r   )8AsyncMusicClientr   r   c                C  r   r   )r
   r   r   r   r   r   r   r   r    ;  r!   zAsyncMusicClient.__init__r"   r
   c                 C  r#   )z
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        AsyncRawMusicClient
        r$   r%   r   r   r   r&   @  r'   z"AsyncMusicClient.with_raw_responseNr(   r)   r3   r*   r4   r+   r5   r,   r6   r-   r7   r.   r8   r/   r0   r1   r2   r9   typing.AsyncIterator[bytes]c       
         C x   | j j|||||||||	|
d
4 I dH }|j2 z	3 dH W }|V  q6 W d  I dH  dS 1 I dH s5w   Y  dS )u  
        Compose a song from a prompt or a composition plan.

        Parameters
        ----------
        output_format : typing.Optional[MusicComposeRequestOutputFormat]
            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.

        prompt : typing.Optional[str]
            A simple text prompt to generate a song from. Cannot be used in conjunction with `composition_plan`.

        composition_plan : typing.Optional[MusicPrompt]
            A detailed composition plan to guide music generation. Cannot be used in conjunction with `prompt`.

        music_length_ms : typing.Optional[int]
            The length of the song to generate in milliseconds. Used only in conjunction with `prompt`. Must be between 3000ms and 300000ms. Optional - if not provided, the model will choose a length based on the prompt.

        model_id : typing.Optional[typing.Literal["music_v1"]]
            The model to use for the generation.

        force_instrumental : typing.Optional[bool]
            If true, guarantees that the generated song will be instrumental. If false, the song may or may not be instrumental depending on the `prompt`. Can only be used with `prompt`.

        respect_sections_durations : typing.Optional[bool]
            Controls how strictly section durations in the `composition_plan` are enforced. Only used with `composition_plan`. When set to true, the model will precisely respect each section's `duration_ms` from the plan. When set to false, the model may adjust individual section durations which will generally lead to better generation quality and improved latency, while always preserving the total song duration from the plan.

        store_for_inpainting : typing.Optional[bool]
            Whether to store the generated song for inpainting. Only available to enterprise clients with access to the inpainting API.

        sign_with_c_2_pa : typing.Optional[bool]
            Whether to sign the generated song with C2PA. Applicable only for mp3 files.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.

        Returns
        -------
        typing.AsyncIterator[bytes]
            The generated audio file in the format specified

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.music.compose()


        asyncio.run(main())
        r(   Nr<   )r   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r?   _chunkr   r   r   r=   K  $   G.zAsyncMusicClient.composerA   rC   rB   c       
         C r^   )u
  
        Compose a song from a prompt or a composition plan.

        Parameters
        ----------
        output_format : typing.Optional[MusicComposeDetailedRequestOutputFormat]
            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.

        prompt : typing.Optional[str]
            A simple text prompt to generate a song from. Cannot be used in conjunction with `composition_plan`.

        composition_plan : typing.Optional[MusicPrompt]
            A detailed composition plan to guide music generation. Cannot be used in conjunction with `prompt`.

        music_length_ms : typing.Optional[int]
            The length of the song to generate in milliseconds. Used only in conjunction with `prompt`. Must be between 3000ms and 300000ms. Optional - if not provided, the model will choose a length based on the prompt.

        model_id : typing.Optional[typing.Literal["music_v1"]]
            The model to use for the generation.

        force_instrumental : typing.Optional[bool]
            If true, guarantees that the generated song will be instrumental. If false, the song may or may not be instrumental depending on the `prompt`. Can only be used with `prompt`.

        store_for_inpainting : typing.Optional[bool]
            Whether to store the generated song for inpainting. Only available to enterprise clients with access to the inpainting API.

        with_timestamps : typing.Optional[bool]
            Whether to return the timestamps of the words in the generated song.

        sign_with_c_2_pa : typing.Optional[bool]
            Whether to sign the generated song with C2PA. Applicable only for mp3 files.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.

        Returns
        -------
        typing.AsyncIterator[bytes]
            Multipart/mixed response with JSON metadata and binary audio file

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.music.compose_detailed()


        asyncio.run(main())
        rA   NrD   )r   r)   r*   r+   r,   r-   r.   r0   rB   r1   r2   r?   r_   r   r   r   rE     r`   z!AsyncMusicClient.compose_detailedrF   rG   c             
   C st   | j j||||||||d4 I dH }	|	j2 z	3 dH W }
|
V  q6 W d  I dH  dS 1 I dH s3w   Y  dS )u]	  
        Stream a composed song from a prompt or a composition plan.

        Parameters
        ----------
        output_format : typing.Optional[MusicStreamRequestOutputFormat]
            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.

        prompt : typing.Optional[str]
            A simple text prompt to generate a song from. Cannot be used in conjunction with `composition_plan`.

        composition_plan : typing.Optional[MusicPrompt]
            A detailed composition plan to guide music generation. Cannot be used in conjunction with `prompt`.

        music_length_ms : typing.Optional[int]
            The length of the song to generate in milliseconds. Used only in conjunction with `prompt`. Must be between 3000ms and 300000ms. Optional - if not provided, the model will choose a length based on the prompt.

        model_id : typing.Optional[typing.Literal["music_v1"]]
            The model to use for the generation.

        force_instrumental : typing.Optional[bool]
            If true, guarantees that the generated song will be instrumental. If false, the song may or may not be instrumental depending on the `prompt`. Can only be used with `prompt`.

        store_for_inpainting : typing.Optional[bool]
            Whether to store the generated song for inpainting. Only available to enterprise clients with access to the inpainting API.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.

        Returns
        -------
        typing.AsyncIterator[bytes]
            Streaming audio data in the format specified

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.music.stream()


        asyncio.run(main())
        rF   NrH   )r   r)   r*   r+   r,   r-   r.   r0   r2   r?   r_   r   r   r   rI     s    ?	.zAsyncMusicClient.streamrJ   rL   rM   rN   rK   rO   c             	   C sn   | j j|||||d4 I dH }|j2 z	3 dH W }|V  q6 W d  I dH  dS 1 I dH s0w   Y  dS )u  
        Separate an audio file into individual stems. This endpoint might have high latency, depending on the length of the audio file.

        Parameters
        ----------
        file : core.File
            See core.File for more documentation

        output_format : typing.Optional[MusicSeparateStemsRequestOutputFormat]
            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.

        stem_variation_id : typing.Optional[MusicSeparateStemsRequestStemVariationId]
            The id of the stem variation to use.

        sign_with_c_2_pa : typing.Optional[bool]
            Whether to sign the generated song with C2PA. Applicable only for mp3 files.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.

        Returns
        -------
        typing.AsyncIterator[bytes]
            ZIP archive containing separated audio stems. Each stem is provided as a separate audio file in the requested output format.
        rP   NrQ   )r   rL   r)   rK   r1   r2   r?   r_   r   r   r   rR   C  s   ".zAsyncMusicClient.separate_stemsc                 C  rS   )Nr	   )r   r   )r   rT   r   r   )r   r   r   r   r   r+   o  rU   z!AsyncMusicClient.composition_plan)r   r   )r"   r
   )r)   r3   r*   r4   r+   r5   r,   r6   r-   r7   r.   r8   r/   r8   r0   r8   r1   r8   r2   r9   r"   r]   )r)   rC   r*   r4   r+   r5   r,   r6   r-   r7   r.   r8   r0   r8   rB   r8   r1   r8   r2   r9   r"   r]   )r)   rG   r*   r4   r+   r5   r,   r6   r-   r7   r.   r8   r0   r8   r2   r9   r"   r]   )rL   rM   r)   rN   rK   rO   r1   r8   r2   r9   r"   r]   rV   r   r   r   r   r\   :  sT    
YYP,r\   )"
__future__r   typing r   core.client_wrapperr   r   core.request_optionsr   types.music_promptr   
raw_clientr
   r   2types.music_compose_detailed_request_output_formatr   )types.music_compose_request_output_formatr   0types.music_separate_stems_request_output_formatr   4types.music_separate_stems_request_stem_variation_idr   (types.music_stream_request_output_formatr   TYPE_CHECKINGrT   r   r   castAnyr[   r   r\   r   r   r   r   <module>   s&     $