/// <summary>
        /// Initializes a new instance of the AudioProcessor class given a specified window size, step size and an audio format handler
        /// </summary>
        /// <param name="windowSize">The number of seconds to be included in each request</param>
        /// <param name="stepSize">The number of seconds between every request</param>
        /// <param name="audioFormatHandler">A helper handler to process the input stream, and verify its type</param>
        public AudioProcessor(int windowSize, int stepSize, AudioFormatHandler audioFormatHandler)
        {
            if (windowSize <= 0)
            {
                throw new ArgumentException("Window size must be a positive integer", nameof(windowSize));
            }

            if (stepSize <= 0)
            {
                throw new ArgumentException("Step size must be a positive integer", nameof(stepSize));
            }

            _windowSize         = windowSize;
            _stepSize           = stepSize;
            _audioFormatHandler = audioFormatHandler ?? throw new ArgumentNullException(nameof(audioFormatHandler));

            _secondsQueue = new Queue <byte[]>();
            _wavesQueue   = new ConcurrentQueue <byte[]>();

            _lastSecond      = null;
            _lastSecondIndex = 0;

            _maxWaveHeaderSize = audioFormatHandler.InputAudioFormat.Container.MaxHeaderSize;

            _headerFound       = false;
            _headerBuffer      = new byte[_maxWaveHeaderSize];
            _headerBufferIndex = 0;
        }
        /// <summary>
        ///     Initializes a new instance of the RecognitionClient class.
        /// </summary>
        /// <param name="clientId">ID associated with all requests related to this client</param>
        /// <param name="speakerIds">Speaker IDs for identification</param>
        /// <param name="stepSize">Step size in seconds</param>
        /// <param name="windowSize">Number of seconds sent per request</param>
        /// <param name="audioFormat">Audio format</param>
        /// <param name="resultCallback">Value callback action consisted of identification result, client ID and request ID</param>
        /// <param name="serviceClient">Client used in identifying the streamed audio file</param>
        /// <param name="httpRequests"></param>
        internal RecognitionClient(Guid clientId, Guid[] speakerIds, int stepSize, int windowSize,
                                   AudioFormat audioFormat, Action <RecognitionResult> resultCallback,
                                   SpeakerIdentificationServiceClient serviceClient, List <Task> httpRequests)
        {
            ClientId    = clientId;
            SpeakerIds  = speakerIds;
            StepSize    = stepSize;
            WindowSize  = windowSize;
            _requestId  = 0;
            AudioFormat = audioFormat;
            var audioFormatHandler = new AudioFormatHandler(audioFormat);

            _serviceClient = serviceClient;
            _httpRequests  = httpRequests;

            _audioProcessor = new AudioProcessor(WindowSize, StepSize, audioFormatHandler);
            _idClient       = new IdentificationClient(SpeakerIds, resultCallback);

            _requestingTaskCancelletionTokenSource = new CancellationTokenSource();
            _requestingTask = Task.Run(async() =>
            {
                await SendingRequestsTask(_requestingTaskCancelletionTokenSource.Token).ConfigureAwait(false);
            });
        }