# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
"""Client and server classes corresponding to protobuf-defined services."""
import grpc
import warnings

from phonexia.grpc.technologies.speech_to_text.v1 import speech_to_text_pb2 as phonexia_dot_grpc_dot_technologies_dot_speech__to__text_dot_v1_dot_speech__to__text__pb2

GRPC_GENERATED_VERSION = '1.76.0'
GRPC_VERSION = grpc.__version__
_version_not_supported = False

try:
    from grpc._utilities import first_version_is_lower
    _version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION)
except ImportError:
    _version_not_supported = True

if _version_not_supported:
    raise RuntimeError(
        f'The grpc package installed is at version {GRPC_VERSION},'
        + ' but the generated code in phonexia/grpc/technologies/speech_to_text/v1/speech_to_text_pb2_grpc.py depends on'
        + f' grpcio>={GRPC_GENERATED_VERSION}.'
        + f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}'
        + f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.'
    )


class SpeechToTextStub(object):
    """Service implementing speech-to-text transcription.

    Error Handling:

    This service implements the richer gRPC error model using google.rpc.Status
    with detailed error information. When validation fails, the response includes:

    (1) Status code: INVALID_ARGUMENT
    (2) google.rpc.ErrorInfo with top-level error context:
    reason: "INPUT_ERROR"
    domain: "speech-to-text.phonexia"
    (3) google.rpc.BadRequest with field-level validation errors

    The `reason` field in each BadRequest.FieldViolation identifies the specific error type:

    * UNSUPPORTED_GRAPHEME - Character not supported by the transcription model
    * UNSUPPORTED_PHONEME - Phoneme not supported by the transcription model
    * EMPTY_FIELD - Required field is empty or missing
    * PRONUNCIATION_TOO_SHORT - Pronunciation contains fewer than 3 phonemes

    Field violations use dot notation with array indices to identify the exact
    location of errors. Examples:

    * "audio" - Audio field is missing or invalid
    * "config.additional_words[0].spelling" - Error in the spelling of the first additional word
    * "config.additional_words[2].pronunciations[1]" - Error in the second pronunciation of the third additional word
    * "config.preferred_phrases[5]" - Error in the sixth preferred phrase

    Example error response when a preferred phrase contains an unsupported character:
    ```
    code: INVALID_ARGUMENT
    message: "Invalid argument"
    details: [
    ErrorInfo {
    reason: "INPUT_ERROR"
    domain: "speech-to-text.phonexia"
    },
    BadRequest {
    field_violations: [
    {
    field: "config.preferred_phrases[1]"
    description: "Invalid grapheme 'é' in preferred phrase 'café'"
    reason: "UNSUPPORTED_GRAPHEME"
    }
    ]
    }
    ]
    ```
    See [Error handling](https://docs.cloud.phonexia.com/products/speech-platform-4/microservices/guides/error-handling) documentation for more information.

    """

    def __init__(self, channel):
        """Constructor.

        Args:
            channel: A grpc.Channel.
        """
        self.Transcribe = channel.stream_stream(
                '/phonexia.grpc.technologies.speech_to_text.v1.SpeechToText/Transcribe',
                request_serializer=phonexia_dot_grpc_dot_technologies_dot_speech__to__text_dot_v1_dot_speech__to__text__pb2.TranscribeRequest.SerializeToString,
                response_deserializer=phonexia_dot_grpc_dot_technologies_dot_speech__to__text_dot_v1_dot_speech__to__text__pb2.TranscribeResponse.FromString,
                _registered_method=True)
        self.ListAllowedSymbols = channel.unary_unary(
                '/phonexia.grpc.technologies.speech_to_text.v1.SpeechToText/ListAllowedSymbols',
                request_serializer=phonexia_dot_grpc_dot_technologies_dot_speech__to__text_dot_v1_dot_speech__to__text__pb2.ListAllowedSymbolsRequest.SerializeToString,
                response_deserializer=phonexia_dot_grpc_dot_technologies_dot_speech__to__text_dot_v1_dot_speech__to__text__pb2.ListAllowedSymbolsResponse.FromString,
                _registered_method=True)


class SpeechToTextServicer(object):
    """Service implementing speech-to-text transcription.

    Error Handling:

    This service implements the richer gRPC error model using google.rpc.Status
    with detailed error information. When validation fails, the response includes:

    (1) Status code: INVALID_ARGUMENT
    (2) google.rpc.ErrorInfo with top-level error context:
    reason: "INPUT_ERROR"
    domain: "speech-to-text.phonexia"
    (3) google.rpc.BadRequest with field-level validation errors

    The `reason` field in each BadRequest.FieldViolation identifies the specific error type:

    * UNSUPPORTED_GRAPHEME - Character not supported by the transcription model
    * UNSUPPORTED_PHONEME - Phoneme not supported by the transcription model
    * EMPTY_FIELD - Required field is empty or missing
    * PRONUNCIATION_TOO_SHORT - Pronunciation contains fewer than 3 phonemes

    Field violations use dot notation with array indices to identify the exact
    location of errors. Examples:

    * "audio" - Audio field is missing or invalid
    * "config.additional_words[0].spelling" - Error in the spelling of the first additional word
    * "config.additional_words[2].pronunciations[1]" - Error in the second pronunciation of the third additional word
    * "config.preferred_phrases[5]" - Error in the sixth preferred phrase

    Example error response when a preferred phrase contains an unsupported character:
    ```
    code: INVALID_ARGUMENT
    message: "Invalid argument"
    details: [
    ErrorInfo {
    reason: "INPUT_ERROR"
    domain: "speech-to-text.phonexia"
    },
    BadRequest {
    field_violations: [
    {
    field: "config.preferred_phrases[1]"
    description: "Invalid grapheme 'é' in preferred phrase 'café'"
    reason: "UNSUPPORTED_GRAPHEME"
    }
    ]
    }
    ]
    ```
    See [Error handling](https://docs.cloud.phonexia.com/products/speech-platform-4/microservices/guides/error-handling) documentation for more information.

    """

    def Transcribe(self, request_iterator, context):
        """Performs synchronous speech-to-text transcription.
        The transcription starts after the whole audio has been received.

        Errors:
        * INVALID_ARGUMENT: Invalid input parameters (see error details for specific violations)
        * RESOURCE_EXHAUSTED: No processing instances available
        * FAILED_PRECONDITION: License has expired
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def ListAllowedSymbols(self, request, context):
        """<code>ListAllowedSymbols</code> returns lists of allowed graphemes and phonemes.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')


