public TranscribeResponse GetTranscribeResponse(RepeatedField <SpeechRecognitionResult> results)
        {
            TranscribeResponse transcript = new TranscribeResponse();

            foreach (var result in results)
            {
                foreach (var alternative in result.Alternatives)
                {
                    Console.WriteLine($"Transcript: { alternative.Transcript}");
                    Console.WriteLine("Word details:");
                    Console.WriteLine($" Word count:{alternative.Words.Count}");

                    RspAlternative alt = new RspAlternative(alternative.Transcript)
                    {
                        wordCount = alternative.Words.Count
                    };

                    int count = 1;
                    foreach (var item in alternative.Words)
                    {
                        alt.words.Add(new RspWord(item.Word, ParseDuration(item.StartTime),
                                                  ParseDuration(item.EndTime), count++));

                        Console.WriteLine($"  {item.Word}");
                        Console.WriteLine($"    WordStartTime: {item.StartTime}");
                        Console.WriteLine($"    WordEndTime: {item.EndTime}");
                    }
                    transcript.alternatives.Add(alt);
                }
            }
            return(transcript);
        }
        public TranscribeResponse TranscribeInCloud(string objectName, string language)
        {
            var speech = SpeechClient.Create();

            string           fileOnCloudStorage = "gs://" + GoogleCloudBucketName + "/" + objectName;
            RecognitionAudio recogAudio         = RecognitionAudio.FromStorageUri(fileOnCloudStorage);

            var longOperation = speech.LongRunningRecognize(new RecognitionConfig()
            {
                Encoding              = RecognitionConfig.Types.AudioEncoding.Flac,
                SampleRateHertz       = 48000,
                EnableWordTimeOffsets = true,
                LanguageCode          = language,
            }, recogAudio);

            longOperation = longOperation.PollUntilCompleted();
            var response = longOperation.Result;

            // Transform the Google response into a more usable object.
            // TranscribeResponse transcript = GetLongTranscribeResponse(response);

            TranscribeResponse transcript = new TranscribeResponse();

            foreach (var result in response.Results)
            {
                foreach (var alternative in result.Alternatives)
                {
                    Console.WriteLine($"Transcript: { alternative.Transcript}");
                    Console.WriteLine("Word details:");
                    Console.WriteLine($" Word count:{alternative.Words.Count}");

                    RspAlternative alt = new RspAlternative(alternative.Transcript)
                    {
                        wordCount = alternative.Words.Count
                    };

                    int count = 1;
                    foreach (var item in alternative.Words)
                    {
                        alt.words.Add(new RspWord(item.Word, ParseDuration(item.StartTime),
                                                  ParseDuration(item.EndTime), count++));

                        Console.WriteLine($"  {item.Word}");
                        Console.WriteLine($"    WordStartTime: {item.StartTime}");
                        Console.WriteLine($"    WordEndTime: {item.EndTime}");
                    }
                    transcript.alternatives.Add(alt);
                }
            }


            return(transcript);
        }