<?php
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# source: google/cloud/speech/v2/cloud_speech.proto

namespace Google\Cloud\Speech\V2;

use Google\Protobuf\Internal\GPBType;
use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;

/**
 * Request message for the
 * [StreamingRecognize][google.cloud.speech.v2.Speech.StreamingRecognize]
 * method. Multiple
 * [StreamingRecognizeRequest][google.cloud.speech.v2.StreamingRecognizeRequest]
 * messages are sent. The first message must contain a
 * [recognizer][google.cloud.speech.v2.StreamingRecognizeRequest.recognizer] and
 * optionally a
 * [streaming_config][google.cloud.speech.v2.StreamingRecognizeRequest.streaming_config]
 * message and must not contain
 * [audio][google.cloud.speech.v2.StreamingRecognizeRequest.audio]. All
 * subsequent messages must contain
 * [audio][google.cloud.speech.v2.StreamingRecognizeRequest.audio] and must not
 * contain a
 * [streaming_config][google.cloud.speech.v2.StreamingRecognizeRequest.streaming_config]
 * message.
 *
 * Generated from protobuf message <code>google.cloud.speech.v2.StreamingRecognizeRequest</code>
 */
class StreamingRecognizeRequest extends \Google\Protobuf\Internal\Message
{
    /**
     * Required. Streaming recognition should start with an initial request having
     * a `recognizer`. Subsequent requests carry the audio data to be recognized.
     * The initial request with configuration can be omitted if the Recognizer
     * being used has a
     * [default_recognition_config][google.cloud.speech.v2.Recognizer.default_recognition_config].
     *
     * Generated from protobuf field <code>string recognizer = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {</code>
     */
    private $recognizer = '';
    protected $streaming_request;

    /**
     * Constructor.
     *
     * @param array $data {
     *     Optional. Data for populating the Message object.
     *
     *     @type string $recognizer
     *           Required. Streaming recognition should start with an initial request having
     *           a `recognizer`. Subsequent requests carry the audio data to be recognized.
     *           The initial request with configuration can be omitted if the Recognizer
     *           being used has a
     *           [default_recognition_config][google.cloud.speech.v2.Recognizer.default_recognition_config].
     *     @type \Google\Cloud\Speech\V2\StreamingRecognitionConfig $streaming_config
     *           StreamingRecognitionConfig to be used in this recognition attempt.
     *           If provided, it will override the default RecognitionConfig stored in the
     *           Recognizer.
     *     @type string $audio
     *           Inline audio bytes to be Recognized.
     * }
     */
    public function __construct($data = NULL) {
        \GPBMetadata\Google\Cloud\Speech\V2\CloudSpeech::initOnce();
        parent::__construct($data);
    }

    /**
     * Required. Streaming recognition should start with an initial request having
     * a `recognizer`. Subsequent requests carry the audio data to be recognized.
     * The initial request with configuration can be omitted if the Recognizer
     * being used has a
     * [default_recognition_config][google.cloud.speech.v2.Recognizer.default_recognition_config].
     *
     * Generated from protobuf field <code>string recognizer = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {</code>
     * @return string
     */
    public function getRecognizer()
    {
        return $this->recognizer;
    }

    /**
     * Required. Streaming recognition should start with an initial request having
     * a `recognizer`. Subsequent requests carry the audio data to be recognized.
     * The initial request with configuration can be omitted if the Recognizer
     * being used has a
     * [default_recognition_config][google.cloud.speech.v2.Recognizer.default_recognition_config].
     *
     * Generated from protobuf field <code>string recognizer = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {</code>
     * @param string $var
     * @return $this
     */
    public function setRecognizer($var)
    {
        GPBUtil::checkString($var, True);
        $this->recognizer = $var;

        return $this;
    }

    /**
     * StreamingRecognitionConfig to be used in this recognition attempt.
     * If provided, it will override the default RecognitionConfig stored in the
     * Recognizer.
     *
     * Generated from protobuf field <code>.google.cloud.speech.v2.StreamingRecognitionConfig streaming_config = 6;</code>
     * @return \Google\Cloud\Speech\V2\StreamingRecognitionConfig|null
     */
    public function getStreamingConfig()
    {
        return $this->readOneof(6);
    }

    public function hasStreamingConfig()
    {
        return $this->hasOneof(6);
    }

    /**
     * StreamingRecognitionConfig to be used in this recognition attempt.
     * If provided, it will override the default RecognitionConfig stored in the
     * Recognizer.
     *
     * Generated from protobuf field <code>.google.cloud.speech.v2.StreamingRecognitionConfig streaming_config = 6;</code>
     * @param \Google\Cloud\Speech\V2\StreamingRecognitionConfig $var
     * @return $this
     */
    public function setStreamingConfig($var)
    {
        GPBUtil::checkMessage($var, \Google\Cloud\Speech\V2\StreamingRecognitionConfig::class);
        $this->writeOneof(6, $var);

        return $this;
    }

    /**
     * Inline audio bytes to be Recognized.
     *
     * Generated from protobuf field <code>bytes audio = 5;</code>
     * @return string
     */
    public function getAudio()
    {
        return $this->readOneof(5);
    }

    public function hasAudio()
    {
        return $this->hasOneof(5);
    }

    /**
     * Inline audio bytes to be Recognized.
     *
     * Generated from protobuf field <code>bytes audio = 5;</code>
     * @param string $var
     * @return $this
     */
    public function setAudio($var)
    {
        GPBUtil::checkString($var, False);
        $this->writeOneof(5, $var);

        return $this;
    }

    /**
     * @return string
     */
    public function getStreamingRequest()
    {
        return $this->whichOneof("streaming_request");
    }

}