def add_SpeechToTextServicer_to_server(servicer, server):
    rpc_method_handlers = {
            'Transcribe': grpc.stream_stream_rpc_method_handler(
                    servicer.Transcribe,
                    request_deserializer=phonexia_dot_grpc_dot_technologies_dot_speech__to__text_dot_v1_dot_speech__to__text__pb2.TranscribeRequest.FromString,
                    response_serializer=phonexia_dot_grpc_dot_technologies_dot_speech__to__text_dot_v1_dot_speech__to__text__pb2.TranscribeResponse.SerializeToString,
            ),
            'ListAllowedSymbols': grpc.unary_unary_rpc_method_handler(
                    servicer.ListAllowedSymbols,
                    request_deserializer=phonexia_dot_grpc_dot_technologies_dot_speech__to__text_dot_v1_dot_speech__to__text__pb2.ListAllowedSymbolsRequest.FromString,
                    response_serializer=phonexia_dot_grpc_dot_technologies_dot_speech__to__text_dot_v1_dot_speech__to__text__pb2.ListAllowedSymbolsResponse.SerializeToString,
            ),
    }
    generic_handler = grpc.method_handlers_generic_handler(
            'phonexia.grpc.technologies.speech_to_text.v1.SpeechToText', rpc_method_handlers)
    server.add_generic_rpc_handlers((generic_handler,))
    server.add_registered_method_handlers('phonexia.grpc.technologies.speech_to_text.v1.SpeechToText', rpc_method_handlers)


 # This class is part of an EXPERIMENTAL API.
class SpeechToText(object):
    """Service implementing speech-to-text transcription.

    Error Handling:

    This service implements the richer gRPC error model using google.rpc.Status
    with detailed error information. When validation fails, the response includes:

    (1) Status code: INVALID_ARGUMENT
    (2) google.rpc.ErrorInfo with top-level error context:
    reason: "INPUT_ERROR"
    domain: "speech-to-text.phonexia"
    (3) google.rpc.BadRequest with field-level validation errors

    The `reason` field in each BadRequest.FieldViolation identifies the specific error type:

    * UNSUPPORTED_GRAPHEME - Character not supported by the transcription model
    * UNSUPPORTED_PHONEME - Phoneme not supported by the transcription model
    * EMPTY_FIELD - Required field is empty or missing
    * PRONUNCIATION_TOO_SHORT - Pronunciation contains fewer than 3 phonemes

    Field violations use dot notation with array indices to identify the exact
    location of errors. Examples:

    * "audio" - Audio field is missing or invalid
    * "config.additional_words[0].spelling" - Error in the spelling of the first additional word
    * "config.additional_words[2].pronunciations[1]" - Error in the second pronunciation of the third additional word
    * "config.preferred_phrases[5]" - Error in the sixth preferred phrase

    Example error response when a preferred phrase contains an unsupported character:
    ```
    code: INVALID_ARGUMENT
    message: "Invalid argument"
    details: [
    ErrorInfo {
    reason: "INPUT_ERROR"
    domain: "speech-to-text.phonexia"
    },
    BadRequest {
    field_violations: [
    {
    field: "config.preferred_phrases[1]"
    description: "Invalid grapheme 'é' in preferred phrase 'café'"
    reason: "UNSUPPORTED_GRAPHEME"
    }
    ]
    }
    ]
    ```
    See [Error handling](https://docs.cloud.phonexia.com/products/speech-platform-4/microservices/guides/error-handling) documentation for more information.

    """

    @staticmethod
    def Transcribe(request_iterator,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.stream_stream(
            request_iterator,
            target,
            '/phonexia.grpc.technologies.speech_to_text.v1.SpeechToText/Transcribe',
            phonexia_dot_grpc_dot_technologies_dot_speech__to__text_dot_v1_dot_speech__to__text__pb2.TranscribeRequest.SerializeToString,
            phonexia_dot_grpc_dot_technologies_dot_speech__to__text_dot_v1_dot_speech__to__text__pb2.TranscribeResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def ListAllowedSymbols(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(
            request,
            target,
            '/phonexia.grpc.technologies.speech_to_text.v1.SpeechToText/ListAllowedSymbols',
            phonexia_dot_grpc_dot_technologies_dot_speech__to__text_dot_v1_dot_speech__to__text__pb2.ListAllowedSymbolsRequest.SerializeToString,
            phonexia_dot_grpc_dot_technologies_dot_speech__to__text_dot_v1_dot_speech__to__text__pb2.ListAllowedSymbolsResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)
