
    >|h,                         d dl 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
 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 ddlmZ  e j,                  e j.                  d      Z G d d      Z G d d      Zy)    N   )SyncClientWrapper)core   )/SpeechToTextConvertRequestTimestampsGranularity)RequestOptions)SpeechToTextChunkResponseModel)construct_type)UnprocessableEntityError)HttpValidationError)JSONDecodeError)ApiError)AsyncClientWrapper.c                   ^   e Zd ZdefdZdeeeeeedddedej                  de	j                  e   de	j                  e   d	e	j                  e   d
e	j                  e   de	j                  e   de	j                  e   de	j                  e	j                  e      de	j                  e   defdZy)SpeechToTextClientclient_wrapperc                    || _         y N_client_wrapperselfr   s     _/var/www/html/test/engine/venv/lib/python3.12/site-packages/elevenlabs/speech_to_text/client.py__init__zSpeechToTextClient.__init__   
    -    Nenable_logginglanguage_codetag_audio_eventsnum_speakerstimestamps_granularitydiarizebiased_keywordsrequest_optionsmodel_idfiler   r   r    r!   r"   r#   r$   r%   returnc       
         b   | j                   j                  j                  ddd|i|||||||	dd|i|
t              }	 d|j                  cxk  rdk  r:n n7t        j                  t        t        t        |j                         	            S |j                  d
k(  r@t        t        j                  t        t        t        |j                         	                  |j                         }t        |j                  |      # t        $ r" t        |j                  |j                        w xY w)a
  
        Transcribe an audio or video file.

        Parameters
        ----------
        model_id : str
            The ID of the model to use for transcription, currently only 'scribe_v1' is available.

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

        enable_logging : typing.Optional[bool]
            When enable_logging is set to false zero retention mode will be used for the request. This will mean history features are unavailable for this request, including request stitching. Zero retention mode may only be used by enterprise customers.

        language_code : typing.Optional[str]
            An ISO-639-1 or ISO-639-3 language_code corresponding to the language of the audio file. Can sometimes improve transcription performance if known beforehand. Defaults to null, in this case the language is predicted automatically.

        tag_audio_events : typing.Optional[bool]
            Whether to tag audio events like (laughter), (footsteps), etc. in the transcription.

        num_speakers : typing.Optional[int]
            The maximum amount of speakers talking in the uploaded file. Can help with predicting who speaks when. The maximum amount of speakers that can be predicted is 32. Defaults to null, in this case the amount of speakers is set to the maximum value the model supports.

        timestamps_granularity : typing.Optional[SpeechToTextConvertRequestTimestampsGranularity]
            The granularity of the timestamps in the transcription. 'word' provides word-level timestamps and 'character' provides character-level timestamps per word.

        diarize : typing.Optional[bool]
            Whether to annotate which speaker is currently talking in the uploaded file.

        biased_keywords : typing.Optional[typing.List[str]]
            A list of keywords and their biases.          The keywords are the words that you want to bias the transcription towards.           The biases decide how much the model should boost or suppress the keyword.           The biases should be numbers between -10 and 10. The number of keywords cannot exceed 100.          The length of each keyword must be less than 50 characters.          Each keyword-bias pair must be separated by a colon.          For example ["keyword_a:0.42", "keyword_b:-0.5"]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        SpeechToTextChunkResponseModel
            Successful Response

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

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.speech_to_text.convert(
            model_id="model_id",
        )
        v1/speech-to-textPOSTr   r&   r   r    r!   r"   r#   r$   r'   methodparamsdatafilesr%   omit   ,  type_object_  status_codebodyr   httpx_clientrequestOMITr:   typingcastr	   r
   jsonr   r   r   r   textr   r&   r'   r   r   r    r!   r"   r#   r$   r%   	_response_response_jsons                r   convertzSpeechToTextClient.convert   s6   B ((55== . %!.$4 ,*@"#2  ,' > 
	*	Si++1c1{{2"< ) 0  $$+.KK+&"5$-NN$4  '^^-N 9#8#8~NN  	Sy'<'<9>>RR	Ss   AD AD +D.)__name__
__module____qualname__r   r   r?   strr   Filer@   Optionalboolintr   Listr   r	   rG    r   r   r   r      s
   .*; . 15.226-1cg)-=A;?lO lO ii	lO
 -lO s+lO !//$/lO ooc*lO !'0_ `lO &lO  S)9:lO  8lO 
(lOr   r   c                   ^   e Zd ZdefdZdeeeeeedddedej                  de	j                  e   de	j                  e   d	e	j                  e   d
e	j                  e   de	j                  e   de	j                  e   de	j                  e	j                  e      de	j                  e   defdZy)AsyncSpeechToTextClientr   c                    || _         y r   r   r   s     r   r   z AsyncSpeechToTextClient.__init__   r   r   Nr   r&   r'   r   r   r    r!   r"   r#   r$   r%   r(   c       
         ~  K   | j                   j                  j                  ddd|i|||||||	dd|i|
t               d{   }	 d|j                  cxk  rd	k  r:n n7t        j                  t        t        t        |j                         
            S |j                  dk(  r@t        t        j                  t        t        t        |j                         
                  |j                         }t        |j                  |      7 # t        $ r" t        |j                  |j                        w xY ww)a;  
        Transcribe an audio or video file.

        Parameters
        ----------
        model_id : str
            The ID of the model to use for transcription, currently only 'scribe_v1' is available.

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

        enable_logging : typing.Optional[bool]
            When enable_logging is set to false zero retention mode will be used for the request. This will mean history features are unavailable for this request, including request stitching. Zero retention mode may only be used by enterprise customers.

        language_code : typing.Optional[str]
            An ISO-639-1 or ISO-639-3 language_code corresponding to the language of the audio file. Can sometimes improve transcription performance if known beforehand. Defaults to null, in this case the language is predicted automatically.

        tag_audio_events : typing.Optional[bool]
            Whether to tag audio events like (laughter), (footsteps), etc. in the transcription.

        num_speakers : typing.Optional[int]
            The maximum amount of speakers talking in the uploaded file. Can help with predicting who speaks when. The maximum amount of speakers that can be predicted is 32. Defaults to null, in this case the amount of speakers is set to the maximum value the model supports.

        timestamps_granularity : typing.Optional[SpeechToTextConvertRequestTimestampsGranularity]
            The granularity of the timestamps in the transcription. 'word' provides word-level timestamps and 'character' provides character-level timestamps per word.

        diarize : typing.Optional[bool]
            Whether to annotate which speaker is currently talking in the uploaded file.

        biased_keywords : typing.Optional[typing.List[str]]
            A list of keywords and their biases.          The keywords are the words that you want to bias the transcription towards.           The biases decide how much the model should boost or suppress the keyword.           The biases should be numbers between -10 and 10. The number of keywords cannot exceed 100.          The length of each keyword must be less than 50 characters.          Each keyword-bias pair must be separated by a colon.          For example ["keyword_a:0.42", "keyword_b:-0.5"]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        SpeechToTextChunkResponseModel
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.speech_to_text.convert(
                model_id="model_id",
            )


        asyncio.run(main())
        r*   r+   r   r,   r'   r-   Nr3   r4   r5   r8   r9   r<   rD   s                r   rG   zAsyncSpeechToTextClient.convert   sF    R ..;;CC . %!.$4 ,*@"#2  ,' D 
 
	*	Si++1c1{{2"< ) 0  $$+.KK+&"5$-NN$4  '^^-N 9#8#8~NNW
R  	Sy'<'<9>>RR	Ss8   A D=DD=AD D=AD 6D=+D::D=)rH   rI   rJ   r   r   r?   rK   r   rL   r@   rM   rN   rO   r   rP   r   r	   rG   rQ   r   r   rS   rS      s
   .*< . 15.226-1cg)-=A;?tO tO ii	tO
 -tO s+tO !//$/tO ooc*tO !'0_ `tO &tO  S)9:tO  8tO 
(tOr   rS   )r@   core.client_wrapperr    r   ;types.speech_to_text_convert_request_timestamps_granularityr   core.request_optionsr   )types.speech_to_text_chunk_response_modelr	   core.unchecked_base_modelr
   !errors.unprocessable_entity_errorr   types.http_validation_errorr   json.decoderr   core.api_errorr   r   rA   Anyr?   r   rS   rQ   r   r   <module>ra      s`     3  x 1 V 6 H = ( % 4 v{{6::s#pO pOfxO xOr   