o
    $`^h                     @   s(   d dl mZ d dlZG dd deZdS )    )absolute_importNc                       sB   e Zd ZdZejjjjejjjjdd fdd
Z	dd Z
  ZS )SpeechHelpersa  A set of convenience methods to make the Speech client easier to use.

    This class should be considered abstract; it is used as a superclass
    in a multiple-inheritance construction alongside the applicable GAPIC.
    See the :class:`~google.cloud.speech_v1.SpeechClient`.
     )retrytimeoutmetadatac                   s   t t| j| ||||dS )a0  Perform bi-directional speech recognition.

        This method allows you to receive results while sending audio;
        it is only available via. gRPC (not REST).

        .. warning::

            This method is EXPERIMENTAL. Its interface might change in the
            future.

        Example:
          >>> from google.cloud import speech_v1
          >>> client = speech_v1.SpeechClient()
          >>> config = speech_v1.StreamingRecognitionConfig(
          ...     config=speech_v1.RecognitionConfig(
          ...         encoding=speech_v1.RecognitionConfig.AudioEncoding.FLAC,
          ...     ),
          ... )
          >>> request = speech_v1.StreamingRecognizeRequest(audio_content=b'...')
          >>> requests = [request]
          >>> for element in client.streaming_recognize(config, requests):
          ...     # process element
          ...     pass

        Args:
            config (:class:`~.types.StreamingRecognitionConfig`): The
                configuration to use for the stream.
            requests (Iterable[:class:`~.types.StreamingRecognizeRequest`]):
                The input objects.
            retry (Optional[google.api_core.retry.Retry]):  A retry object used
                to retry requests. If ``None`` is specified, requests will not
                be retried.
            timeout (Optional[float]): The amount of time, in seconds, to wait
                for the request to complete. Note that if ``retry`` is
                specified, the timeout applies to each individual attempt.
            metadata (Sequence[Tuple[str, str]]): Strings which should be
                sent along with the request as metadata.

        Returns:
          Iterable[:class:`~.types.StreamingRecognizeResponse`]

        Raises:
          :exc:`ValueError` if the parameters are invalid.
        )requestsr   r   )superr   streaming_recognize_streaming_request_iterable)selfconfigr   r   r   r   	__class__r   \/home/air/shanriGPT/back/venv/lib/python3.10/site-packages/google/cloud/speech_v1/helpers.pyr
      s
   
5
z!SpeechHelpers.streaming_recognizec                 c   s     d|iV  |D ]}|V  qdS )a  A generator that yields the config followed by the requests.

        Args:
            config (~.speech_v1.types.StreamingRecognitionConfig): The
                configuration to use for the stream.
            requests (Iterable[~.speech_v1.types.StreamingRecognizeRequest]):
                The input objects.

        Returns:
            Iterable[~.speech_v1.types.StreamingRecognizeRequest]): The
                correctly formatted input for
                :meth:`~.speech_v1.SpeechClient.streaming_recognize`.
        streaming_configNr   )r   r   r   requestr   r   r   r   W   s
   
z)SpeechHelpers._streaming_request_iterable)__name__
__module____qualname____doc__googleapi_coregapic_v1methodDEFAULTr
   r   __classcell__r   r   r   r   r      s    

;r   )
__future__r   google.api_core.gapic_v1.methodr   objectr   r   r   r   r   <module>   s   